Skip to main content

cdf

Function cdf 

Source
pub fn cdf(x: f64) -> f64
Expand description

Standard normal cumulative distribution function Φ(x) = P(Z ≤ x) for Z ~ N(0, 1).

Defined for every f64: NaN gives NaN, −∞ gives 0, +∞ gives 1. The relative error is below 1e-14 wherever the result is a normal f64 (x ≳ −37.5); beyond that the result underflows gradually to 0. The upper tail Q(x) = 1 − Φ(x) is computed accurately as cdf(−x); 1.0 − cdf(x) loses all precision once Φ(x) is close to 1.

§Examples

use moru_quant::math::normal;

// Upper tail at 10 standard deviations, through the symmetry Q(x) = Φ(−x).
let q = normal::cdf(-10.0);
assert!((q / 7.619_853_024_160_527e-24 - 1.0).abs() < 1e-14);