rndLCgam#
Purpose#
Computes Gamma pseudo-random numbers.
Note
This function is deprecated–use rndGamma()–but remains for backward compatibility.
Format#
- { x, newstate } = rndLCgam(r, c, alpha, state)#
- Parameters:
r (scalar) – number of rows of resulting matrix.
c (scalar) – number of columns of resulting matrix.
alpha (matrix, vector or scalar) – shape argument for gamma distribution, scalar or ExE conformable matrix with r and c.
state (scalar or vector) –
scalar case
3x1 vector case
[1]
the starting seed, uses the system clock if -1
[2]
the multiplicative constant
[3]
the additive constant
4x1 vector case
state = the state vector returned from a previous call to one of the
rndLCrandom number generators.
- Returns:
x (RxC matrix) – gamma distributed random numbers.
newstate (4x1 vector) –
[1]
the updated seed
[2]
the multiplicative constant
[3]
the additive constant
[4]
the original initialization seed
Examples#
// Generate a 3x2 matrix of gamma random numbers
// with shape alpha = 5, using a fixed seed for repeatable output
{ x, newstate } = rndLCgam(3, 2, 5, 12345);
print x;
The output is a 3x2 matrix of gamma-distributed values. The sample mean is approximately 5, consistent with the theoretical mean of alpha:
4.3270396 9.4093462
3.9689646 4.7393241
6.1082705 5.6436564
Technical Notes#
This function uses a linear congruential method, discussed in Kennedy, W.J. Jr., and J.E. Gentle, Statistical Computing, Marcel Dekker, Inc. 1980, pp. 136-147. Each seed is generated from the preceding seed using the formula
where % is the mod operator and where a is the multiplicative constant
and c is the additive constant.
Source#
randlc.src