# How does one find the mode of a distribution without counting manually?

I know if I have a set of elements

$\lbrace 1,2,3,4,4,4,5,8,9\rbrace$

Then the mode is $4$ in this case.

How do I find the mode for more complex distributions?

I have formulas that give me median, mean, etc. but I don't see how to calculate mode.

For instance, gamma distribution

• It's actually computationally hard. For a distribution, you are just seeking the maximum value, so if the distribution is continuous, you can use calculus techniques. – Thomas Andrews Feb 9 '16 at 21:31
• Thanks for replying. Can you elaborate on this a bit? Why maximum value? How is that equivalent? – Stan Shunpike Feb 9 '16 at 21:35
• How do you define "mode"? You are seeking the value $x$ where the PDF is at its maximum, by definition of mode. Of course, that $x$ is not always unique, but that's to problem with "mode" in general. – Thomas Andrews Feb 9 '16 at 21:37
• I thought mode was the one that occurred mode frequently. I have never really used it before. I was asked on an exam to find it and my professor nor TAs did not discuss it, so I came here inquiring. – Stan Shunpike Feb 9 '16 at 21:40
• You mean, other than the thing on the right that said "Mode" in big letters? – Thomas Andrews Feb 9 '16 at 21:45

The mode of a $sample$ is the the most frequently occurring number or category (it it exists). If I die is rolled 5 times and we get faces 1,1,2,3,4,then 1 is the 'modal face' observed. But if we get faces 1,1,2,3,3, then there is no mode. (Informally, some texts might speak of a 'double mode'.)

The mode of a $distribution$ is the value $\xi$ at which the PDF achieves a maximum (if there is such a value). Thus, $Unif(0, 1)$ does not have a mode, but $Norm(\mu = 100, \sigma=15)$ has a mode (same as the mean) at $\mu = \xi = 100.$

In a right-skewed distribution, it is fairly common to have $\xi > \eta > \mu,$ where $\eta$ is the median. In particular, $Gamma(shape=5, scale=1)$ has $\xi = 4$ (by differential calculus), $\eta = 4.670909$ (by numerical integration), and $\mu = 5.$ (The notation $\mu$ is standard, $\eta$ is often seen, and there seems to be no standard notation for the mode.)

In a large sample from a continuous distribution, sometimes one tries to 'smooth' a histogram of the data to estimate the location of the mode of the population distribution. Based on 100,000 observations from $Gamma(5, 1)$, the figure below suggests that the mode of the population is near 4. (However, technically, no two observations are equal, except possibly as a result of rounding.) The purple curve is from the default density estimator in R.

For continuous densities, you use calculus (with which I am sure that you are familiar).

Let $X$ follow a Gamma distribution with density $$f_X(x) = \frac{1}{\Gamma(k)\theta^k} x^{k-1}e^{- x/\theta}.$$

Next, find the critical points $$0 =f_X'(x) = \frac{1}{\Gamma(k)\theta^k}\left[(k-1)x^{k-2}e^{-x/\theta}+e^{-x/\theta}(-1/\theta)x^{k-1}\right]$$

I skip a few steps and will let you confirm that the maximum is attained when $$0 = x^{k-2}\left(k-1+\frac{-1}{\theta}x\right).$$

This gives the mode at $$x = \theta(k-1).$$