rndKMp#
Purpose#
Computes Poisson pseudo-random numbers.
Format#
- { x, newstate } = rndKMp(r, c, lambda, state)#
- Parameters:
r (scalar) – number of rows of resulting matrix.
c (scalar) – number of columns of resulting matrix.
lambda (matrix or vector or scalar) – Shape argument for Poisson distribution, scalar or ExE conformable matrix with r and c.
state (scalar or 500x1 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
rndKMrandom number functions.
- Returns:
x (RxC matrix) – Poisson distributed random numbers.
newstate (500x1 vector) – the updated state.
Remarks#
The properties of the pseudo-random numbers in x are:
r and c will be truncated to integers if necessary.
Examples#
// Generate a 3x2 matrix of Poisson
// random numbers with lambda = 5
// using a fixed seed for repeatable output
{ x, newstate } = rndKMp(3, 2, 5, 12345);
print x;
The output is a 3x2 matrix of non-negative integers. The sample mean is approximately 5, consistent with the theoretical mean of lambda:
6.0000000 4.0000000
4.0000000 7.0000000
3.0000000 4.0000000
Technical Notes#
rndKMp() uses the recur-with-carry KISS+Monster algorithm described in the rndKMi() Technical Notes.
Source#
randkm.src