Learn R Programming

SBMSplitMerge (version 1.1.1)

rcat: Draw draw Categorical distribution

Description

Draw draw Categorical distribution

Usage

rcat(n, p, replace = TRUE)

Arguments

n

number of draws

p

a length-d probability vector

replace

should the categories be replaced? If so n < p required

Value

a draw from Categorical(p)

Examples

Run this code
# NOT RUN {
rcat(1, 1) ## returns 1 with probability 1
rcat(1, rep(1/6,6)) ## a dice roll
# }

Run the code above in your browser using DataLab