Skip to main content

Module mcmc

Module mcmc 

Source
Expand description

Markov-Chain Monte Carlo (PRML ch 11) — random-walk Metropolis-Hastings over an arbitrary (unnormalized) log-density. This is the general inference engine the Bayesian methods lean on: give it log p(x) (up to a constant) and it returns samples from p. Kernel-class Divergent (the accept/reject branch).

The target need only be specified up to a normalizing constant — the Metropolis acceptance ratio exp(log p(x') − log p(x)) cancels it.

Structs§

McmcResult
Result of an MCMC run.

Functions§

metropolis_hastings
Random-walk Metropolis-Hastings. log_density(x) returns the target’s log-density (up to a constant) at a dim-vector; initial is the starting point; proposal_std the per-dimension Gaussian step; n_samples post-burn-in draws; burn_in discarded warm-up steps. Deterministic given seed.