Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

distMode

Mode of a Unimodal Distribution


Description

Function to calculate the mode of a unimodal distribution which is specified by the root of the density function name and the corresponding parameters.

Usage

distMode(densFn, param = NULL, ...)

Arguments

densFn

Character. The name of the density function for which the mode is required.

param

Numeric. A vector giving the parameter values for the distribution specified by densFn. If no param values are specified, then the default parameter values of each distribution are used instead.

...

Passes arguments to optimize. In particular, the parameters of the distribution.

Details

The name of the unimodal density function must be supplied as the characters of the root for that density (e.g. norm, ghyp). The particular unimodal distribution being considered is specified by the value of the argument param, or for base R distributions by specification in the ... arguments.

Value

The mode is found by a numerical optimization using optimize.

Author(s)

See Also

Examples

normRange <- distCalcRange("norm", tol = 10^(-7), mean = 4, sd = 1)
curve(dnorm(x, mean = 4, sd = 1), normRange[1], normRange[2])
abline(v = distMode("norm", mean = 4, sd = 1), col = "blue")

DistributionUtils

Distribution Utilities

v0.6-0
GPL (>= 2)
Authors
David Scott <d.scott@auckland.ac.nz>
Initial release
2018-11-26

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.