# GEV: Create a Generalised Extreme Value (GEV) distribution In alexpghayes/distributions: Probability Distributions as S3 Objects

## Description

The GEV distribution arises from the Extremal Types Theorem, which is rather like the Central Limit Theorem (see `\link{Normal}`) but it relates to the maximum of n i.i.d. random variables rather than to the sum. If, after a suitable linear rescaling, the distribution of this maximum tends to a non-degenerate limit as n tends to infinity then this limit must be a GEV distribution. The requirement that the variables are independent can be relaxed substantially. Therefore, the GEV distribution is often used to model the maximum of a large number of random variables.

## Usage

 `1` ```GEV(mu = 0, sigma = 1, xi = 0) ```

## Arguments

 `mu` The location parameter, written μ in textbooks. `mu` can be any real number. Defaults to `0`. `sigma` The scale parameter, written σ in textbooks. `sigma` can be any positive number. Defaults to `1`. `xi` The shape parameter, written ξ in textbooks. `xi` can be any real number. Defaults to `0`, which corresponds to a Gumbel distribution.

## Details

We recommend reading this documentation on https://alexpghayes.github.io/distributions3, where the math will render with additional detail and much greater clarity.

In the following, let X be a GEV random variable with location parameter `mu` = μ, scale parameter `sigma` = σ and shape parameter `xi` = ξ.

Support: (-∞, μ - σ / ξ) for ξ < 0; (μ - σ / ξ, ∞) for ξ > 0; and R, the set of all real numbers, for ξ = 0.

Mean: μ + σ[Γ(1 - ξ) - 1]/ξ for ξ < 1, ξ != 0; μ + σγ for ξ = 0, where γ is Euler's constant, approximately equal to 0.57722; undefined otherwise.

Median: μ + σ[(ln 2)^(-ξ) - 1] / ξ for ξ != 0; μ - σ ln(ln 2) for ξ = 0.

Variance: σ^2 [Γ(1 - 2 ξ) - Γ(1 - ξ)^2] / ξ^2 for ξ < 1 / 2, ξ != 0; σ^2 π^2 / 6 for ξ = 0; undefined otherwise.

Probability density function (p.d.f):

If ξ is not equal to 0 then

f(x) = (1 / σ) [1 + ξ (x - μ) / σ] ^ {-(1 + 1/ξ)} exp{ -[1 + ξ (x - μ) / σ] ^ (-1/ξ)}

for 1 + ξ (x - μ) / σ > 0. The p.d.f. is 0 outside the support.

In the ξ = 0 (Gumbel) special case

f(x) = (1 / σ) exp[-(x - μ) / σ] exp{-exp[-(x - μ) / σ]}

for x in R, the set of all real numbers.

Cumulative distribution function (c.d.f):

If ξ is not equal to 0 then

F(x) = exp{ -[1 + ξ (x - μ) / σ] ^ (-1/ξ)}

for 1 + ξ (x - μ) / σ > 0. The c.d.f. is 0 below the support and 1 above the support.

In the ξ = 0 (Gumbel) special case

F(x) = exp{ - exp[-(x - μ) / σ]}

for x in R, the set of all real numbers.

## Value

A `GEV` object.

Other continuous distributions: `Beta()`, `Cauchy()`, `ChiSquare()`, `Exponential()`, `Frechet()`, `GP()`, `Gamma()`, `Gumbel()`, `LogNormal()`, `Logistic()`, `Normal()`, `RevWeibull()`, `StudentsT()`, `Tukey()`, `Uniform()`, `Weibull()`
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15``` ```set.seed(27) X <- GEV(1, 2, 0.1) X random(X, 10) pdf(X, 0.7) log_pdf(X, 0.7) cdf(X, 0.7) quantile(X, 0.7) cdf(X, quantile(X, 0.7)) quantile(X, cdf(X, 0.7)) ```