Learn R Programming

miscF (version 0.1-5)

rMultinom: Generate Random Samples from Different Multinomial Distributions with the Same Number of Classes

Description

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

Usage

rMultinom(p)

Arguments

p

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

Value

Random samples from multinomial distributions.

Details

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

See Also

rmultinom

Examples

Run this code
# NOT RUN {
  #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))
  
# }

Run the code above in your browser using DataLab