Struct statrs::distribution::LogNormal
[−]
[src]
pub struct LogNormal { /* fields omitted */ }
Implements the Log-normal distribution
Examples
use statrs::distribution::{LogNormal, Continuous}; use statrs::statistics::Mean; use statrs::prec; let n = LogNormal::new(0.0, 1.0).unwrap(); assert_eq!(n.mean(), (0.5f64).exp()); assert!(prec::almost_eq(n.pdf(1.0), 0.3989422804014326779399, 1e-16));
Methods
impl LogNormal
[src]
fn new(location: f64, scale: f64) -> Result<LogNormal>
Constructs a new log-normal distribution with a location of location
and a scale of scale
Errors
Returns an error if location
or scale
are NaN
.
Returns an error if scale <= 0.0
Examples
use statrs::distribution::LogNormal; let mut result = LogNormal::new(0.0, 1.0); assert!(result.is_ok()); result = LogNormal::new(0.0, 0.0); assert!(result.is_err());
Trait Implementations
impl Debug for LogNormal
[src]
impl Copy for LogNormal
[src]
impl Clone for LogNormal
[src]
fn clone(&self) -> LogNormal
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl PartialEq for LogNormal
[src]
fn eq(&self, __arg_0: &LogNormal) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &LogNormal) -> bool
This method tests for !=
.
impl Sample<f64> for LogNormal
[src]
fn sample<R: Rng>(&mut self, r: &mut R) -> f64
Generate a random sample from a log-normal
distribution using r
as the source of randomness.
Refer here for implementation details
impl IndependentSample<f64> for LogNormal
[src]
fn ind_sample<R: Rng>(&self, r: &mut R) -> f64
Generate a random independent sample from a log-normal
distribution using r
as the source of randomness.
Refer here for implementation details
impl Distribution<f64> for LogNormal
[src]
fn sample<R: Rng>(&self, r: &mut R) -> f64
Generate a random sample from the log-normal distribution
using r
as the source of randomness. Uses the Box-Muller
algorithm
Examples
use rand::StdRng; use statrs::distribution::{LogNormal, Distribution}; let mut r = rand::StdRng::new().unwrap(); let n = LogNormal::new(0.0, 1.0).unwrap(); print!("{}", n.sample::<StdRng>(&mut r));
impl Univariate<f64, f64> for LogNormal
[src]
impl Min<f64> for LogNormal
[src]
fn min(&self) -> f64
Returns the minimum value in the domain of the log-normal distribution representable by a double precision float
Formula
0
impl Max<f64> for LogNormal
[src]
fn max(&self) -> f64
Returns the maximum value in the domain of the log-normal distribution representable by a double precision float
Formula
INF
impl Mean<f64> for LogNormal
[src]
fn mean(&self) -> f64
Returns the mean of the log-normal distribution
Formula
e^(μ + σ^2 / 2)
where μ
is the location and σ
is the scale
impl Variance<f64> for LogNormal
[src]
fn variance(&self) -> f64
Returns the variance of the log-normal distribution
Formula
(e^(σ^2) - 1) * e^(2μ + σ^2)
where μ
is the location and σ
is the scale
fn std_dev(&self) -> f64
Returns the standard deviation of the log-normal distribution
Formula
sqrt((e^(σ^2) - 1) * e^(2μ + σ^2))
where μ
is the location and σ
is the scale
impl Entropy<f64> for LogNormal
[src]
fn entropy(&self) -> f64
Returns the entropy of the log-normal distribution
Formula
ln(σe^(μ + 1 / 2) * sqrt(2π))
where μ
is the location and σ
is the scale
impl Skewness<f64> for LogNormal
[src]
fn skewness(&self) -> f64
Returns the skewness of the log-normal distribution
Formula
(e^(σ^2) + 2) * sqrt(e^(σ^2) - 1)
where μ
is the location and σ
is the scale
impl Median<f64> for LogNormal
[src]
impl Mode<f64> for LogNormal
[src]
fn mode(&self) -> f64
Returns the mode of the log-normal distribution
Formula
e^(μ - σ^2)
where μ
is the location and σ
is the scale