Learn R Programming

vws (version 0.3.0)

Gumbel: Gumbel Distribution

Description

Functions for the Gumbel distribution with density $$ f(x \mid \mu, \sigma) = \frac{1}{\sigma} \exp\{ -\{ (x - \mu) / \sigma + e^{-(x - \mu) / \sigma} \} \} $$

Usage

r_gumbel(n, mu = 0, sigma = 1)

d_gumbel(x, mu = 0, sigma = 1, log = FALSE)

p_gumbel(q, mu = 0, sigma = 1, lower = TRUE, log = FALSE)

q_gumbel(p, mu = 0, sigma = 1, lower = TRUE, log = FALSE)

Value

d_gumbel computes the density, r_gumbel generates random deviates, p_gumbel computes the CDF, and q_gumbel computes quantiles. A vector is returned by each.

Arguments

n

Number of draws.

mu

Location parameter.

sigma

Scale parameter.

x

Vector; argument of density.

log

Logical; if TRUE, probabilities \(p\) are given as \(\log(p)\).

q

Vector; argument of quantile function.

lower

Logical; if TRUE (default), probabilities are \(P[X \leq x]\) otherwise, \(P[X > x]\).

p

Vector; argument of cumulative distribution function.

Examples

Run this code
mu = 1
sigma = 2
x = r_gumbel(100000, mu, sigma)
xx = seq(min(x), max(x), length.out = 100)

plot(density(x))
lines(xx, d_gumbel(xx, mu, sigma), lty = 2, col = "blue", lwd = 2)

plot(ecdf(x))
lines(xx, p_gumbel(xx, mu, sigma), lty = 2, col = "blue", lwd = 2)

pp = seq(0, 1, length.out = 102) |> head(-1) |> tail(-1)
qq = quantile(x, probs = pp)
plot(pp, qq)
lines(pp, q_gumbel(pp, mu, sigma), lty = 2, col = "blue", lwd = 2)

Run the code above in your browser using DataLab