rcat: Draw draw Categorical distribution

Description Usage Arguments Value Examples

View source: R/misc.R

Description

Draw draw Categorical distribution

Usage

1
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

1
2
rcat(1, 1) ## returns 1 with probability 1
rcat(1, rep(1/6,6)) ## a dice roll

SBMSplitMerge documentation built on July 1, 2020, 5:23 p.m.