accept_reject

Function accept_reject 

Source
pub fn accept_reject(
    f_x: &impl ProbabilityDistribution,
    g_x: &impl ProbabilityDistribution,
    y_sample: &Array1<f64>,
    m: f64,
    uniform_sample: &Array1<f64>,
) -> Result<Array1<f64>, DigiFiError>
Expand description

Implements the Accept-Reject Method, a Monte Carlo technique for generating random samples from a probability distribution.

§Input

  • f_x: Target probability density function
  • g_x: Proposal probability density function
  • y_sample: Sample from the proposal distribution
  • m: Constant such that m*g(x) >= f(x) for all x
  • uniform_sample: Sample from a uniform distribution

§Output

  • Sample array generated from the target distribution

§Errors

  • Returns an error if the arrays produced by f_x and g_x are of different lengths.
  • Returns an error if arrays produced by f_x and g_x are different in length to y_sample.