rndMVn#

Purpose#

Computes multivariate normal random numbers given a covariance matrix.

Format#

r = rndMVn(num, mu, cov)#
{ r, newstate } = rndMVn(num, mu, cov, state)
Parameters:
  • num (Scalar) – number of random vectors to create.

  • mu (Nx1 matrix) – mean vector.

  • cov (NxN matrix) – covariance matrix

  • 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:
  • r (numxN matrix) – multivariate normal random numbers.

  • newstate (Opaque vector) – the updated state.

Examples#

// covariance matrix
cov = { 1 0.3,
      0.3   1 };

// mean for each column of 'cov'
mu = { 0, 0 };

x = rndMVn(100, mu, cov);

Remarks#

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

\[ \begin{align}\begin{aligned}\begin{split}E(x) = mu\\\end{split}\\Var(x) = cov\end{aligned}\end{align} \]

See also

Functions rndCreateState(), rndStateSkip()