Skip to main content

NumericalInverseHermite

Struct NumericalInverseHermite 

Source
pub struct NumericalInverseHermite<'a> { /* private fields */ }
Expand description

Numerical inversion of a distribution function by cubic Hermite interpolation of its inverse (SciPy’s NumericalInverseHermite; Hörmann and Leydold’s HINV). The interval (a, b) is split until, on every piece, the cubic that matches x and dx/du = 1/f(x) at both ends inverts F to within u_resolution: |F(x̂(u)) − u| ≤ ε at the middle of the piece. The pieces are then a table, and a variate or a quantile costs a search and a cubic.

Implementations§

Source§

impl<'a> NumericalInverseHermite<'a>

Source

pub fn new( cdf: impl Fn(f64) -> f64 + 'a, pdf: impl Fn(f64) -> f64 + 'a, domain: (f64, f64), center: f64, u_resolution: f64, ) -> Result<Self, ErrorsJSL>

cdf and pdf on domain (infinite ends are cut where the tail probability is below u_resolution / 10); center is a point inside the distribution (SciPy’s center).

Source

pub fn n_intervals(&self) -> usize

The number of intervals of the table.

Source

pub fn ppf(&self, u: f64) -> f64

The quantile function: x with F(x) = u, 0 ≤ u ≤ 1 (SciPy’s ppf).

Source

pub fn rvs_one<G: UniformGenerator>(&self, rng: &mut G) -> f64

Source

pub fn rvs<G: UniformGenerator>(&self, n: usize, rng: &mut G) -> Vec<f64>

Source

pub fn qrvs_sobol(&self, n: usize) -> Vec<f64>

n variates by inversion of the first points of the (unscrambled, one-dimensional) Sobol sequence (SciPy’s qrvs); their empirical distribution function converges to F like (log n)/n, not n^{-1/2}. The sequence starts at 0, which is skipped.

Source

pub fn u_error(&self, n: usize) -> f64

The largest |F(ppf(u)) − u| over n equally spaced values of u (SciPy’s u_error, which uses random ones).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.