Main Content

pearsrnd

Pearson system random numbers

Description

r = pearsrnd(mu,sigma,skew,kurt) generates a random number drawn from the Pearson distribution with mean mu, standard deviation sigma, skewness skew, and kurtosis kurt.

Note

Because r is a random sample, its sample moments, especially the skewness and kurtosis, typically differ somewhat from the specified distribution moments.

pearsrnd uses the definition of kurtosis for which a normal distribution has a kurtosis of 3. Some definitions of kurtosis subtract 3, so that a normal distribution has a kurtosis of 0. The pearsrnd function does not use this convention.

example

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

example

r = pearsrnd(mu,sigma,skew,kurt,sz) generates an array of random numbers, where vector sz specifies size(r).

example

[r,type] = pearsrnd(___) returns the type of the specified distribution within the Pearson system using any of the input argument combinations in the previous syntaxes. type is a scalar integer from 0 to 7. Set sz to 0 to identify the distribution type without generating any random values.

example

[r,type,coefs] = pearsrnd(___) returns the coefficients coefs of the quadratic polynomial that defines the distribution via the differential equation

p'(x)p(x)=a+(xμ)b0+b1(xμ)+b2(xμ)2,

example

Examples

collapse all

Define the variables mu, sigma, skew, and kurt, which contain values for the mean, standard deviation, skewness, and kurtosis of a Pearson distribution, respectively. These parameters correspond to a type 0, standard normal distribution.

mu = 0;
sigma = 1;
skew = 0;
kurt = 3;
rng("twister") % For reproducibility
[r,type,coefs] = pearsrnd(mu,sigma,skew,kurt) % Equivalent to randn(1,1)
r = 
0.5377
type = 
0
coefs = 1×3

     1     0     0

Generate an array of random values from Pearson distributions with varying mean values. The software performs scalar expansion for sigma values implicitly.

mu = [-1,0,1];
sigma = 2;
skew = 1;
kurtosis = 3;
rng("twister") % for reproducibility
r = pearsrnd(mu,sigma,skew,kurtosis)
r = 1×3

   -0.0217   -1.5638    0.3768

The generated array has the same dimensions as mu (1-by-3).

Input Arguments

collapse all

Mean of the Pearson distribution, specified as a scalar or a numeric array.

To specify multiple distributions, specify either mu or sigma (or both) using arrays. If either mu or sigma is an array, then the array sizes must be the same. In this case, pearsrnd expands each scalar input into a constant array of the same size as the array inputs.

Example: [0 1 2; 0 1 2]

Data Types: single | double

Standard deviation of the Pearson distribution, specified as a positive scalar or a numeric array of positive values.

To specify multiple distributions, specify either mu or sigma (or both) using arrays. If either mu or sigma is an array, then the array sizes must be the same. In this case, pearsrnd expands each scalar input into a constant array of the same size as the array inputs.

Example: [1 1 1; 2 2 2]

Data Types: single | double

Skewness for the Pearson distribution, specified as a scalar. The value of skew must be less than sqrt(kurt - 1). For more information, see Skewness.

Example: 3

Data Types: single | double

Kurtosis for the Pearson distribution, specified as a scalar. The value of kurt must be greater than skew^2 + 1. For more information, see Kurtosis.

Example: 11

Data Types: single | double

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

If either mu or sigma is an array, then the specified dimensions sz1,...,szN must match the common dimensions of mu and sigma 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, pearsrnd ignores trailing dimensions with a size of 1. For example, specifying 3,1,1,1 produces a 3-by-1 vector of random numbers.

Example: 5,3,2

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 either mu or sigma is an array, then the specified dimensions sz must match the common dimensions of mu and sigma 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, pearsrnd ignores trailing dimensions with a size of 1. For example, specifying [3,1,1,1] produces a 3-by-1 vector of random numbers.

Example: [5,3,2]

Data Types: single | double

Output Arguments

collapse all

Normal 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 mu and sigma.

Type of Pearson distribution used to generate random numbers, returned as an integer from the interval [0 7] or NaN. If the distribution parameters are invalid, pearsrnd returns NaN.

This table describes the distribution corresponding to each Pearson distribution type.

Pearson Distribution TypeDescription
0Normal
14-parameter beta
2Symmetric 4-parameter beta
33-parameter gamma
4Distribution specific to the Pearson system
5Inverse 3-parameter gamma
6F location-scale
7Student's t location-scale

Quadratic polynomial coefficients, returned as a numeric 1-by-3 vector. The ith element of coefs is the coefficient bi in the differential equation

p'(x)p(x)=a+(xμ)b0+b1(xμ)+b2(xμ)2,

which defines the Pearson distribution probability density function (pdf) p(x).

References

[1] Johnson, N.L., S. Kotz, and N. Balakrishnan (1994) Continuous Univariate Distributions, Volume 1, Wiley-Interscience, Pg 15, Eqn 12.33.

Extended Capabilities

expand all

Version History

Introduced in R2006a