| Home | Libraries | People | FAQ | More

#### Weibull Distribution

    #include <boost/math/distributions/weibull.hpp>

    namespace boost{ namespace math{

    template <class RealType = double,
              class Policy   = policies::policy<> >
    class weibull_distribution;

    typedef weibull_distribution<> weibull;

    template <class RealType, class Policy>
    class weibull_distribution
    {
    public:
       typedef RealType value_type;
       typedef Policy   policy_type;
       // Construct:
       weibull_distribution(RealType shape, RealType scale = 1)
       // Accessors:
       RealType shape()const;
       RealType scale()const;
    };

    }} // namespaces

The Weibull distribution is a continuous distribution with the probability density function:

f(x; α, β) = (α/β) * (x / β)α - 1 * e-(x/β)α

For shape parameter α > 0, and scale parameter β > 0, and x > 0.

The Weibull distribution is often used in the field of failure analysis; in particular it can mimic distributions where the failure rate varies over time. If the failure rate is:

- constant over time, then α = 1, suggests that items are failing from random events.
- decreases over time, then α < 1, suggesting "infant mortality".
- increases over time, then α > 1, suggesting "wear out" - more likely to fail as time goes by.

The following graph illustrates how the PDF varies with the shape parameter α:

While this graph illustrates how the PDF varies with the scale parameter β:

##### Related distributions

When α = 3, the Weibull distribution appears similar to the normal distribution. When α = 1, the Weibull distribution reduces to the exponential distribution. The relationship of the types of extreme value distributions, of which the Weibull is but one, is discussed by Extreme Value Distributions, Theory and Applications Samuel Kotz & Saralees Nadarajah.

##### Member Functions

    weibull_distribution(RealType shape, RealType scale = 1);

Constructs a Weibull distribution with shape shape and scale scale.

Requires that the shape and scale parameters are both greater than zero, otherwise calls domain_error.

    RealType shape()const;

Returns the shape parameter of this distribution.

    RealType scale()const;

Returns the scale parameter of this distribution.

##### Non-member Accessors

All the usual non-member accessor functions that are generic to all distributions are supported: Cumulative Distribution Function, Probability Density Function, Quantile, Hazard Function, Cumulative Hazard Function, mean, median, mode, variance, standard deviation, skewness, kurtosis, kurtosis_excess, range and support.

The domain of the random variable is [0, ∞].

##### Accuracy

The Weibull distribution is implemented in terms of the standard library `log` and `exp` functions plus expm1 and log1p and as such should have very low error rates.

##### Implementation

In the following table α is the shape parameter of the distribution, β is its scale parameter, x is the random variate, p is the probability and q = 1-p.

Function | Implementation Notes
--- | ---
pdf | Using the relation: pdf = αβ-α xα - 1 e-(x/beta)alpha
cdf | Using the relation: p = -expm1(-(x/β)α)
cdf complement | Using the relation: q = e-(x/β)α
quantile | Using the relation: x = β * (-log1p(-p))1/α
quantile from the complement | Using the relation: x = β * (-log(q))1/α
mean | β * Γ(1 + 1/α)
variance | β2(Γ(1 + 2/α) - Γ2(1 + 1/α))
mode | β((α - 1) / α)1/α
skewness | Refer to Weisstein, Eric W. "Weibull Distribution." From MathWorld--A Wolfram Web Resource.
kurtosis | Refer to Weisstein, Eric W. "Weibull Distribution." From MathWorld--A Wolfram Web Resource.
kurtosis excess | Refer to Weisstein, Eric W. "Weibull Distribution." From MathWorld--A Wolfram Web Resource.

##### References

- http://en.wikipedia.org/wiki/Weibull_distribution
- Weisstein, Eric W. "Weibull Distribution." From MathWorld--A Wolfram Web Resource.
- Weibull in NIST Exploratory Data Analysis