pub fn rejection_sample_1d(
pdf: impl Fn(f64) -> f64,
lo: f64,
hi: f64,
envelope: f64,
n: usize,
rng: &mut Lcg,
) -> Vec<f64>Expand description
Draw n samples from an arbitrary 1-D PDF using rejection sampling.
pdf must be non-negative; envelope must satisfy pdf(x) ≤ envelope
for all x ∈ \[lo, hi).
§Arguments
pdf– target density functionlo,hi– support of the distributionenvelope– upper bound ofpdfover the supportn– number of samples to drawrng– LCG random source