Similar to @seealso estimatePdf, this function returns the probability for a discrete value, given some observations.

getProbForDiscrete(data, value)

Arguments

data

vector of observations that have the same type as the given value.

value

a single observation of the same type as the data vector.

Value

the probability of value given data.

Note

If no observations are given, then this function will warn and return a probability of zero for the value given. While we could technically return positive infinity, 0 is more suitable in the context of Bayesian inferencing.

Examples

mmb::getProbForDiscrete(data = c(), value = iris[1,]$Species)
#> Warning: No data was given for calculating probability for discrete value.
#> [1] 0
mmb::getProbForDiscrete(data = iris$Species, value = iris[1,]$Species)
#> [1] 0.3333333