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

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);

Implementations

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 Clone for Weibull[src]

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

(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

ln((k / λ) * (x / λ)^(k - 1) * e^(-(x / λ)^k))

where k is the shape and λ is the scale

impl Copy for Weibull[src]

impl Debug for Weibull[src]

impl Distribution<f64> for Weibull[src]

impl Entropy<f64> for Weibull[src]

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

Returns the entropy of the weibull distribution

Formula

γ(1 - 1 / k) + ln(λ / k) + 1

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

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

INF

impl Mean<f64> for Weibull[src]

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

Returns the mean of the weibull distribution

Formula

λΓ(1 + 1 / k)

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

impl Median<f64> for Weibull[src]

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

Returns the median of the weibull distribution

Formula

λ(ln(2))^(1 / 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

0

impl Mode<f64> for Weibull[src]

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

Returns the median of the weibull distribution

Formula

if k == 1 {
    0
} else {
    λ((k - 1) / k)^(1 / k)
}

where k is the shape and λ is the scale

impl PartialEq<Weibull> for Weibull[src]

impl Skewness<f64> for Weibull[src]

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

Returns the skewness of the weibull distribution

Formula

(Γ(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 StructuralPartialEq for Weibull[src]

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

1 - e^-((x/λ)^k)

where k is the shape and λ is the scale

impl Variance<f64> for Weibull[src]

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

Returns the variance of the weibull distribution

Formula

λ^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

sqrt(λ^2 * (Γ(1 + 2 / k) - Γ(1 + 1 / k)^2))

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

Auto Trait Implementations

impl RefUnwindSafe for Weibull

impl Send for Weibull

impl Sync for Weibull

impl Unpin for Weibull

impl UnwindSafe for Weibull

Blanket Implementations

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

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

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

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

impl<T, U> Into<U> for T where
    U: From<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<V, T> VZip<V> for T where
    V: MultiLane<T>, 
[src]