[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] 3.368640043 0.175724232 0.387322751 7.313551992 0.160882829 4.849844939
#>  [7] 3.163655153 0.006425101 0.000115997 0.123342023
#> 
#> [[2]]
#>  [1] 2.3237692 1.1522499 2.1482703 0.2734348 0.2743510 0.7019148 6.3922861
#>  [8] 2.5026346 0.9213308 0.3092500
#> 
#> [[3]]
#>  [1] 1.56029481 0.43312731 0.28788521 0.05317854 1.21701897 2.26973553
#>  [7] 0.85230140 0.83765229 0.47811894 1.22789884
#> 
#> [[4]]
#>  [1] 0.9349205 1.0068717 1.1555322 0.7661731 0.7778560 0.8951510 1.0999128
#>  [8] 0.7025759 1.0332005 0.9917596
#> 

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