Main Content

gevrnd

Generalized extreme value random numbers

Description

r = gevrnd(k,sigma,mu) generates a random number drawn from the generalized extreme value (GEV) distribution with the specified shape parameter k, scale parameter sigma, and location parameter mu.

When k < 0, the GEV distribution is the type III extreme value distribution. When k > 0, the GEV distribution is the type II (Frechet) extreme value distribution. If w has a Weibull distribution, then –w has a type III extreme value distribution and 1/w has a type II extreme value distribution. In the limiting case as k approaches 0, the GEV distribution is the mirror image of the type I (Gumbel) extreme value distribution. For more information, see Generalized Extreme Value Distribution.

r = gevrnd(k,sigma,mu,sz1,...,szN) generates an array of random numbers, where sz1,...,szN indicates the size of each dimension.

example

r = gevrnd(k,sigma,mu,sz) generates an array of random numbers, where the vector sz specifies size(r).

Examples

collapse all

Generate 100 random numbers from a generalized extreme value distribution with the shape parameter k, scale parameter sigma, and location parameter mu.

rng(0,"twister") % For reproducibility
k = 0.5;
sigma = 4;
mu = 2;
r = gevrnd(k,sigma,mu,[100 1]);

Plot a histogram of the numbers.

histogram(r)

Figure contains an axes object. The axes object contains an object of type histogram.

Input Arguments

collapse all

Shape parameter, specified as a numeric scalar or array.

To generate random numbers from multiple distributions, specify one or more of the following input arguments using arrays: k, sigma, or mu. If one or more of the input arguments k, sigma, and mu are arrays, then the array sizes must be the same. In this case, gevrnd expands each scalar input into a constant array of the same size as the array inputs.

Scale parameter, specified as a positive scalar or an array of positive scalars.

To generate random numbers from multiple distributions, specify one or more of the following input arguments using arrays: k, sigma, or mu. If one or more of the input arguments k, sigma, and mu are arrays, then the array sizes must be the same. In this case, gevrnd expands each scalar input into a constant array of the same size as the array inputs.

Data Types: single | double

Location parameter, specified as a numeric scalar or array.

To generate random numbers from multiple distributions, specify one or more of the following input arguments using arrays: k, sigma, or mu. If one or more of the input arguments k, sigma, and mu are arrays, then the array sizes must be the same. In this case, gevrnd expands each scalar input into a constant array of the same size as the array inputs.

Data Types: single | double

Size of each dimension, specified as separate arguments of integers. For example, specifying 5,3,2 generates a 5-by-3-by-2 array of random numbers from the probability distribution.

If one or more of the input arguments k, sigma, and mu are arrays, then the specified dimensions sz1,...,szN must match the common dimensions of k, sigma, and mu after any necessary scalar expansion. The default values of sz1,...,szN are the common dimensions.

  • If you specify a single value sz1, then r is a square matrix of size sz1-by-sz1.

  • If the size of any dimension is 0 or negative, then r is an empty array.

  • Beyond the second dimension, gevrnd ignores trailing dimensions with a size of 1. For example, specifying 3,1,1,1 produces a 3-by-1 vector of random numbers.

Data Types: single | double

Size of each dimension, specified as a row vector of integers. For example, specifying [5,3,2] generates a 5-by-3-by-2 array of random numbers from the probability distribution.

If one or more of the input arguments k, sigma, and mu are arrays, then the specified dimensions sz must match the common dimensions of k, sigma, and mu after any necessary scalar expansion. The default values of sz are the common dimensions.

  • If you specify a single value sz1, then r is a square matrix of size sz1-by-sz1.

  • If the size of any dimension is 0 or negative, then r is an empty array.

  • Beyond the second dimension, gevrnd ignores trailing dimensions with a size of 1. For example, specifying [3,1,1,1] produces a 3-by-1 vector of random numbers.

Data Types: single | double

Output Arguments

collapse all

Random numbers, returned as a scalar value or an array of scalar values with the dimensions specified by sz1,...,szN or sz. Each element in r is the random number generated from the distribution specified by the corresponding elements in k, sigma, and mu.

Alternative Functionality

  • gevrnd is a function specific to the GEV distribution. Statistics and Machine Learning Toolbox™ also offers the generic function random, which supports various probability distributions. To use random, specify the probability distribution name and its parameters. Note that the distribution-specific function gevrnd is faster than the generic function random.

  • To generate random numbers interactively, use randtool, a user interface for random number generation.

References

[1] Embrechts, P., C. Klüppelberg, and T. Mikosch. Modelling Extremal Events for Insurance and Finance. New York: Springer, 1997.

[2] Kotz, S., and S. Nadarajah. Extreme Value Distributions: Theory and Applications. London: Imperial College Press, 2000.

Extended Capabilities

expand all

Version History

Introduced before R2006a