rndKMu

Purpose

Returns a matrix of uniform (pseudo) random variables and the state of the random number generator.

Format

{ y, newstate } = rndKMu(r, c, state)
Parameters:
  • r (scalar) – row dimension.
  • c (scalar) – column dimension.
  • state (scalar or vector) –

    scalar case

    state = starting seed value only. If -1, GAUSS computes the starting seed based on the system clock.

    500x1 vector case

    state = the state vector returned from a previous call to one of the rndKM random number functions.
Returns:
  • y (RxC matrix) – of uniform random numbers, \(0 \leq y < 1\).
  • newstate (500x1 vector) – the updated state.

Examples

This example generates two thousand vectors of uniform random numbers, each with one million elements. The state of the random number generator after each iteration is used as an input to the next generation of random numbers.

state = 13;
n = 2000;
k = 1000000;
c = 0;
submean = {};

do while c < n;
   { y, state } = rndKMu(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.

Technical Notes

rndKMu() uses the recur-with-carry KISS-Monster algorithm described in the rndKMi() Technical Notes. Random integer seeds from \(0\) to \(2^{32}-1\) are generated. Each integer is divided by \(2^{32}\) or \(2^{32}-1\).

See also

Functions rndKMn(), rndKMi()