M = randg
M = randg(A)
M = randg(A, n)
M = randg(A, x1, x2, ... , xN)
M = randg(A, sz)
M = randg(A, x1, x2, ... , xN, classname)
| Parameter | Description |
|---|---|
| A | a real nonnegative value or array: the shape parameter(s). |
| n | a variable: n-by-n matrix will be generated. |
| x1, x2, ... , xN | x1-by-...-by-xN values |
| classname | a string: 'single' or 'double' |
| Parameter | Description |
|---|---|
| M | a matrix of random numbers. |
randg returns a matrix with gamma distributed random elements, with shape parameter A and unit scale.
A gamma sample of shape k has mean k and variance k; a shape of 1 gives the standard exponential distribution.
When only A is supplied, the result has the size of A and each element uses the matching shape. When a size is supplied, A must be a scalar used for every element.
Values are drawn with the Marsaglia and Tsang rejection method; the seed can be modified using rng.
rng('default');
randg
rng('default');
randg(2, 3)
rng('default');
M = randg(3, 1, 100000);
[mean(M), var(M)]
rng('default');
randg(2, 2, 2, 'single')
| Version | Description |
|---|---|
| 2.0.0 | initial version |