Stable lifecycle

dist_weibull(shape, scale)

Arguments

shape

shape and scale parameters, the latter defaulting to 1.

scale

shape and scale parameters, the latter defaulting to 1.

Details

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

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] 0.127746018 0.137285426 0.201826375 0.006074920 0.280085710 0.014554020 #> [7] 0.002664719 0.270857749 2.636549987 0.923412008 #> #> [[2]] #> [1] 3.32629143 0.08673962 1.00657786 1.41905682 4.11040335 0.03187973 #> [7] 0.80629224 0.03627146 0.92868032 2.43562903 #> #> [[3]] #> [1] 0.6031822 0.9845420 0.4996292 1.5181450 0.7922070 1.1964124 0.2998157 #> [8] 0.9672187 2.1824700 0.1668926 #> #> [[4]] #> [1] 1.1637084 0.8489207 1.1858182 0.9336008 1.0370494 1.1260629 1.1363509 #> [8] 1.2028497 0.8005619 0.5990185 #>
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