Description Usage Arguments Details Value Examples
Hamiltonian Monte-Carlo, also called Hybrid Monte Carlo, is a sampling algorithm that uses Hamiltonian Dynamics to approximate a posterior distribution. Unlike MCMC and MC3, HMC uses not only the current position, but also a sense of momentum, to draw future samples. An introduction to HMC can be read here
1 | sampler_hmc(pdf, start, epsilon = 0.5, L = 10, iterations = 1024)
|
pdf |
pdf Probability Density Function of the target distribution.Takes 2 arguments: a vector with a position, and, optionally, a boolean determining whether to return the log density instead. |
start |
Vector. Starting point for the sampler |
epsilon |
Size of the leapfrog step |
L |
Number of leapfrog steps per iteration |
iterations |
Number of times the sampler runs |
This implementations assumes that the momentum is drawn from a normal distribution with mean 0 and identity covariance matrix (p ~ N (0, I) )
Chain with a history of visited places
1 2 3 | # pdfs can be made easily using the make_*_pdf helpers
pd_func <- make_distr6_pdf(distr6::MultivariateNormal$new(mean = c(2,5)))
hmc_results <- sampler_hmc(pd_func, start = c(0,0), epsilon = 1, L = 10, iterations=10)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.