powered by
Performs Hamiltonian Monte Carlo for a desired target function.
hmc(f, init, numit, L, eps, mass)
Minus log-density function of interest.
Initial point for the algorithm.
Number of iterations.
Leapfrog parameter: number of steps.
Leapfrog parameter: size of each step.
Mass vector.
A list with the chain with the samples of interest, the values of the log-density calculated at each step and the acceptance rate.
# NOT RUN { f = function(x) -dnorm(x, 20, 10, log = TRUE) hmc(f, 19, 1000, 16, 0.3, 0.1) # }
Run the code above in your browser using DataLab