BiBlock
A composite unit that represents a block. It can be used for sampling on a block in a setting of smoothing or inference.
DiffusionMCMCTools.BiBlock — Typemutable struct BiBlock{L,TGP,TGPl,TW,TWn,TX}
b::Block{L,TGP,TGPl,TW,TWn,TX}
b°::Block{L,TGP,TGPl,TW,TWn,TX}
ρ::Float64
accpt_history::Vector{Bool}
endComposite unit that allows for sampling of a single block. It provides two Blocks: one proposal b°, one accepted b that can be used for smoothing or inference problems. ρ is a memory parameter of the preconditioned Crank-Nicolson scheme and accpt_history stores the history of accept/reject decisions (useful for MCMC).
function BiBlock(
sp::SamplingPair,
range::UnitRange{Int64},
ρ=0.0,
last_block=false,
ll_hist_len=0
)Base constructor.
There are many functions implemented for it.
Imputation of paths
DiffusionMCMCTools.draw_proposal_path! — Methoddraw_proposal_path!(bb::BiBlock)Sample a proposal path, compute log-likelihood along the way. Assumes bb.b.XX[1].x[1] is a starting point. Uses preconditioned Crank-Nicolson scheme with memory parameter set as bb.ρ.
Accept/reject decision in an MCMC setting
DiffusionMCMCTools.accept_reject_proposal_path! — Methodaccept_reject_proposal_path!(bb::BiBlock, mcmciter)Accept/reject decision of the Metropolis-Hastings algorithm for the step of path imputation.
Adjustments made after the accept-reject decision (regardless of what it was)
DiffusionMCMCTools.set_accepted! — Methodset_accepted!(bb::BiBlock, i::Int, v)Commit the accept/reject decision v to acceptance history of BiBlock b at the position i.
Adjustments to the containers in case of acceptance of proposals:
DiffusionMCMCTools.swap_paths! — Methodswap_paths!(bb::BiBlock)Swap XX and WW containers between proposal-acceptance pair.
DiffusionMCMCTools.swap_XX! — Methodswap_XX!(bb::BiBlock)Swap XX containers between proposal-acceptance pair.
DiffusionMCMCTools.swap_WW! — Methodswap_WW!(bb::BiBlock)Swap WW containers between proposal-acceptance pair.
DiffusionMCMCTools.swap_PP! — Methodswap_PP!(bb::BiBlock)Swap PP containers (including PP_last) between proposal-acceptance pair.
DiffusionMCMCTools.swap_ll! — Methodswap_ll!(bb::BiBlock)Swap ll containers between proposal-acceptance pair.
Setting up a block
GuidedProposals.set_obs! — MethodGP.set_obs!(bb::BiBlock)Freeze an artificial observation at the terminal point of the block. For a terminal block nothing is done.
GuidedProposals.recompute_guiding_term! — MethodGP.recompute_guiding_term!(bb::BiBlock)Recompute the guiding terms of both the proposal and the accepted laws.
DiffusionMCMCTools.find_W_for_X! — Methodfind_W_for_X!(bb::BiBlock)Find the Wiener process bb.b.WW that reconstructs path bb.b.XX under the accepted law bb.b.PP (possibly including bb.b.P_last).
Setting parameters
Missing docstring for DiffusionMCMCTools.set_proposal_law!( bb::DiffusionMCMCTools.BiBlock, θ°, pnames, critical_change=DiffusionMCMCTools.is_critical_update(bb, pnames), skip=0 ). Check Documenter's build log for details.
Utility
DiffusionMCMCTools.ll_of_accepted — Methodll_of_accepted(bb::BiBlock, i)Return the log-likelihood of the path that was accepted at the ith iteration.
DiffusionMCMCTools.accpt_rate — Methodaccpt_rate(bb::BiBlock, range)Compute the acceptance rate over the range of MCMC accept/reject history.
DiffusionMCMCTools.loglikhd! — Methodloglikhd!(b::BiBlock)Compute the log-likelihood for the accepted block, evaluated at a sampled path and store the result in an internal field ll.
DiffusionMCMCTools.loglikhd°! — Methodloglikhd°!(b::BiBlock)Compute the log-likelihood for the proposal block, evaluated at a sampled path and store the result in an internal field ll.
DiffusionMCMCTools.save_ll! — Methodsave_ll!(bb::BiBlock, i::Int)Commit the current proposal and accepted log-likelihood fields ll to history, at index i.
As you can see above, BiBlock is the fundamental building block that is used for creating inference and smoothing algorithms. However, as the complexity of these algorithms grow it is useful to use some macro structures that operate on or are defined for multiple BiBlocks. This is precisely what the remaining tools defined in this package are for. Otherwise put, they aim to facilitate writing snippets of code as above in a much more compact and convenient way.