Skip to contents

This function calculates the mode of a distribution, given as a ddf object. In the case of the mode not being unique, by default all possible values are returned. This behaviour can be controlled using the methods argument.

Usage

modes(dist, method = "all")

Arguments

dist

A ddf object, the distribution.

method

A character specifying the output format.

Value

A numeric vector.

Details

A mode of a discrete random variable \(X\) is a value at which the probability mass function of \(X\) takes its maximal value.

In general, it is not unique which is the reason for this function to have the method argument.

  • If method is set to "all", all values in the support which are a mode of the given distribution are returned. This is the default behaviour.

  • If method is set to "mean", the mean of all such values is returned.

  • If method is set to "min" or "max", the respective elements of all modes are returned.

Examples

# In case the mode is not unique, by default all
# possible modes are returned
modes(unif(3))
#> [1] 1 2 3
# This can be controlled using the method argument
modes(unif(3), method = "mean")
#> [1] 2