rndLCu#
Purpose#
Returns a matrix of uniform (pseudo) random variables and the state of the random number generator. NOTE: This function is deprecated but remains for backward compatibility.
Format#
- { y, newstate } = rndLCu(r, c, state)#
- Parameters:
r (scalar) – row dimension.
c (scalar) – column dimension.
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
rndLC
random number generators.
- Returns:
y (RxC matrix) – uniform (\(0 < x < 1\)) random numbers.
newstate (4x1 vector) –
[1]
the updated seed
[2]
the multiplicative constant
[3]
the additive constant
[4]
the original initialization seed
Examples#
state = 13;
n = 2000000000;
k = 1000000;
c = 0;
submean = {};
do while c < n;
{ y,state } = rndLCu(k,1,state);
submean = submean | meanc(y);
c = c + k;
endo;
mean = meanc(submean);
print 0.5-mean;
Remarks#
r and c will be truncated to integers if necessary.
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. A number between 0 and 1 is created by
dividing new_seed by \(2\ :sup:`32`\).
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.