Trait rv::traits::InverseCdf [−][src]
pub trait InverseCdf<X>: Rv<X> + Support<X> { fn invcdf(&self, p: f64) -> X; fn quantile(&self, p: f64) -> X { ... } fn interval(&self, p: f64) -> (X, X) { ... } }
Has an inverse-CDF / quantile function
Required Methods
fn invcdf(&self, p: f64) -> X
The value of the x
at the given probability in the CDF
Example
The CDF identity: p = CDF(x) => x = CDF-1(p)
use rv::dist::Gaussian; use rv::traits::Cdf; use rv::traits::InverseCdf; let g = Gaussian::standard(); let x: f64 = 1.2; let p: f64 = g.cdf(&x); let y: f64 = g.invcdf(p); // x and y should be about the same assert!((x - y).abs() < 1E-12);
Provided Methods
fn quantile(&self, p: f64) -> X
Alias for invcdf
fn interval(&self, p: f64) -> (X, X)
Interval containing p
proportion for the probability
Example
Confidence interval
use rv::dist::Gaussian; use rv::traits::InverseCdf; let g = Gaussian::new(100.0, 15.0).unwrap(); let ci: (f64, f64) = g.interval(0.68268949213708585); // one stddev assert!( (ci.0 - 85.0).abs() < 1E-12); assert!( (ci.1 - 115.0).abs() < 1E-12);
Implementors
impl InverseCdf<f64> for Cauchy
impl InverseCdf<f32> for Cauchy
impl InverseCdf<f64> for Exponential
impl InverseCdf<f32> for Exponential
impl InverseCdf<f32> for Gaussian
impl InverseCdf<f64> for Gaussian
impl InverseCdf<f32> for LogNormal
impl InverseCdf<f64> for LogNormal
impl InverseCdf<f64> for Uniform
impl InverseCdf<f32> for Uniform