draw8multinom: simulates random draw from a multinomial

Description Usage Arguments Details Value Examples

Description

(dn) As far as I understood, there is no possibility to use the standard rmultinom in a parallel way to get the complete set of simulations with a unique call. This is why this function was created, if necessary it could be replaced by some C code one day.
There is two ways to use the function. (i) When is.null(levels) as a multivariate multinomials with different sizes, (ii) When levels is a non null character, then a categorical taking the levels values is returned.

Usage

1
draw8multinom(n, size, proba, levels=NULL)

Arguments

n

Number of draws to obtain.

size

Vector [n] of the sizes of the multinomials.

proba

Matrix [n,k] of the probabilities of the multinomials.

levels

When a categoric variable must be returned, levels provides its levels (since it is a factor).

Details

When !is.null(levels) size is forced to be a vector of ones.

Value

when is.null(levels) the integer matrix [n,k] of the draws is returned else a factor.

Examples

1
2
3
 rebastaba3k("RESET"); # for the sake of R checking
 draw8multinom(10, 1:10, matrix(1:10, 10, 3, byrow=TRUE));
 draw8multinom(10, rep(1, 10), matrix(1:10, 10, 3, byrow=TRUE), levels=LETTERS[1:3]);

rebastaba documentation built on May 2, 2019, 5:24 p.m.