draw.multinomial {MultiRNG}R Documentation

Pseudo-Random Number Generation under Multivariate Multinomial Distribution

Description

This function implements pseudo-random number generation for a multivariate multinomial distribution with pdf

f(xθ1,...,θd)=N!xj!j=1dθjxjf(x|\theta_{1},...,\theta_{d})=\frac{N!}{\prod x_{j}!}\prod_{j=1}^{d}\theta_{j}^{x_{j}}

for 0<θj<10<\theta_{j}<1, xj0x_{j}\geq 0, and j=1dxj=N\sum_{j=1}^{d}x_{j}=N, where θ1,...,θd\theta_{1},...,\theta_{d} are cell probabilities and NN is the size.

Usage

draw.multinomial(no.row,d,theta,N)

Arguments

no.row

Number of rows to generate.

d

Number of variables to generate.

theta

Vector of cell probabilities.

N

Sample Size. Must be at least 2.

Value

A no.row×dno.row \times d matrix of generated data.

Examples

theta.vec=c(0.3,0.3,0.25,0.15) ; N=4
mydata=draw.multinomial(no.row=1e5,d=4,theta=c(0.3,0.3,0.25,0.15),N=4)
apply(mydata,2,mean)-N*theta.vec

[Package MultiRNG version 1.2.4 Index]