Generates random data from the gamma probability distribution. There are two forms. |
||
Syntax |
RND = GammaRnd(a, b, Rows, Cols, Seed, State) RND = GammaRnd(a, b, Seed, State) |
|
Arguments |
Name |
Description |
a |
Shape parameter. A scalar, vector or matrix of positive values. See Comments. |
|
b |
Scale parameter. A scalar, vector or matrix of positive values. See Comments. |
|
Rows (optional) |
Number of output rows. A positive integer. Only valid when a and b are scalars. |
|
Cols (optional) |
Number of output columns. A positive integer. Only valid when a and b are scalars. |
|
Seed (optional) |
The seed to initialize the random number generator. An integer. See Comments below. |
|
State (optional) |
Set to "discard" if the state of the pseudo random number is not to be retained for future use. The default is "retain". |
|
Outputs |
Name |
Description |
RND |
Random numbers from the gamma distribution. Its dimensions are determined by the input arguments. See Comments below. |
|
Example 1 |
Generate two random numbers from the gamma distribution with (a, b) pairs of (2, 5) and (4, 3) respectively, with a random seed of 2003 |
|
Syntax |
||
rnd = GammaRnd([2,4],[5,3],2003) |
||
Results |
||
rnd = 7.0869 9.7002 |
||
Example 2 |
Generate a 1x4 vector of random numbers from the gamma distribution with a = 2, b = 5 and a random seed 2003. |
|
Syntax |
||
rnd = GammaRnd(2,5,1,4,2003) |
||
Results |
||
rnd = 7.0869 8.0835 9.0355 10.602 |
||
Comments |
The form of distribution function is such that the mean is a*b. a and b must be the same size. If the optional size inputs are omitted, the size of the output is solely determined by the size of the two inputs a and b. Each entry in the output uses the corresponding entries in the two inputs. If the optional size inputs are provided, both must be supplied. In that case, a and b must be scalars and the size of the output is determined by Rows and Cols. That is, the inputs a and b are used for each element of the output. The Seed can be any number. Using a seed allows a random sequence to be repeated. |
|
See Also: |