rmultinomial: Generate random samples from multinomial distributions

Description Usage Arguments Value Author(s) Examples

Description

rmultinomial: Generate random samples from multinomial distributions, where both n and p may vary among distributions

rmultz2: fixed p case

Usage

1
2
rmultinomial(n, p, rows=max(c(length(n), nrow(p))))
rmultz2(n, p, draws=length(n))

Arguments

n

vector of sizes

p

vector or probs

rows

numeric giving desired number rows to be output

draws

number samples required

Value

a matrix of rows rows delivering specified samples

Author(s)

John Wallace, 17 Feb 1997 S-news , mods by Chasalow

Examples

1
2
3
 n <- c(100,20,10)
 p <- matrix(c(.3,.1,.5,.1,.1,.2,.6,.8,.3),3)
 rmultinomial(n,p)

Example output

Attaching package: 'combinat'

The following object is masked from 'package:utils':

    combn

     [,1] [,2] [,3]
[1,]   21   11   68
[2,]    1    1   18
[3,]    5    2    3

combinat documentation built on May 2, 2019, 5:57 a.m.