You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The first directional derivative `dϕ[1]` tells me if I move up or down the potential. The second directional derivative `dϕ[2]` tells me how fast the first changes. The gradient `∇ϕ!` tells me the surface I want to reflect on.
211
+
212
+
dϕ = function (t, x, v, args...) # two directional derivatives
213
+
u = ForwardDiff.derivative(t -> -ℓ(x + t*v), Dual{:hSrkahPmmC}(0.0, 1.0))
214
+
u.value, u.partials[]
215
+
end
216
+
∇ϕ! = function (y, t, x, args...)
217
+
ForwardDiff.gradient!(y, ℓ, x)
218
+
y .= -y
219
+
y
220
+
end
221
+
222
+
The remaining arguments:
223
+
224
+
d = 25 # number of parameters
225
+
t0 = 0.0
226
+
x0 = zeros(d) # starting point sampler
227
+
θ0 = randn(d) # starting direction sampler
228
+
T = 200. # end time (similar to number of samples in MCMC)
229
+
c = 50.0 # initial guess for the bound
230
+
231
+
# define BouncyParticle sampler (has two relevant parameters)
232
+
Z = BouncyParticle(∅, ∅, # ignored
233
+
10.0, # momentum refreshment rate
234
+
0.95, # momentum correlation / only gradually change momentum in refreshment/momentum update
235
+
0.0, # ignored
236
+
I # left cholesky factor of momentum precision
237
+
)
238
+
239
+
trace, final, (acc, num), cs = @time pdmp(
240
+
dneglogp, # return first two directional derivatives of negative target log-likelihood in direction v
241
+
∇neglogp!, # return gradient of negative target log-likelihood
242
+
t0, x0, θ0, T, # initial state and duration
243
+
ZZB.LocalBound(c), # use Hessian information
244
+
Z; # sampler
245
+
oscn=false, # no orthogonal subspace pCR
246
+
adapt=true, # adapt bound c
247
+
progress=true, # show progress bar
248
+
subsample=true # keep only samples at refreshment times
249
+
)
250
+
251
+
# to obtain direction change times and points of piecewise linear trace
0 commit comments