rndLogNorm#

Purpose#

Computes lognormal pseudo-random numbers with the choice of underlying random number generator.

Format#

x = rndLogNorm(r, c, mu, sigma)#
{ x, newstate } = rndLogNorm(r, c, mu, sigma, state)
Parameters:
  • r (scalar) – number of rows of resulting matrix.

  • c (scalar) – number of columns of resulting matrix.

  • mu (matrix or vector or scalar) – mean, scalar or ExE conformable matrix with r and c.

  • sigma (matrix or vector or scalar) – standard deviation, scalar or ExE conformable matrix with r and c.

  • state (scalar or opaque vector) –

    Optional argument.

    scalar case

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

    opaque vector case

    state = the state vector returned from a previous call to one of the rnd random number functions.

Returns:
  • x (RxC matrix) – lognormal distributed random numbers.

  • newstate (Opaque vector) – the updated state.

Remarks#

The properties of the pseudo-random numbers in x are:

\[ \begin{align}\begin{aligned}\begin{split}E(x) = exp(\mu - 0.5*\sigma^2)\\\end{split}\\Var(x) = (exp(\sigma^2) - 1) * exp(2*\mu + \sigma^2)\end{aligned}\end{align} \]

r and c will be truncated to integers if necessary.

Examples#

// Set seed for repeatable output
rndseed 12345;

// Generate a 3x2 matrix of lognormal
// random numbers with mu = 0, sigma = 1
x = rndLogNorm(3, 2, 0, 1);
print x;

After the code above, x is:

3.7047831       0.87171778
2.0433690       0.32325784
1.0245128       0.21482781

See also

Functions rndCreateState(), rndStateSkip()