Struct rusty_machine::stats::dist::gaussian::Gaussian [] [src]

pub struct Gaussian { /* fields omitted */ }

A Gaussian random variable.

This struct stores both the variance and the standard deviation. This is to minimize the computation required for computing the distribution functions and sampling.

It is most efficient to construct the struct using the from_std_dev constructor.

Methods

impl Gaussian
[src]

Creates a new Gaussian random variable from a given mean and variance.

Creates a new Gaussian random variable from a given mean and standard deviation.

Trait Implementations

impl Debug for Gaussian
[src]

Formats the value using the given formatter.

impl Clone for Gaussian
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Copy for Gaussian
[src]

impl Default for Gaussian
[src]

The default Gaussian random variable. This is the Standard Normal random variable.

The defaults are:

Returns the "default value" for a type. Read more

impl Distribution<f64> for Gaussian
[src]

The distribution of the gaussian random variable.

Accurately computes the PDF and log PDF. Estimates the CDF accurate only to 0.003.

The pdf of the normal distribution

Examples

use rusty_machine::stats::dist::Gaussian;
use rusty_machine::stats::dist::Distribution;
use rusty_machine::stats::dist::consts;

let gauss = Gaussian::default();

let lpdf_zero = gauss.pdf(0f64);

// The value should be very close to 1/sqrt(2 * pi)
assert!((lpdf_zero - (1f64/consts::SQRT_2_PI).abs()) < 1e-20);

The log pdf of the normal distribution.

Examples

use rusty_machine::stats::dist::Gaussian;
use rusty_machine::stats::dist::Distribution;
use rusty_machine::stats::dist::consts;

let gauss = Gaussian::default();

let lpdf_zero = gauss.logpdf(0f64);

// The value should be very close to -0.5*Ln(2 * pi)
assert!((lpdf_zero + 0.5*consts::LN_2_PI).abs() < 1e-20);

Rough estimate for the cdf of the gaussian distribution. Accurate to 0.003.

Examples

use rusty_machine::stats::dist::Gaussian;
use rusty_machine::stats::dist::Distribution;

let gauss = Gaussian::new(10f64, 5f64);
let cdf_mid = gauss.cdf(10f64);

assert!((0.5 - cdf_mid).abs() < 0.004);

A slightly more involved test:

use rusty_machine::stats::dist::Gaussian;
use rusty_machine::stats::dist::Distribution;

let gauss = Gaussian::new(10f64, 4f64);
let cdf = gauss.cdf(9f64);

assert!((0.5*(1f64 - 0.382924922548) - cdf).abs() < 0.004);

impl Sample<f64> for Gaussian
[src]

Generate a random value of Support, using rng as the source of randomness. Read more

impl IndependentSample<f64> for Gaussian
[src]

Generate a random value.