Creates pseudo-random numbers with a chi-squared distribution, with an optional non-centrality parameter and a choice of underlying random number generator.


x = rndChiSquare(r, c, df[, s_ncp])
{ x, newstate } = rndChiSquare(r, c, df, s_ncp, state)
  • r (scalar) – number of rows of resulting matrix.
  • c (scalar) – number of columns of resulting matrix.
  • df (scalar) – degrees of freedom.
  • s_ncp (scalar) –

    Optional argument, non-centrality parameter.


    This is the square root of the noncentrality parameter that sometimes goes under the symbol \(\lambda\).

  • 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.

  • x (RxC matrix) – chi-square distributed random numbers.
  • newstate (Opaque vector) – the updated state.


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

\[ \begin{align}\begin{aligned}\begin{split}E(x) = k + \lambda\\\end{split}\\\sigma^2(x) = 2*k + 4*\lambda\end{aligned}\end{align} \]


\[ \begin{align}\begin{aligned}k = df\\\lambda = s\_ncp^2\end{aligned}\end{align} \]

Technical Notes

The default generator for rndChiSquare() is the SFMT Mersenne-Twister 19937. You can specify a different underlying random number generator with the function rndCreateState().

See also

Functions rndCreateState(), rndStateSkip()