[Stable]

Generalization of the gamma distribution. Often used in survival and time-to-event analyses.

dist_weibull(shape, scale)

Arguments

shape, scale

shape and scale parameters, the latter defaulting to 1.

Details

We recommend reading this documentation on https://pkg.mitchelloharawild.com/distributional/, where the math will render nicely.

In the following, let \(X\) be a Weibull random variable with success probability p = \(p\).

Support: \(R^+\) and zero.

Mean: \(\lambda \Gamma(1+1/k)\), where \(\Gamma\) is the gamma function.

Variance: \(\lambda [ \Gamma (1 + \frac{2}{k} ) - (\Gamma(1+ \frac{1}{k}))^2 ]\)

Probability density function (p.d.f):

$$ f(x) = \frac{k}{\lambda}(\frac{x}{\lambda})^{k-1}e^{-(x/\lambda)^k}, x \ge 0 $$

Cumulative distribution function (c.d.f):

$$F(x) = 1 - e^{-(x/\lambda)^k}, x \ge 0$$

Moment generating function (m.g.f):

$$\sum_{n=0}^\infty \frac{t^n\lambda^n}{n!} \Gamma(1+n/k), k \ge 1$$

See also

Examples

dist <- dist_weibull(shape = c(0.5, 1, 1.5, 5), scale = rep(1, 4))

dist
#> <distribution[4]>
#> [1] Weibull(0.5, 1) Weibull(1, 1)   Weibull(1.5, 1) Weibull(5, 1)  
mean(dist)
#> [1] 2.0000000 1.0000000 0.9027453 0.9181687
variance(dist)
#> [1] 20.00000000  1.00000000  0.37569028  0.04422998
skewness(dist)
#> [1]   5.0737409   0.0000000  -0.7764597 -38.1055455
kurtosis(dist)
#> [1]  87.48382  14.00000  12.28013 660.88795

generate(dist, 10)
#> [[1]]
#>  [1] 2.379189e-02 6.578803e+00 4.784346e-01 1.641560e-03 3.451740e-01
#>  [6] 1.651122e+01 1.438972e+00 2.889346e-02 8.164925e-05 2.601623e-01
#> 
#> [[2]]
#>  [1] 3.10336127 1.04162461 0.28426707 0.43815115 0.09065591 2.63418665
#>  [7] 0.02873696 0.20220772 1.38419654 1.25229448
#> 
#> [[3]]
#>  [1] 1.5547222 0.9609725 0.1402400 0.2583985 0.4953023 0.8584439 0.1783918
#>  [8] 1.1856970 2.3610753 1.1731253
#> 
#> [[4]]
#>  [1] 1.1072530 0.9036363 1.0914309 0.8526814 1.1083431 0.9608553 0.9912377
#>  [8] 0.8304103 1.1084421 0.9845964
#> 

density(dist, 2)
#> [1] 8.595475e-02 1.353353e-01 1.253822e-01 1.013133e-12
density(dist, 2, log = TRUE)
#> [1]  -2.453934  -2.000000  -2.076388 -27.617973

cdf(dist, 4)
#> [1] 0.8646647 0.9816844 0.9996645 1.0000000

quantile(dist, 0.7)
#> [1] 1.449551 1.203973 1.131734 1.037823