Learn R Programming

VBmix (version 0.3.2)

multinomial:

Description

samples from a k-multinomial.

Usage

multinomial(weights, k)

Arguments

weights
numeric vector with the weights of the multinomial. Sum to 1.
k
size of the weight vector.

Value

an integer value in [1,k], coded as a 1-of-k variable (see reference).

References

Bishop, C. M. (2006) _Pattern Recognition and Machine Learning_ Chap. 10, Springer.

Examples

Run this code
weights <- c(0.3, 0.5, 0.2)
multinomial(weights, 3)
#[1] 0 1 0

Run the code above in your browser using DataLab