Skip to main content

metropolis_hastings

Function metropolis_hastings 

Source
pub fn metropolis_hastings<F, U>(
    log_density: F,
    initial: Vec<f64>,
    options: MetropolisOptions,
    rng: &mut U,
) -> Result<MarkovChain, ErrorsJSL>
where F: Fn(&[f64]) -> f64, U: UniformGenerator,
Expand description

Samples from the density proportional to exp(log_density(x)) by random-walk Metropolis-Hastings: propose x' = x + σ ⊙ z with z standard normal, accept with probability min(1, p(x')/p(x)). Only an unnormalised log-density is needed; returning −∞ marks points outside the support.