Weibull Distribution

Table of contents


Density Function

The density function of the Weibull distribution:

\[f(x; k, \theta) = \frac{k}{\theta} \left( \frac{x}{\theta} \right)^{k-1} \exp \left( - \left( \frac{x}{\theta} \right)^k \right) \times \mathbf{1}[ x \geq 0 ]\]

Methods for scalar input, as well as for list input, are listed below.

Scalar Input

pystats.dweibull(x: float, alpha: float = 1.0, sigma: float = 1.0, log: bool = False) float

Density function of the Weibull distribution.

Example

>>> pystats.dweibull(1.0, 2.0, 3.0)
0.19885318151430437
Parameters
  • x (float) – A real-valued input.

  • alpha (float) – The shape parameter, a real-valued input.

  • sigma (float) – The scale parameter, a real-valued input.

  • log (bool) – Return the log-density or the true form.

Returns

The density function evaluated at x.

List Input

pystats.dweibull(x: List[float], alpha: float = 1.0, sigma: float = 1.0, log: bool = False) List[float]

Density function of the Weibull distribution.

Example

>>> pystats.dweibull([1.8, 0.7, 4.2], 2.0, 3.0)
[0.27907053042841234, 0.14731284075281734, 0.1314678595263087]
Parameters
  • x (List[float]) – A standard list input.

  • alpha (float) – The shape parameter, a real-valued input.

  • sigma (float) – The scale parameter, a real-valued input.

  • log (bool) – Return the log-density or the true form.

Returns

A list of density values corresponding to the elements of x.


Cumulative Distribution Function

The cumulative distribution function (CDF) of the Weibull distribution:

\[F(x; k, \theta) = \int_0^x f(z; k, \theta) dz = 1 - \exp \left( - \left( \frac{x}{\theta} \right)^k \times \mathbf{1}[x \geq 0] \right)\]

Methods for scalar input, as well as for list input, are listed below.

Scalar Input

pystats.pweibull(p: float, alpha: float = 1.0, sigma: float = 1.0, log: bool = False) float

Distribution function of the Weibull distribution.

Example

>>> pystats.pweibull(1.0, 2.0, 3.0)
0.1051606831856301
Parameters
  • p (float) – A real-valued input.

  • alpha (float) – The shape parameter, a real-valued input.

  • sigma (float) – The scale parameter, a real-valued input.

  • log (bool) – Return the log-density or the true form.

Returns

The cumulative distribution function evaluated at p.

List Input

pystats.pweibull(p: List[float], alpha: float = 1.0, sigma: float = 1.0, log: bool = False) List[float]

Distribution function of the Weibull distribution.

Example

>>> pystats.pweibull([1.8, 0.7, 4.2], 2.0, 3.0)
[0.302323673928969, 0.052988880874744404, 0.859141579078955]
Parameters
  • p (List[float]) – A standard list input.

  • alpha (float) – The shape parameter, a real-valued input.

  • sigma (float) – The scale parameter, a real-valued input.

  • log (bool) – Return the log-density or the true form.

Returns

A list of CDF values corresponding to the elements of p.


Quantile Function

The quantile function of the Weibull distribution:

\[q(p; k, \theta) = \lambda \times (- \ln(1 - p))^{1/k}\]

Methods for scalar input, as well as for list input, are listed below.

Scalar Input

pystats.qweibull(q: float, alpha: float = 1.0, sigma: float = 1.0) float

Quantile function of the Weibull distribution.

Example

>>> pystats.qweibull(0.5, 2.0, 3.0)
2.497663833473093
Parameters
  • q (float) – A real-valued input.

  • alpha (float) – The shape parameter, a real-valued input.

  • sigma (float) – The scale parameter, a real-valued input.

Returns

The quantile function evaluated at q.

List Input

pystats.qweibull(q: List[float], alpha: float = 1.0, sigma: float = 1.0) List[float]

Quantile function of the Weibull distribution.

Example

>>> pystats.qweibull([0.3, 0.5, 0.9], 2.0, 3.0)
[1.7916680762486648, 2.497663833473093, 4.552281388155439]
Parameters
  • q (List[float]) – A standard list input.

  • alpha (float) – The shape parameter, a real-valued input.

  • sigma (float) – The scale parameter, a real-valued input.

Returns

A list of quantiles values corresponding to the elements of q.


Random Sampling

Random sampling for the Weibull distribution is achieved via the inverse probability integral transform.

Scalar Output

pystats.rweibull(alpha: float = 1.0, sigma: float = 1.0) float

Random sampling function for the Weibull distribution.

Example

>>> pystats.rweibull(2.0, 3.0)
2.7238639049596536
Parameters
  • alpha (float) – The shape parameter, a real-valued input.

  • sigma (float) – The scale parameter, a real-valued input.

Returns

A pseudo-random draw from the Weibull distribution.

List Output

pystats.rweibull(n: int, alpha: float = 1.0, sigma: float = 1.0) List[float]

Random sampling function for the Weibull distribution.

Example

>>> pystats.rweibull(3, 2.0, 3.0)
[0.563858221268503, 1.10144762159266, 2.0484747373540606]
Parameters
  • n (int) – The number of output values.

  • alpha (float) – The shape parameter, a real-valued input.

  • sigma (float) – The scale parameter, a real-valued input.

Returns

A list of pseudo-random draws from the Weibull distribution.