Struct statrs::distribution::Normal [−][src]
pub struct Normal { /* fields omitted */ }
Implements the Normal distribution
Examples
use statrs::distribution::{Normal, Continuous}; use statrs::statistics::Mean; let n = Normal::new(0.0, 1.0).unwrap(); assert_eq!(n.mean(), 0.0); assert_eq!(n.pdf(1.0), 0.2419707245191433497978);
Methods
impl Normal
[src]
impl Normal
pub fn new(mean: f64, std_dev: f64) -> Result<Normal>
[src]
pub fn new(mean: f64, std_dev: f64) -> Result<Normal>
Constructs a new normal distribution with a mean of mean
and a standard deviation of std_dev
Errors
Returns an error if mean
or std_dev
are NaN
or if
std_dev <= 0.0
Examples
use statrs::distribution::Normal; let mut result = Normal::new(0.0, 1.0); assert!(result.is_ok()); result = Normal::new(0.0, 0.0); assert!(result.is_err());
Trait Implementations
impl Debug for Normal
[src]
impl Debug for Normal
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Copy for Normal
[src]
impl Copy for Normal
impl Clone for Normal
[src]
impl Clone for Normal
fn clone(&self) -> Normal
[src]
fn clone(&self) -> Normal
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl PartialEq for Normal
[src]
impl PartialEq for Normal
fn eq(&self, other: &Normal) -> bool
[src]
fn eq(&self, other: &Normal) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Normal) -> bool
[src]
fn ne(&self, other: &Normal) -> bool
This method tests for !=
.
impl Distribution<f64> for Normal
[src]
impl Distribution<f64> for Normal
fn sample<R: Rng + ?Sized>(&self, r: &mut R) -> f64
[src]
fn sample<R: Rng + ?Sized>(&self, r: &mut R) -> f64
Generate a random value of T
, using rng
as the source of randomness.
fn sample_iter<R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T> where
R: Rng,
[src]
fn sample_iter<R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T> where
R: Rng,
Create an iterator that generates random values of T
, using rng
as the source of randomness. Read more
impl Univariate<f64, f64> for Normal
[src]
impl Univariate<f64, f64> for Normal
fn cdf(&self, x: f64) -> f64
[src]
fn cdf(&self, x: f64) -> f64
Calculates the cumulative distribution function for the
normal distribution at x
Formula
(1 / 2) * (1 + erf((x - μ) / (σ * sqrt(2))))
where μ
is the mean, σ
is the standard deviation, and
erf
is the error function
impl Min<f64> for Normal
[src]
impl Min<f64> for Normal
fn min(&self) -> f64
[src]
fn min(&self) -> f64
Returns the minimum value in the domain of the normal distribution representable by a double precision float
Formula
-INF
impl Max<f64> for Normal
[src]
impl Max<f64> for Normal
fn max(&self) -> f64
[src]
fn max(&self) -> f64
Returns the maximum value in the domain of the normal distribution representable by a double precision float
Formula
INF
impl Mean<f64> for Normal
[src]
impl Mean<f64> for Normal
fn mean(&self) -> f64
[src]
fn mean(&self) -> f64
Returns the mean of the normal distribution
Remarks
This is the same mean used to construct the distribution
impl Variance<f64> for Normal
[src]
impl Variance<f64> for Normal
fn variance(&self) -> f64
[src]
fn variance(&self) -> f64
Returns the variance of the normal distribution
Formula
σ^2
where σ
is the standard deviation
fn std_dev(&self) -> f64
[src]
fn std_dev(&self) -> f64
Returns the standard deviation of the normal distribution
Remarks
This is the same standard deviation used to construct the distribution
impl Entropy<f64> for Normal
[src]
impl Entropy<f64> for Normal
fn entropy(&self) -> f64
[src]
fn entropy(&self) -> f64
Returns the entropy of the normal distribution
Formula
(1 / 2) * ln(2σ^2 * π * e)
where σ
is the standard deviation
impl Skewness<f64> for Normal
[src]
impl Skewness<f64> for Normal
impl Median<f64> for Normal
[src]
impl Median<f64> for Normal
fn median(&self) -> f64
[src]
fn median(&self) -> f64
Returns the median of the normal distribution
Formula
μ
where μ
is the mean
impl Mode<f64> for Normal
[src]
impl Mode<f64> for Normal
fn mode(&self) -> f64
[src]
fn mode(&self) -> f64
Returns the mode of the normal distribution
Formula
μ
where μ
is the mean
impl Continuous<f64, f64> for Normal
[src]
impl Continuous<f64, f64> for Normal
fn pdf(&self, x: f64) -> f64
[src]
fn pdf(&self, x: f64) -> f64
Calculates the probability density function for the normal distribution
at x
Formula
(1 / sqrt(2σ^2 * π)) * e^(-(x - μ)^2 / 2σ^2)
where μ
is the mean and σ
is the standard deviation
fn ln_pdf(&self, x: f64) -> f64
[src]
fn ln_pdf(&self, x: f64) -> f64
Calculates the log probability density function for the normal
distribution
at x
Formula
ln((1 / sqrt(2σ^2 * π)) * e^(-(x - μ)^2 / 2σ^2))
where μ
is the mean and σ
is the standard deviation