The Gumbel Distribution
gumbel.RdDensity, distribution function, quantile function, random generation, and gradient of density of the extreme value (maximum and minimum) distributions. The Gumbel distribution is also known as the extreme value maximum distribution, the double-exponential distribution and the log-Weibull distribution.
Usage
dgumbel(x, location = 0, scale = 1, log = FALSE, max = TRUE)
pgumbel(q, location = 0, scale = 1, lower.tail = TRUE, max = TRUE)
qgumbel(p, location = 0, scale = 1, lower.tail = TRUE, max = TRUE)
rgumbel(n, location = 0, scale = 1, max = TRUE)
ggumbel(x, max = TRUE)Arguments
- x,q
numeric vector of quantiles.
- p
vector of probabilities.
- n
number of observations.
- location
numeric scalar.
- scale
numeric scalar.
- lower.tail
logical; if
TRUE(default), probabilities are \(P[X \leq x]\) otherwise, \(P[X > x]\).- log
logical; if
TRUE, probabilities p are given as log(p).- max
distribution for extreme maxima (default) or minima? The default corresponds to the standard right-skew Gumbel distribution.
Details
dgumbel, pgumbel and ggumbel are implemented in C
for speed and care is taken that 'correct' results are provided for
values of NA, NaN, Inf, -Inf or just
extremely small or large.
The distribution functions, densities and gradients are used in the
Newton-Raphson algorithms in fitting cumulative link models with
clm and cumulative link mixed models with
clmm.
Value
pgumbel gives the distribution function, dgumbel
gives the density, ggumbel gives the gradient of the
density, qgumbel is the quantile function, and
rgumbel generates random deviates.
Examples
## Illustrating the symmetry of the distribution functions:
pgumbel(5) == 1 - pgumbel(-5, max=FALSE) ## TRUE
#> [1] TRUE
dgumbel(5) == dgumbel(-5, max=FALSE) ## TRUE
#> [1] TRUE
ggumbel(5) == -ggumbel(-5, max=FALSE) ## TRUE
#> [1] TRUE
## More examples:
x <- -5:5
(pp <- pgumbel(x))
#> [1] 3.507389e-65 1.942338e-24 1.892179e-09 6.179790e-04 6.598804e-02
#> [6] 3.678794e-01 6.922006e-01 8.734230e-01 9.514320e-01 9.818511e-01
#> [11] 9.932847e-01
qgumbel(pp)
#> [1] -5 -4 -3 -2 -1 0 1 2 3 4 5
dgumbel(x)
#> [1] 5.205427e-63 1.060480e-22 3.800543e-08 4.566281e-03 1.793741e-01
#> [6] 3.678794e-01 2.546464e-01 1.182050e-01 4.736901e-02 1.798323e-02
#> [11] 6.692700e-03
ggumbel(x)
#> [1] 7.673485e-61 5.683979e-21 7.253539e-07 2.917423e-02 3.082152e-01
#> [6] 0.000000e+00 -1.609672e-01 -1.022077e-01 -4.501065e-02 -1.765386e-02
#> [11] -6.647605e-03
(ppp <- pgumbel(x, max=FALSE))
#> [1] 0.006715298 0.018148927 0.048568007 0.126576982 0.307799372 0.632120559
#> [7] 0.934011964 0.999382021 0.999999998 1.000000000 1.000000000
## Observe that probabilities close to 0 are more accurately determined than
## probabilities close to 1:
qgumbel(ppp, max=FALSE)
#> [1] -5 -4 -3 -2 -1 0 1 2 3 Inf Inf
dgumbel(x, max=FALSE)
#> [1] 6.692700e-03 1.798323e-02 4.736901e-02 1.182050e-01 2.546464e-01
#> [6] 3.678794e-01 1.793741e-01 4.566281e-03 3.800543e-08 1.060480e-22
#> [11] 5.205427e-63
ggumbel(x, max=FALSE)
#> [1] 6.647605e-03 1.765386e-02 4.501065e-02 1.022077e-01 1.609672e-01
#> [6] 0.000000e+00 -3.082152e-01 -2.917423e-02 -7.253539e-07 -5.683979e-21
#> [11] -7.673485e-61
## random deviates:
set.seed(1)
(r1 <- rgumbel(10))
#> [1] -0.28224819 0.01153789 0.58496474 2.34047303 -0.47066805 2.23351289
#> [7] 2.86621319 0.88114707 0.76907246 -1.02391536
set.seed(1)
r2 <- -rgumbel(10, max = FALSE)
all(r1 == r2) ## TRUE
#> [1] TRUE