deodorant.hmc
Basic HMC sampler implementation.
burn-in-and-thin
(burn-in-and-thin burn-in-proportion thin-rate samples)
Takes the output of a markov chain, removes a number of burn-in samples
and thins
Accpets: burn-in-proportion
thin-rate
samples
Retruns: samples(n-start:thin-rate:end)
where n-start = (int (* (count samples) burn-in-proportion))
collapse-identical-samples
(collapse-identical-samples samples)
Takes an unweighted collection of samples and returns the unique values
allong with a vector of the number of times they occured. Ordering
correspondings to the times of first apperance
hmc-chain
(hmc-chain u grad-u eps num-steps q-start)
Performs Hamiltonian Monte Carlo to construct a Markov Chain
Accepts functions u and grad-u with arguments [q], a parameter eps
that specifies the integration step size, and a parameter num-steps
that specifies the number of integration steps.
Returns a lazy sequence of samples q.
hmc-integrate
(hmc-integrate grad-u eps num-steps q p)
Preforms leap-frog integration of trajectory.
hmc-transition
(hmc-transition u grad-u eps num-steps q-start)
Performs one Hamiltonian Monte Carlo transition update.
Accepts functions u and grad-u with arguments [q], a parameter eps
that specifies the integration step size, and a parameter num-steps
that specifies the number of integration steps.
Returns a new sample q.
scale-vector
(scale-vector v factor)
Scale a vector by a scalar