rndLCp#

Purpose#

Computes Poisson pseudo-random numbers.

Note

This function is deprecated–use rndPoisson()–but remains for backward compatibility.

Format#

{ x, newstate } = rndLCp(r, c, lambda, state)#
Parameters:
  • r (scalar) – row dimension.

  • c (scalar) – column dimension.

  • lambda (scalar) – mean parameter.

  • state (scalar or vector) –

    scalar case

    state = starting seed value only. System default values are used for the additive and multiplicative constants.

    The defaults are 1013904223, and 1664525, respectively. These may be changed with Format and Format.

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

    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:
  • x (RxC matrix) – Poisson 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 Poisson
// random numbers with lambda = 5
// using a fixed seed for repeatable output
{ x, newstate } = rndLCp(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:

1.0000000        1.0000000
5.0000000        6.0000000
8.0000000        2.0000000

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

\[new\_seed = (((a * seed) \% 2^{32})+ c) \% 2_{32}\]

where % is the mod operator and where a is the multiplicative constant and c is the additive constant.

Source#

randlc.src