Learn R Programming

bbricks (version 0.1.4)

dCategorical: Probability mass function for Categorical distribution

Description

Calculate probability masses for integer valued Categorical random samples. 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

dCategorical(x, p)

Arguments

x

integer, categorical samples.

p

numeric, probabilities.

Value

A numeric vector of the same length of 'x'.

See Also

rCategorical

Examples

Run this code
# NOT RUN {
dCategorical(x=c(1L,2L,1L),p=c(1,2))
# }

Run the code above in your browser using DataLab