Skip to main content

sample

Function sample 

Source
pub fn sample<const N: usize>(
    peak: &[f64; N],
    covariance: &[[f64; N]; N],
    draws: usize,
    seed: u64,
    log_target: impl FnMut(&[f64; N]) -> Option<f64>,
) -> Option<Posterior<N>>
Expand description

The posterior whose log density, up to a constant, is log_target, by draws weighted draws around peak with the Laplace covariance covariance.

log_target gives None where the posterior can’t be had; that draw gets no weight. Only the lower triangle of covariance is read. None overall if peak isn’t finite, covariance isn’t positive definite, draws is 0, or no draw has a finite weight. The same seed and a log_target that gives the same answer for the same point give the same answer, bit for bit, on one platform (the draws go through the platform’s ln, ln_1p, sqrt and exp).