BridgeLandmarks.jl
BridgeLandmarks.GuidRecursions
BridgeLandmarks.GuidedProposal!
BridgeLandmarks.ObsInfo
Base.:*
Base.:*
Base.conj!
Base.show
Bridge.B
Bridge.B
Bridge.B!
Bridge.B!
Bridge._b!
Bridge.a
Bridge.b!
Bridge.b!
Bridge.b!
Bridge.σ!
Bridge.σ!
Bridge.σ!
BridgeLandmarks.HMC
BridgeLandmarks._r!
BridgeLandmarks.amul
BridgeLandmarks.amul
BridgeLandmarks.amul
BridgeLandmarks.cholinverse!
BridgeLandmarks.construct_nfs
BridgeLandmarks.convert_samplepath
BridgeLandmarks.convert_samplepath
BridgeLandmarks.getpars
BridgeLandmarks.guidingbackwards!
BridgeLandmarks.hamiltonian
BridgeLandmarks.init_guidrec
BridgeLandmarks.kernel
BridgeLandmarks.landmarksforward
BridgeLandmarks.lm_gpupdate!
BridgeLandmarks.lm_mcmc
BridgeLandmarks.lyapunovpsdbackward_step!
BridgeLandmarks.lρtilde
BridgeLandmarks.plotshapes
BridgeLandmarks.putpars!
BridgeLandmarks.set_obsinfo
BridgeLandmarks.simguidedlm_llikelihood!
BridgeLandmarks.simguidedlm_llikelihood!
BridgeLandmarks.slogρ!
BridgeLandmarks.update_guidrec!
BridgeLandmarks.update_initialstate!
BridgeLandmarks.update_pars!
BridgeLandmarks.update_path!
BridgeLandmarks.z
BridgeLandmarks.σp
BridgeLandmarks.σq
BridgeLandmarks.σq
BridgeLandmarks.σt!
BridgeLandmarks.σt!
BridgeLandmarks.σtmul
BridgeLandmarks.∇K̄
BridgeLandmarks.∇kernel
BridgeLandmarks.∇kernel
BridgeLandmarks.∇z
BridgeLandmarks.construct_nfs
— Method.Construct sequence of Noisefields for AHS model
db: domainbound (sources are places on square grid specified by
(-db:2nfstd:db) x -db:2nfstd:db
nfstd: standard deviation of noise fields (the smaller: the more noise fields we use)
γ: if set to one, then the value of the noise field on the positions is approximately 1 at all locations in the domain
BridgeLandmarks.landmarksforward
— Method.Forward simulate landmarks process specified by P on grid t.
Returns driving motion W and landmarks process X
t: time grid
x0: starting point
P: landmarks specification
BridgeLandmarks.lm_mcmc
— Method.Perform mcmc or sgd for landmarks model using the LM-parametrisation
tt_: time grid
(xobs0,xobsT): observations at times 0 and T (at time T this is a vector)
σobs: standard deviation of Gaussian noise assumed on xobs0 and xobsT
mT: vector of momenta at time T used for constructing guiding term
P: target process
sampler: either sgd (stochastic gradient descent) or mcmc (Markov Chain Monte Carlo)
obs_atzero: Boolean, if true there is an observation at time zero
fixinitmomentato0: Boolean, if true we assume at time zero we observe zero momenta
xinit: initial guess on starting state
ITER: number of iterations
subsamples: vector of indices of iterations that are to be saved
ρ: Crank-Nicolson parameter (ρ=0 is independence sampler)
δ: step size for MALA updates on initial state (first component for positions, second component for momenta)
prior_a: prior on parameter a
prior_c: prior on parameter c
prior_γ: prior on parameter γ
σ_a: parameter determining update proposal for a [update a to aᵒ as aᵒ = a * exp(σ_a * rnorm())]
σ_c: parameter determining update proposal for c [update c to cᵒ as cᵒ = c * exp(σ_c * rnorm())]
σ_γ: parameter determining update proposal for γ [update γ to γᵒ as γᵒ = γ * exp(σ_γ * rnorm())]
outdir: output directory for animation
pb:: Lmplotbounds (axis used for plotting landmarks evolution)
updatepars: logical flag for updating pars a, c, γ
makefig: logical flag for making figures
showmomenta: logical flag if momenta are also drawn in figures
Returns:
Xsave: saved iterations of all states at all times in tt_
parsave: saved iterations of all parameter updates ,
objvals: saved values of stochastic approximation to loglikelihood
perc_acc: acceptance percentages (bridgepath - inital state)
anim, Xsave, parsave, objvals, perc_acc = lm_mcmc_mv(tt_, (xobs0,xobsTvec), σobs, mT, P,
sampler, obs_atzero,
xinit, ITER, subsamples,
(δ, prior_a, prior_c, prior_γ, σ_a, σ_c, σ_γ),
outdir, pb; updatepars = true, makefig=true, showmomenta=false)
BridgeLandmarks.GuidRecursions
— Type.GuidRecursions defines a struct that contains all info required for computing the guiding term and
likelihood (including ptilde term) for a single shape
BridgeLandmarks.GuidedProposal!
— Type.struct that contains target, auxiliary process for each shape, time grid, observation at time 0, observations
at time T, number of shapes, and momenta in final state used for constructing the auxiliary processes
guidrec is a vector of GuidRecursions, which contains the results from the backward recursions and gpupdate step at time zero
BridgeLandmarks.ObsInfo
— Type.Observe V0 = L0 X0 + N(0,Σ0) and VT = LT X0 + N(0,ΣT)
μT is just a vector of zeros (possibly remove later)
Base.:*
— Method.Compute y = HX where Hinv = LL' (Cholesky decomposition
Input are L and X, output is Y
y=HX is equivalent to LL'y=X, which can be solved by first backsolving LZ=X for z and next backsolving L'Y=Z
L is a lower triangular matrix with element of type UncMat X is a matrix with elements of type UncMat Returns a matrix with elements of type UncMat
Base.:*
— Method.Compute y = Hx where Hinv = LL' (Cholesky decomposition
Input are L and x, output is y
y=Hx is equivalent to LL'y=x, which can be solved by first backsolving Lz=x for z and next backsolving L'y=z
L is a lower triangular matrix with element of type UncMat x is a State or vector of points Returns a State (Todo: split up again and return vector for vector input)
Base.conj!
— Method.Compute transpose of square matrix of Unc matrices
A = reshape([Unc(1:4), Unc(5:8), Unc(9:12), Unc(13:16)],2,2) B = copy(A) A conj!(B)
Base.show
— Method.Good display of variable of type State
Bridge.B!
— Method.Compute B̃(t) * X (B̃ from auxiliary process) and write to out Both B̃(t) and X are of type UncMat
Bridge.B!
— Method.Compute B̃(t) * X (B̃ from auxiliary process) and write to out Both B̃(t) and X are of type UncMat
Bridge.B
— Method.Compute tildeB(t) for landmarks auxiliary process
Bridge.B
— Method.Compute tildeB(t) for landmarks auxiliary process
Bridge._b!
— Method.Evaluate drift bᵒ of guided proposal at (t,x), write into out
Bridge.a
— Method.Returns matrix a(t) for Marsland-Shardlow model
Bridge.b!
— Method.Evaluate drift of landmarks auxiliary process in (t,x) and save to out x is a state and out as well
Bridge.b!
— Method.Evaluate drift of landmarks in (t,x) and save to out x is a state and out as well
Bridge.b!
— Method.Evaluate drift of landmarks in (t,x) and save to out x is a state and out as well
Bridge.σ!
— Method.Evaluate σ(t,x) dW and write into out
Bridge.σ!
— Method.Compute sigma(t,x) * dm where dm is a vector and sigma is the diffusion coefficient of landmarks write to out which is of type State
Bridge.σ!
— Method.compute σ(t,x) * dm and write to out
BridgeLandmarks.HMC
— Method.Adapting Radford Neal's R implementation of Hamiltonian Monte Carlo with
stepsize ϵ and L steps
BridgeLandmarks._r!
— Method.Evaluate tilder (appearing in guiding term of guided proposal) at (t,x), write into out
BridgeLandmarks.amul
— Method.Multiply a(t,x) times a vector of points Returns a State (first multiply with sigma', via function σtmul, next left-multiply this vector with σ)
BridgeLandmarks.amul
— Method.Multiply a(t,x) times a state Returns a state (first multiply with sigma', via function σtmul, next left-multiply this vector with σ)
BridgeLandmarks.amul
— Method.Multiply a(t,x) times xin (which is of type state) Returns variable of type State
BridgeLandmarks.cholinverse!
— Method.Solve L L'y =x using two backsolves, L should be lower triangular
BridgeLandmarks.convert_samplepath
— Method.Useful for storage of a samplepath of states
Ordering is as follows:
1) time
2) landmark nr
3) for each landmark: q1, q2 p1, p2
With m time-steps, n landmarks, this entails a vector of length m * n * 2 * d
BridgeLandmarks.convert_samplepath
— Method.Useful for storage of a samplepath of states
Ordering is as follows:
0) shape
1) time
2) landmark nr
3) for each landmark: q1, q2 p1, p2
With m time-steps, n landmarks, this entails a vector of length m * n * 2 * d
BridgeLandmarks.getpars
— Method.Extract parameters from GuidedProposal! Q
BridgeLandmarks.guidingbackwards!
— Method.Solve backwards recursions in L, M, μ parametrisation on grid t
implicit: if true, Euler backwards is used for solving ODE for Lt, else Euler forwards is used
Case lowrank=true still gives an error: fixme!
BridgeLandmarks.hamiltonian
— Method.Hamiltonian for deterministic part of landmarks model
BridgeLandmarks.init_guidrec
— Method.Initialise (allocate memory) a struct of type GuidRecursions for a single shape
guidres = init_guidrec((t,obs_info,xobs0)
BridgeLandmarks.kernel
— Method.kernel in Hamiltonian
BridgeLandmarks.lm_gpupdate!
— Method.Guided proposal update for newly incoming observation at time zero.
Information on new observations at time zero is (L0, Σ0, xobs0)
Values just after time zero, (Lt0₊, Mt⁺0₊, μt0₊) are updated to time zero, the result being
written into (Lt0, Mt⁺0, μt0)
Version where B̃ and ã do not depend on try
BridgeLandmarks.lρtilde
— Method.Compute log tildeρ(0,x_0) for the k-th shape
BridgeLandmarks.plotshapes
— Method.plot initial and final shape, given by xobs0 and xobsT respectively
BridgeLandmarks.putpars!
— Method.update parameter values in GuidedProposal! Q, i.e.
new values are written into Q.target and Q.aux is updated accordingly
BridgeLandmarks.set_obsinfo
— Method.Make ObsInfo object
Three cases:
1) obs_atzero=true: this refers to the case of observing one landmark configuration at times 0 and T
2) obs_atzero=false & fixinitmomentato0=false: case of observing multiple shapes at time T,
both positions and momenta at time zero assumed unknown
3) obs_atzero=false & fixinitmomentato0=true: case of observing multiple shapes at time T,
positions at time zero assumed unknown, momenta at time 0 are fixed to zero
BridgeLandmarks.simguidedlm_llikelihood!
— Method.Simulate guided proposal and compute loglikelihood for one shape
Solve sde inplace and return loglikelihood (thereby avoiding 'double' computations)
BridgeLandmarks.simguidedlm_llikelihood!
— Method.Simulate guided proposal and compute loglikelihood (vector version, multiple shapes)
solve sde inplace and return loglikelihood (thereby avoiding 'double' computations)
BridgeLandmarks.slogρ!
— Method.Stochastic approximation for loglikelihood.
Simulate guided proposal and compute loglikelihood for starting point x0,
guided proposals defined by Q and Wiener increments in W.
Guided proposals are written into X.
Writes vector of loglikelihoods into llout.
Returns sum of loglikelihoods
BridgeLandmarks.update_guidrec!
— Method.Compute backward recursion for all shapes and write into field Q.guidrec
BridgeLandmarks.update_initialstate!
— Method.update initial state
X: current iterate of vector of sample paths
Xᵒ: vector of sample paths to write proposal into
W: current vector of Wiener increments
ll: current value of loglikelihood
x, xᵒ, ∇x, ∇xᵒ: allocated vectors for initial state and its gradient
sampler: either sgd (not checked yet) or mcmc
Q::GuidedProposal!
δ: vector with MALA stepsize for initial state positions (δ[1]) and initial state momenta (δ[2])
updatekernel: can be :mala_pos, :mala_mom, :rmmala_pos
BridgeLandmarks.update_pars!
— Method.For fixed Wiener increments and initial state, update parameters by random-walk-MH
BridgeLandmarks.update_path!
— Method.update bridges for all shapes using Crank-Nicholsen scheme with parameter ρ (only in case the method is mcmc)
Newly accepted bridges are written into (X,W), loglikelihood on each segment is written into vector ll
update_path!(X,Xᵒ,W,Wᵒ,Wnew,ll,x, Q, ρ, acc_pcn)
BridgeLandmarks.z
— Method.Define z(q) = < ∇K̄(q - δ,τ), λ >
Required for Stratonovich -> Ito correction in AHS-model
BridgeLandmarks.σp
— Method.Suppose one noise field nf
Returns diagonal matrix with noisefield for momentum at point location q (can be vector or Point)
BridgeLandmarks.σq
— Method.For AHS model compute total noise field on position experienced at a point x.
Useful for plotting purposes.
Example usage:
σq(Point(0.0, 0.0), nfs)
σq([0.0; 0.0], nfs)
BridgeLandmarks.σq
— Method.Suppose one noise field nf
Returns diagonal matrix with noisefield for position at point location q (can be vector or Point)
BridgeLandmarks.σt!
— Method.compute σ(t,x)' y, where y::State
the result is a vector of points that is written to out
BridgeLandmarks.σt!
— Method.compute σ(t,x)' y, where y::State
the result is a vector of points that is written to out
BridgeLandmarks.σtmul
— Method.Compute sigma(t,x)' * y where y is a state and sigma is the diffusion coefficient of landmarks returns a vector of points of length P.nfs
BridgeLandmarks.∇K̄
— Method.Needed for b! in case P is auxiliary process
BridgeLandmarks.∇kernel
— Method.Needed for b! in case P is auxiliary process
BridgeLandmarks.∇kernel
— Method.gradient of kernel in hamiltonian
BridgeLandmarks.∇z
— Method.Define ∇z(q) = ∇ < ∇K̄(q - δ,τ), λ >
Required for Stratonovich -> Ito correction in AHS-model