dist_weibull(shape, scale)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) $$
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.928370050 2.674906444 1.680918261 0.004768824 0.961170852 0.835941765
#> [7] 0.226928746 0.517202662 0.056915774 0.674870662
#>
#> [[2]]
#> [1] 0.04083201 0.06891926 0.50315103 0.31533887 0.47090504 0.56988506
#> [7] 0.81898066 3.55491306 0.46783543 3.22227197
#>
#> [[3]]
#> [1] 0.9909610 2.9293565 1.3273241 0.9136715 0.7941316 0.5255087 0.8884508
#> [8] 0.6198367 0.8855897 0.6240273
#>
#> [[4]]
#> [1] 0.7704413 1.2415623 0.8778418 0.8741052 1.3566412 0.6236781 0.9123264
#> [8] 0.9533505 1.0185988 0.8632142
#>
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