Next: read() Up: MacAnova Help File Previous: rational()   Contents

# rbin()

Usage:
 ```rbin(N, n, p), N positive integer, n scalar or vector of positive integers, p scalar or vector of probabilities. ```

Keywords: random numbers
```rbin(N, n, p) returns a vector of N independent binomial pseudo-random
variables with sample size n and probability p.  N must be a positive
integer.

n must be a positive integer scalar or a vector of N positive integers.
p must be a REAL scalar between 0 and 1 or a vector of N values between
0 and 1.  If n or p is a scalar, it is used for every element of the
result.  Otherwise, n[i] and/or p[i] are used for the i-th element of
the result.

If the random number generator has not been initialized by setseeds(),
setoptions() or previous use of rbin(), rnorm(), rpoi() or runi(), the
generator's "seeds" will be initialized automatically using the current
time and date, and their values will be printed out.

rbin() can be used to generate other random variables by using a random
vector as p and/or n.  For example,

Cmd> y <- rbin(N, n, invbeta(runi(N),a, b)) # a, b > 0

will generate a pseudo-random beta-binomial sample variables with
parameters n, a and b.  See the User's Guide for details.

The generation algorithm is adapted from Voratas Kachitvichyanukul and
Bruce Schmeiser, "Binomial random variate generation", Commun.ACM, 31
(1988) 216-222, published as Algorithm 678, Trans. Math. Software 15,
394-397.

See also topics setseeds(), getseeds(), setoptions(), rnorm(), rpoi(),
runi(), invbeta(), cumbin(), 'options'.
```

Gary Oehlert 2003-01-15