rCategorical: Random generation for Categorical distribution

Description Usage Arguments Value See Also Examples

View source: R/Categorical_Inference.r

Description

Generate random integer samples from a Categorical distribution. For a random variable x, the density function of categorical distribution is defined as

prod_{k in 1:K} p_k^{I(x=k)}

Where K is the number of unique values.

Usage

1

Arguments

n

integer, number of samples.

p

numeric, probabilities. length(p)=K.

Value

An integer vector of length n.

See Also

dCategorical

Examples

1
rCategorical(n=20,p=c(1,2))

bbricks documentation built on July 8, 2020, 7:29 p.m.