[][src]Struct statrs::distribution::Weibull

pub struct Weibull { /* fields omitted */ }

Implements the Weibull distribution

Examples

use statrs::distribution::{Weibull, Continuous};
use statrs::statistics::Mean;
use statrs::prec;

let n = Weibull::new(10.0, 1.0).unwrap();
assert!(prec::almost_eq(n.mean(),
0.95135076986687318362924871772654021925505786260884, 1e-15));
assert_eq!(n.pdf(1.0), 3.6787944117144232159552377016146086744581113103177);

Methods

impl Weibull[src]

pub fn new(shape: f64, scale: f64) -> Result<Weibull>[src]

Constructs a new weibull distribution with a shape (k) of shape and a scale (λ) of scale

Errors

Returns an error if shape or scale are NaN. Returns an error if shape <= 0.0 or scale <= 0.0

Examples

use statrs::distribution::Weibull;

let mut result = Weibull::new(10.0, 1.0);
assert!(result.is_ok());

result = Weibull::new(0.0, 0.0);
assert!(result.is_err());

pub fn shape(&self) -> f64[src]

Returns the shape of the weibull distribution

Examples

use statrs::distribution::Weibull;

let n = Weibull::new(10.0, 1.0).unwrap();
assert_eq!(n.shape(), 10.0);

pub fn scale(&self) -> f64[src]

Returns the scale of the weibull distribution

Examples

use statrs::distribution::Weibull;

let n = Weibull::new(10.0, 1.0).unwrap();
assert_eq!(n.scale(), 1.0);

Trait Implementations

impl Univariate<f64, f64> for Weibull[src]

fn cdf(&self, x: f64) -> f64[src]

Calculates the cumulative distribution function for the weibull distribution at x

Formula

This example is not tested
1 - e^-((x/λ)^k)

where k is the shape and λ is the scale

impl Continuous<f64, f64> for Weibull[src]

fn pdf(&self, x: f64) -> f64[src]

Calculates the probability density function for the weibull distribution at x

Formula

This example is not tested
(k / λ) * (x / λ)^(k - 1) * e^(-(x / λ)^k)

where k is the shape and λ is the scale

fn ln_pdf(&self, x: f64) -> f64[src]

Calculates the log probability density function for the weibull distribution at x

Formula

This example is not tested
ln((k / λ) * (x / λ)^(k - 1) * e^(-(x / λ)^k))

where k is the shape and λ is the scale

impl Min<f64> for Weibull[src]

fn min(&self) -> f64[src]

Returns the minimum value in the domain of the weibull distribution representable by a double precision float

Formula

This example is not tested
0

impl Max<f64> for Weibull[src]

fn max(&self) -> f64[src]

Returns the maximum value in the domain of the weibull distribution representable by a double precision float

Formula

This example is not tested
INF

impl Mean<f64> for Weibull[src]

fn mean(&self) -> f64[src]

Returns the mean of the weibull distribution

Formula

This example is not tested
λΓ(1 + 1 / k)

where k is the shape, λ is the scale, and Γ is the gamma function

impl Variance<f64> for Weibull[src]

fn variance(&self) -> f64[src]

Returns the variance of the weibull distribution

Formula

This example is not tested
λ^2 * (Γ(1 + 2 / k) - Γ(1 + 1 / k)^2)

where k is the shape, λ is the scale, and Γ is the gamma function

fn std_dev(&self) -> f64[src]

Returns the standard deviation of the weibull distribution

Formula

This example is not tested
sqrt(λ^2 * (Γ(1 + 2 / k) - Γ(1 + 1 / k)^2))

where k is the shape, λ is the scale, and Γ is the gamma function

impl Entropy<f64> for Weibull[src]

fn entropy(&self) -> f64[src]

Returns the entropy of the weibull distribution

Formula

This example is not tested
γ(1 - 1 / k) + ln(λ / k) + 1

where k is the shape, λ is the scale, and γ is the Euler-Mascheroni constant

impl Skewness<f64> for Weibull[src]

fn skewness(&self) -> f64[src]

Returns the skewness of the weibull distribution

Formula

This example is not tested
(Γ(1 + 3 / k) * λ^3 - 3μσ^2 - μ^3) / σ^3

where k is the shape, λ is the scale, and Γ is the gamma function, μ is the mean of the distribution. and σ the standard deviation of the distribution

impl Median<f64> for Weibull[src]

fn median(&self) -> f64[src]

Returns the median of the weibull distribution

Formula

This example is not tested
λ(ln(2))^(1 / k)

where k is the shape and λ is the scale

impl Mode<f64> for Weibull[src]

fn mode(&self) -> f64[src]

Returns the median of the weibull distribution

Formula

This example is not tested
if k == 1 {
    0
} else {
    λ((k - 1) / k)^(1 / k)
}

where k is the shape and λ is the scale

impl Copy for Weibull[src]

impl Clone for Weibull[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl PartialEq<Weibull> for Weibull[src]

impl Debug for Weibull[src]

impl Distribution<f64> for Weibull[src]

fn sample_iter<R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T> where
    R: Rng
[src]

Create an iterator that generates random values of T, using rng as the source of randomness. Read more

Auto Trait Implementations

impl Send for Weibull

impl Sync for Weibull

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]