[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 pkgdown which renders math nicely. https://pkg.mitchelloharawild.com/distributional/reference/dist_weibull.html

In the following, let \(X\) be a Weibull random variable with shape parameter shape = \(k\) and scale parameter scale = \(\lambda\).

Support: \([0, \infty)\)

Mean:

$$ E(X) = \lambda \Gamma\left(1 + \frac{1}{k}\right) $$

where \(\Gamma\) is the gamma function.

Variance:

$$ \text{Var}(X) = \lambda^2 \left[\Gamma\left(1 + \frac{2}{k}\right) - \left(\Gamma\left(1 + \frac{1}{k}\right)\right)^2\right] $$

Probability density function (p.d.f):

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

Cumulative distribution function (c.d.f):

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

Moment generating function (m.g.f):

$$ E(e^{tX}) = \sum_{n=0}^\infty \frac{t^n\lambda^n}{n!} \Gamma\left(1+\frac{n}{k}\right) $$

Skewness:

$$ \gamma_1 = \frac{\mu^3 - 3\mu\sigma^2 - \mu^3}{\sigma^3} $$

where \(\mu = E(X)\), \(\sigma^2 = \text{Var}(X)\), and the third raw moment is

$$ \mu^3 = \lambda^3 \Gamma\left(1 + \frac{3}{k}\right) $$

Excess Kurtosis:

$$ \gamma_2 = \frac{\mu^4 - 4\gamma_1\mu\sigma^3 - 6\mu^2\sigma^2 - \mu^4}{\sigma^4} - 3 $$

where the fourth raw moment is

$$ \mu^4 = \lambda^4 \Gamma\left(1 + \frac{4}{k}\right) $$

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]  6.6187612  2.0000000  1.0719866 -0.2541096
kurtosis(dist)
#> [1] 84.7200000  6.0000000  1.3904036 -0.1197099

generate(dist, 10)
#> [[1]]
#>  [1]  0.24300251  0.07368777  8.70332599  0.27174577  0.26039773 21.11786621
#>  [7]  0.00890440  0.39948674  0.62019177  1.20235229
#> 
#> [[2]]
#>  [1] 0.47928404 1.03653786 0.26123419 0.72963258 0.40401964 0.08398588
#>  [7] 0.12324640 0.96297359 2.09512166 1.78926132
#> 
#> [[3]]
#>  [1] 0.5266070 0.1307273 0.9519558 1.3219925 0.3729735 0.6422722 0.3642916
#>  [8] 1.4749816 0.8450978 1.5336758
#> 
#> [[4]]
#>  [1] 1.0378031 1.1398232 1.4083118 0.9727260 0.9386462 0.6312763 1.0330125
#>  [8] 0.8161005 0.9843171 1.2000900
#> 

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