pub struct Gaussian<T: Numeric + Real> {
    pub mean: T,
    pub variance: T,
}
Expand description

A Gaussian probability density function of a normally distributed random variable with expected value / mean μ, and variance σ2.

See: https://en.wikipedia.org/wiki/Gaussian_function

Fields

mean: T

The mean is the expected value of this gaussian.

variance: T

The variance is a measure of the spread of values around the mean, high variance means one standard deviation encompasses a larger spread of values from the mean.

Implementations

Creates a Gaussian approximating the mean and variance in the provided data.

Note that this will always be an approximation, if you generate some data according to some mean and variance then construct a Gaussian from the mean and variance of that generated data the approximated mean and variance is unlikely to be exactly the same as the parameters the data was generated with, though as the amout of data increases you can expect the approximation to be more close.

Computes g(x) for some x, the probability density of a normally distributed random variable x, or in other words how likely x is to be drawn from this normal distribution.

g(x) is largest for x equal to this distribution’s mean and g(x) will tend towards zero as x is further from this distribution’s mean, at a rate corresponding to this distribution’s variance.

Given a source of random variables in the uniformly distributed range [0, 1] inclusive, draws max_samples of independent random numbers according to this Gaussian distribution’s mean and variance using the Box-Muller transform:

https://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform

The source of random variables must provide at least as many values as max_samples if max_samples is even, and one more than max_samples if max_samples is odd. If fewer are provided None is returned.

As all randomness is provided to this method, this code is deterministic and will always compute the same samples given the same random source of numbers.

Example of generating and feeding random numbers

👎 Deprecated since 1.1.0:

renamed to probability

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.