Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is an old version of boost. Click here for the latest version's documentation home page.
PrevUpHomeNext
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:

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 it's 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

PrevUpHomeNext