rvmultinom: Generate Random Variables from a Multinomial Sampling Model

View source: R/rvmultinom.R

rvmultinomR Documentation

Generate Random Variables from a Multinomial Sampling Model

Description

Generates a random vector from a multinomial sampling model.

Usage

rvmultinom(n = 1, size = 1, prob)

Arguments

n

integer, number of random variables to generate

size

integer or integer-valued rv: the number of trials (size of each sample)

prob

vector (of length at least 3) prior probabilities of successes of each trial (may be constant or an rv object)

Details

The length of prob determines the number of bins.

The vector prob will be normalized to have sum 1.

If length(prob) is two, rvbinom is called instead.

NOTE. Case of random n or size or prob — not yet optimized for speed.

Value

A random array of dimensions length(prob) times n.

Author(s)

Jouni Kerman jouni@kerman.com

References

Kerman, J. and Gelman, A. (2007). Manipulating and Summarizing Posterior Simulations Using Random Variable Objects. Statistics and Computing 17:3, 235-244.

See also vignette("rv").

Examples


  y <- rvmultinom(n=3, size=1, prob=c(0.20, 0.30, 0.50))


rv documentation built on March 18, 2022, 5:55 p.m.