Skip to contents

Categorical distribution

Usage

CategoricalDist(k = NULL, probs = c(0.5, 0.5), n = 0, seed = 0)

Arguments

k

Categories (0-based) at which to evaluate.

probs

Non-negative weights (normalised).

n

Number of draws.

seed

Philox seed.

Value

list(probs, mean, var, pmf, cdf, random).

References

Johnson, Kemp & Kotz (2005). Univariate Discrete Distributions, 3rd ed., ch. 10.

Examples

CategoricalDist(1, probs = c(1, 3))$pmf
#> [1] 0.75