Skip to main content

rejection_sampling

Function rejection_sampling 

Source
pub fn rejection_sampling<R, P, T, D>(
    target: T,
    proposal: P,
    proposal_density: D,
    m: f64,
    n: usize,
    rng: &mut R,
) -> Vec<f64>
where R: Rng + ?Sized, P: FnMut(&mut R) -> f64, T: Fn(f64) -> f64, D: Fn(f64) -> f64,
Expand description

Rejection sampling from a target distribution.

§Arguments

  • target - Target density function (unnormalized OK)
  • proposal - Proposal distribution sampler
  • proposal_density - Proposal density function
  • m - Constant such that target(x) <= M * proposal_density(x) for all x
  • n - Number of samples desired
  • rng - Random number generator

§Returns

Vector of accepted samples