rndKMnb¶
Purpose¶
Computes negative binomial pseudo-random numbers.
Format¶
-
{ x, newstate } =
rndKMnb(r, c, k, p, state)¶ Parameters: - r (scalar) – number of rows of resulting matrix.
- c (scalar) – number of columns of resulting matrix.
- k (matrix or vector or scalar) – “event” argument for negative binomial distribution, scalar or ExE conformable matrix with r and c.
- p (matrix or vector or scalar) – “probability” argument for negative binomial distribution, scalar or ExE conformable matrix with 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 therndKMrandom number functions.
Returns: - x (RxC matrix) – negative binomial distributed random numbers.
- newstate (500x1 vector) – the updated state.
Remarks¶
The properties of the pseudo-random numbers in x are:
\[ \begin{align}\begin{aligned}E(x) = \frac{k * p}{1 - p}\\\begin{split}Var(x) = \frac{k * p}{(1 - p)^2}\\
x = 0, 1,....k > 0\\
0 < p < 1\\\end{split}\end{aligned}\end{align} \]
r and c will be truncated to integers if necessary.
Technical Notes¶
rndKMnb() uses the recur-with-carry KISS+Monster algorithm described in the rndKMi() Technical Notes.
Source¶
randkm.src