rMultinom: Generate Random Samples from Different Multinomial...

Description Usage Arguments Details Value See Also Examples

View source: R/rMultinom.R

Description

Generate random samples from multinomial distributions with the same number of classes but different event probabilities.

Usage

1

Arguments

p

matrix with each row specifying the probabilities for different classes of each sample.

Details

This function vectorizes the generation of random samples from different multinomial distributions by the inversion of CDF method.

Value

Random samples from multinomial distributions.

See Also

rmultinom

Examples

1
2
3
4
5
6
7
  #Example 1: Generate 100 random samples from multinomial distributions
  #           with 3 classes and different event probabilities.
  p1 <- runif(100)
  p2  <- runif(100, 0, 1-p1)
  p3 <- 1-p1-p2 
  x <- rMultinom(p=cbind(p1, p2, p3))
  

Example output

Loading required package: MCMCpack
Loading required package: coda
Loading required package: MASS
##
## Markov Chain Monte Carlo Package (MCMCpack)
## Copyright (C) 2003-2018 Andrew D. Martin, Kevin M. Quinn, and Jong Hee Park
##
## Support provided by the U.S. National Science Foundation
## (Grants SES-0350646 and SES-0350613)
##
Loading required package: mvtnorm
Loading required package: Rcpp
Loading required package: RcppArmadillo

miscF documentation built on Feb. 17, 2018, 1:01 a.m.