Description Usage Arguments Value Examples
View source: R/draw.multinomial.R
This function implements pseudo-random number generation for a multivariate multinomial distribution with pdf
f(x|θ_{1},...,θ_{d})=\frac{N!}{∏ x_{j}!}∏_{j=1}^{d}θ_{j}^{x_{j}}
for 0<θ_{j}<1, x_{j}≥q 0, and ∑_{j=1}^{d}x_{j}=N, where θ_{1},...,θ_{d} are cell probabilities and N is the size.
1 | draw.multinomial(no.row,d,theta,N)
|
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. |
A no.row \times d matrix of generated data.
1 2 3 | 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
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.