pub struct NumericalInversePolynomial<'a> { /* private fields */ }Expand description
Numerical inversion of a distribution function from the density alone, by polynomial
interpolation of its inverse (SciPy’s NumericalInversePolynomial; Derflinger, Hörmann and
Leydold’s PINV). The interval is split until, on every piece, the polynomial of degree order
through order + 1 Chebyshev-Lobatto points of the piece, as a function of the probability
mass, inverts the integral of the density to within u_resolution of the whole mass at
three interior test points. The masses are integrals of the density (adaptive Gauss-Legendre),
so the density needs neither normalising nor a distribution function.
Implementations§
Source§impl<'a> NumericalInversePolynomial<'a>
impl<'a> NumericalInversePolynomial<'a>
Sourcepub fn new(
pdf: impl Fn(f64) -> f64 + 'a,
domain: (f64, f64),
center: f64,
order: usize,
u_resolution: f64,
) -> Result<Self, ErrorsJSL>
pub fn new( pdf: impl Fn(f64) -> f64 + 'a, domain: (f64, f64), center: f64, order: usize, u_resolution: f64, ) -> Result<Self, ErrorsJSL>
pdf (up to a constant) on domain; order is the degree of the polynomials (3 to 17,
SciPy’s default is 5); infinite ends are cut where the mass of what is left is below
u_resolution / 10 of the total. center is a point where the density is positive.
Sourcepub fn n_intervals(&self) -> usize
pub fn n_intervals(&self) -> usize
The number of intervals.
Sourcepub fn area(&self) -> f64
pub fn area(&self) -> f64
The integral of the density over the domain (the normalising constant).
Sourcepub fn cdf(&self, x: f64) -> f64
pub fn cdf(&self, x: f64) -> f64
The distribution function, by integrating the density from the start of the interval.
pub fn rvs_one<G: UniformGenerator>(&self, rng: &mut G) -> f64
pub fn rvs<G: UniformGenerator>(&self, n: usize, rng: &mut G) -> Vec<f64>
Sourcepub fn qrvs_sobol(&self, n: usize) -> Vec<f64>
pub fn qrvs_sobol(&self, n: usize) -> Vec<f64>
n variates by inversion of the (unscrambled, one-dimensional) Sobol sequence.