rndBeta#

Purpose#

Computes beta pseudo-random numbers with a choice of underlying random number generator.

Format#

x = rndBeta(r, c, a, b)#
{ x, newstate } = rndBeta(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, scalar or ExE conformable with r and c.

  • b (matrix or vector or scalar) – second shape argument for beta distribution, scalar or ExE conformable 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) – beta distributed random numbers.

  • newstate (Opaque vector) – the updated state.

Examples#

Example 1#

This example illustrates basic usage of rndBeta(), leaving the management of the random number state to GAUSS to handle internally.

num_rows = 100;
num_cols = 5;
a = 3;
b = 2;
x = rndBeta(num_rows, num_cols, a, b);

Example 2#

//Starting seed for random number generator
seed = 235235;

//If a 'seed' or 'state' vector is passed in,
//then a state vector will be returned
{ x, newstate } = rndBeta(100, 5, 3, 2, seed);

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\\ a > 0\\ b > 0\\\end{split}\end{aligned}\end{align} \]

r and c will be truncated to integers if necessary.

Technical Notes#

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

See also

Functions rndCreateState(), rndStateSkip()