Skip to main content

ContinuousCdf

Trait ContinuousCdf 

Source
pub trait ContinuousCdf {
    type Error;

    // Required methods
    fn cdf(&self, x: f64) -> f64;
    fn ccdf(&self, x: f64) -> f64;
    fn inverse_cdf(&self, p: f64) -> Result<f64, Self::Error>;
}
Expand description

Cumulative distribution function (CDF), complementary CDF, and inverse CDF for a continuous distribution.

§Example

use cdflib::Normal;
use cdflib::traits::ContinuousCdf;

let n = Normal::new(0.0, 1.0);
let p = n.cdf(0.0);       // 0.5
let x = n.inverse_cdf(p).unwrap(); // 0.0

Required Associated Types§

Source

type Error

Domain-specific error type returned by the inverse routines.

Required Methods§

Source

fn cdf(&self, x: f64) -> f64

Returns Pr[Xx].

Source

fn ccdf(&self, x: f64) -> f64

Returns Pr[X > x], the complementary CDF.

Implementations compute this independently of cdf rather than as 1 − cdf(x), so the small tail keeps its precision deep into the tails where the subtraction would lose digits to cancellation.

Source

fn inverse_cdf(&self, p: f64) -> Result<f64, Self::Error>

Returns the smallest x such that cdf(x) ≥ p, for p ∈ [0 . . 1].

At p = 0 returns the infimum of support, at p = 1 the supremum (either may be infinite).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§