Trait rv::traits::ContinuousDistr[][src]

pub trait ContinuousDistr<X>: Rv<X> + Support<X> {
    fn pdf(&self, x: &X) -> f64 { ... }
fn ln_pdf(&self, x: &X) -> f64 { ... } }

Is a continuous probability distributions

This trait uses the Rv<X> and Support<X> implementations to implement itself.

Provided Methods

The value of the Probability Density Function (PDF) at x

Panics

If x is not in the support.

Example

Compute the Gaussian PDF, f(x)

use rv::dist::Gaussian;
use rv::traits::ContinuousDistr;

let g = Gaussian::standard();

let f_mean = g.pdf(&0.0_f64);
let f_low = g.pdf(&-1.0_f64);
let f_high = g.pdf(&1.0_f64);

assert!(f_mean > f_low);
assert!(f_mean > f_high);
assert!((f_low - f_high).abs() < 1E-12);

The value of the log Probability Density Function (PDF) at x

Panics

If x is not in the support.

Example

Compute the natural logarithm of the Gaussian PDF, ln(f(x))

use rv::dist::Gaussian;
use rv::traits::ContinuousDistr;

let g = Gaussian::standard();

let lnf_mean = g.ln_pdf(&0.0_f64);
let lnf_low = g.ln_pdf(&-1.0_f64);
let lnf_high = g.ln_pdf(&1.0_f64);

assert!(lnf_mean > lnf_low);
assert!(lnf_mean > lnf_high);
assert!((lnf_low - lnf_high).abs() < 1E-12);

Implementors