rndKMbeta#

Purpose#

Computes beta pseudo-random numbers.

Format#

{ x, newstate } = rndKMbeta(r, c, a, b, state)#
Parameters:
  • r (scalar) – number of rows of resulting matrix.

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

  • a (matrix or vector or scalar) – First shape argument for beta distribution. ExE conformable with the row and column dimensions of the return matrix, r and c.

  • b (matrix or vector or scalar) – Second shape argument for beta distribution. ExE conformable with the row and column dimensions of the return matrix, 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 rndKM random number functions.

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

  • newstate (500x1 vector) – the updated state.

Remarks#

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

\[ \begin{align}\begin{aligned}\begin{split}E(x) = \frac{a}{a+b}\\\end{split}\\\begin{split}Var(x) = \frac{a*b}{(a+b+1)*(a+b^2)}\\\end{split}\\\begin{split}0 < x < 1\\\end{split}\\\begin{split}a > 0\\\end{split}\\b > 0\end{aligned}\end{align} \]

r and c will be truncated to integers if necessary.

Examples#

// Generate a 3x2 matrix of beta random numbers
// with shape parameters a = 2, b = 5
// using a fixed seed for repeatable output
{ x, newstate } = rndKMbeta(3, 2, 2, 5, 12345);
print x;

The output is a 3x2 matrix of beta-distributed values between 0 and 1. The sample mean is approximately 0.29, consistent with the theoretical mean of a/(a+b) = 2/7:

0.19288089       0.38057594
0.51686669       0.57522795
0.31832075       0.14046662

Technical Notes#

rndKMbeta() uses the recur-with-carry KISS+Monster algorithm described in the rndKMi() Technical Notes.

Source#

randkm.src