hmc: Hamiltonian Monte Carlo

Description Usage Arguments Value Examples

Description

Performs Hamiltonian Monte Carlo for a desired target function.

Usage

1
hmc(f, init, numit, L, eps, mass)

Arguments

f

Minus log-density function of interest.

init

Initial point for the algorithm.

numit

Number of iterations.

L

Leapfrog parameter: number of steps.

eps

Leapfrog parameter: size of each step.

mass

Mass vector.

Value

A list with the chain with the samples of interest, the values of the log-density calculated at each step and the acceptance rate.

Examples

1
2
f = function(x) -dnorm(x, 20, 10, log = TRUE)
hmc(f, 19, 1000, 16, 0.3, 0.1)

vsartor/rhmc documentation built on May 10, 2019, 8:27 a.m.