[−][src]Struct easy_ml::distributions::Gaussian
A Gaussian probability density function of a normally distributed random variable with expected value / mean μ, and variance σ2.
Fields
mean: TThe mean is the expected value of this gaussian.
variance: TThe 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.
Methods
impl<T: Numeric + Real> Gaussian<T>[src]
impl<T: Numeric + Real> Gaussian<T> where
&'a T: NumericRef<T> + RealRef<T>, [src]
&'a T: NumericRef<T> + RealRef<T>,
pub fn map(&self, x: &T) -> T[src]
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.
pub fn draw<I>(&self, source: &mut I, max_samples: usize) -> Option<Vec<T>> where
I: Iterator<Item = T>, [src]
I: Iterator<Item = T>,
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.
Auto Trait Implementations
impl<T> RefUnwindSafe for Gaussian<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Gaussian<T> where
T: Send,
T: Send,
impl<T> Sync for Gaussian<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Gaussian<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Gaussian<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,