Trait rustml::gaussian::GaussianFunctions [] [src]

pub trait GaussianFunctions<T> {
    fn mean(&self) -> T;
    fn var(&self) -> T;
    fn std(&self) -> T;
    fn pr(&self, x: T) -> T;
}

Required Methods

fn mean(&self) -> T

Returns the mean of the Gaussian distribution.

Examples

use rustml::gaussian::*;
use rustml::Normalization;

let a = vec![1.0f32, 2.0, 4.0, 3.0, 6.0, 5.0];
let g = a.gaussian(Normalization::N);
assert_eq!(g.mean(), 3.5);

fn var(&self) -> T

Returns the variance of the Gaussian distribution.

Examples

use rustml::gaussian::*;
use rustml::Normalization;

let a = vec![1.0f32, 2.0, 4.0, 3.0, 6.0, 5.0];
let g = a.gaussian(Normalization::N);
assert!(g.var() - 2.9167 <= 0.0001);

fn std(&self) -> T

Returns the standard deviation (the square root of the variance) of the Gaussian distribution.

Examples

use rustml::gaussian::*;
use rustml::Normalization;

let a = vec![1.0f32, 2.0, 4.0, 3.0, 6.0, 5.0];
let g = a.gaussian(Normalization::N);
assert!(g.std() - 1.7078 <= 0.0001);

fn pr(&self, x: T) -> T

Computes the probability density function for the given value.

Examples

use rustml::gaussian::*;
use rustml::Normalization;

let a = vec![1.0f32, 2.0, 4.0, 3.0, 6.0, 5.0];
let g = a.gaussian(Normalization::N);
assert!(g.pr(2.3) - 0.18250 <= 0.00001);

Implementors