What is the maximum possible coefficient of variation for data taking values within a specified range? I have a question that seems very basic, and yet I have not managed to find an answer after probably several hours of Google-searching.
Fix $0<a<b<\infty$, and let $\mathcal{P}_{[a,b]}$ be the set of all probability distributions on $[a,b]$. For each $p \in \mathcal{P}_{[a,b]}$, let
\begin{align*}
\mu(p) &= \int_{[a,b]} \! x \, p(dx) \\
\sigma(p) &= \sqrt{ \int_{[a,b]} \! x^2 \, p(dx) \ - \ \mu(p)^2 } \\
\gamma(p) &= \frac{\sigma(p)}{\mu(p)}\text{.}
\end{align*}
We call $\gamma(p)$ the coefficient of variation of $p$.

What is $\max_{p \in \mathcal{P}_{[a,b]}} \gamma(p)$?
And is there any paper or textbook that can be cited for the answer to this question?


Remarks.
I believe that this maximum must exist, as $\mu$ and $\sigma$ are continuous with respect to the topology of weak convergence, and $\mathcal{P}_{[a,b]}$ is compact under the topology of weak convergence (since $[a,b]$ is compact).
It should be easy to show that any maximising $p$ has the following three properties:

*

*At least one of the intervals $(a,\mu(p)]$ and $[\mu(p),b)$ is a $p$-null set; hence in particular, at least one of the singletons $\{a\}$ and $\{b\}$ is a $p$-positive measure set.

*$\mu(p) \leq \frac{a+b}{2}$.

*The support of $p$ (i.e. the smallest $p$-full measure closed set) includes both $a$ and $b$.

The first of these must hold, otherwise one can spread some of the mass of $p$ away from $\mu(p)$ in such a manner as to increase $\sigma(p)$ while preserving $\mu(p)$.
The second of these must hold, otherwise one can reflect the mass of $p$ in the point $\frac{a+b}{2}$, resulting in a decreased $\mu(p)$ while $\sigma(p)$ stays the same.
Assuming the first of these, the third of these must hold: otherwise, one can linearly spread the mass of $p$ away from $a$ or $b$ as appropriate, and then $\sigma(p)$ will increase by a factor that is greater than the factor of increase of $\mu(p)$. (Specifically, either $\mu(p)$ will decrease, or else $\mu(p)-a$ will increase by the same factor that $\sigma(p)$ increases.)
My not-very-confident intuition is that any maximising $p$ must be fully supported on the boundary points. Of course, maximising $\gamma(p)$ over the set of probability measures supported on $\{a,b\}$ is an easy problem, as there is only one variable being varied (namely, $p(\{a\})$). Plugging the question into Wolfram Alpha (because I'm too lazy to do it by hand), we get that the maximisation is achieved by
$$ p(\{a\}) = \frac{b}{a+b}\text{,} \quad\quad p(\{b\}) = \frac{a}{a+b}\text{,} $$
for which we have
$$ \gamma(p) = \frac{b-a}{2\sqrt{ab}}\text{.} $$
But whether this remains the maximum over the whole of $\mathcal{P}_{[a,b]}$ I do not know for sure.
 A: Indeed, for any random variable (r.v.) $X$ with values in $[a,b]$ and mean $\mu\in[a,b]$,
$$Var\,X\le Var\,X_{a,b;\mu}=(b-\mu)(\mu-a), \tag{1}$$
where $X_{a,b;\mu}$ is any r.v. with the unique distribution with mean $\mu$ supported on the two-point set $\{a,b\}$. So, the result that you conjectured follows, because
$$\max_{\mu\in[a,b]}\frac{(b-\mu)(\mu-a)}{\mu^2}$$
is attained when $\mu$ is the harmonic mean of $a,b$ and equals $\dfrac{(b-a)^2}{4ab}$.
(However, the maximizing distribution, on the two-point set $\{a,b\}$, is discrete and thus does not have a density function.)

One way to prove inequality (1) is as follows. By Vieta's formula, for all $x\in[a,b]$ we have $x^2-(a+b)x+ab\le0$ and hence
$$x^2\le(a+b)x-ab, \tag{2}$$
with the equality iff $x\in\{a,b\}$. So,
$$EX^2\le(a+b)\mu-ab=EX_{a,b;\mu}^2. \tag{3}$$
Since $Var\,X=EX^2-\mu^2$, we do now get (1).
Moreover, since the inequality in (2) is strict for $x\notin\{a,b\}$, the inequality in (3) is strict unless $X$ equals $X_{a,b;\mu}$ in distribution. Thus, the inequality in (1) is strict unless $X$ equals $X_{a,b;\mu}$ in distribution.
