figaro.montecarlo module

figaro.montecarlo.MC_integral(p, q, n_draws=10000.0, error=True)[source]
Monte Carlo integration using FIGARO reconstructions.

∫p(x)q(x)dx ~ ∑p(x_i)/N with x_i ~ q(x)

p(x) must have a pdf() method and q(x) must have a rvs() method. Lists of p and q are also accepted.

Parameters:
  • p (list or class instance) – the probability density to evaluate. Must have a pdf() method.

  • q (list or class instance) – the probability density to sample from. Must have a rvs() method.

  • n_draws (int) – number of MC draws

  • error (bool) – whether to return the uncertainty on the integral value or not.

Returns:

integral value double: uncertainty (if error = True)

Return type:

double