pub struct Gaussian { /* private fields */ }Expand description
Gaussian (normal) distribution: X ~ N(mu, sigma^2) https://en.wikipedia.org/wiki/Normal_distribution
Implementations§
Trait Implementations§
Source§impl Distribution for Gaussian
impl Distribution for Gaussian
Source§fn cf(&self, t: f64) -> Complex<f64>
fn cf(&self, t: f64) -> Complex<f64>
Characteristic function of the Gaussian distribution.
§Examples
let gaussian = Gaussian::new(0.0, 1.0);
assert_approx_equal!(gaussian.cf(5.0).re, 3.7266532e-6, 1e-7);
assert_eq!(gaussian.cf(5.0).im, 0.0);Source§fn pdf(&self, x: f64) -> f64
fn pdf(&self, x: f64) -> f64
Probability density function of the Gaussian distribution.
§Examples
let gaussian = Gaussian::new(0.0, 1.0);
assert_approx_equal!(gaussian.pdf(1.0), 0.2419707, 1e-7);Source§fn pmf(&self, x: f64) -> f64
fn pmf(&self, x: f64) -> f64
Probability mass function for the Gaussian distribution (continuous) is not defined.
Using this method will call self.pdf() instead.
§Examples
let gaussian = Gaussian::new(0.0, 1.0);
assert_approx_equal!(gaussian.pmf(1.0), gaussian.pdf(1.0), 1e-7);Source§fn cdf(&self, x: f64) -> f64
fn cdf(&self, x: f64) -> f64
Cumulative distribution function of the Gaussian distribution.
§Examples
let gaussian = Gaussian::new(0.0, 1.0);
assert_approx_equal!(gaussian.cdf(1.0), 0.8413447, 1e-7);
assert_approx_equal!(gaussian.cdf(-1.0), 0.1586553, 1e-7);Source§fn inv_cdf(&self, p: f64) -> f64
fn inv_cdf(&self, p: f64) -> f64
Inverse distribution (quantile) function of the Gaussian distribution.
§Examples
let gaussian = Gaussian::new(0.0, 1.0);
assert_eq!(gaussian.inv_cdf(0.5), 0.0);
assert_approx_equal!(gaussian.inv_cdf(0.001), -3.090232306167813, f64::EPSILON);
assert_approx_equal!(gaussian.inv_cdf(0.997), 2.747781385444993, f64::EPSILON);Source§fn mean(&self) -> f64
fn mean(&self) -> f64
Returns the mean of the Gaussian distribution. The mean of the Gaussian distribution is equal to its median.
§Examples
let gaussian = Gaussian::new(0.0, 1.0);
assert_eq!(gaussian.mean(), 0.0);Source§fn median(&self) -> f64
fn median(&self) -> f64
Returns the median of the Gaussian distribution. The median of the Gaussian distribution is equal to its mean.
§Examples
let gaussian = Gaussian::new(0.0, 1.0);
assert_eq!(gaussian.median(), gaussian.mean());Source§fn mode(&self) -> f64
fn mode(&self) -> f64
Returns the mode of the Gaussian distribution. The mode of the Gaussian distribution is equal to its mean.
§Examples
let gaussian = Gaussian::new(0.0, 1.0);
assert_eq!(gaussian.mode(), gaussian.mean());Source§fn variance(&self) -> f64
fn variance(&self) -> f64
Returns the variance of the Gaussian distribution.
§Examples
let gaussian = Gaussian::new(0.0, 1.0);
assert_eq!(gaussian.variance(), 1.0);Source§fn skewness(&self) -> f64
fn skewness(&self) -> f64
Returns the skewness of the Gaussian distribution. The skewness of the Gaussian distribution is equal to 0.
§Examples
let gaussian = Gaussian::new(0.0, 1.0);
assert_eq!(gaussian.skewness(), 0.0);Source§fn kurtosis(&self) -> f64
fn kurtosis(&self) -> f64
Returns the kurtosis of the Gaussian distribution. The kurtosis of the Gaussian distribution is equal to 0.
§Examples
let gaussian = Gaussian::new(0.0, 1.0);
assert_eq!(gaussian.kurtosis(), 0.0);Source§fn entropy(&self) -> f64
fn entropy(&self) -> f64
Returns the entropy of the Gaussian distribution.
§Examples
let gaussian = Gaussian::new(0.0, 1.0);
assert_approx_equal!(gaussian.entropy(), 1.4189385, 1e-7);Source§fn mgf(&self, t: f64) -> f64
fn mgf(&self, t: f64) -> f64
Returns the moment generating function of the Gaussian distribution.
§Examples
let gaussian = Gaussian::new(0.0, 1.0);
assert_approx_equal!(gaussian.mgf(1.0), 1.6487213, 1e-7);Source§fn sample(&self, n: usize) -> Result<Vec<f64>, RustQuantError>
fn sample(&self, n: usize) -> Result<Vec<f64>, RustQuantError>
Generates a random sample from the Gaussian distribution using the Standard Normal Random Variates Generator.
§Examples
let gaussian = Gaussian::new(0.0, 1.0);
let sample = gaussian.sample(1000).expect("Gaussian sampled");
let mean = sample.iter().sum::<f64>() / sample.len() as f64;
assert_approx_equal!(mean, gaussian.mean(), 0.1);Auto Trait Implementations§
impl Freeze for Gaussian
impl RefUnwindSafe for Gaussian
impl Send for Gaussian
impl Sync for Gaussian
impl Unpin for Gaussian
impl UnwindSafe for Gaussian
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.