Distribution function given expectation and maximal variance I'm working on the following problem I got in a hw but I'm stuck. It just asks to find the distribution function of a random variable $X$ on a discrete probability spaces that takes values in $[A,B]$ and for which $Var(X) = \left(\frac{B-A}{2}\right)^{2}.$
I got that this equality gives the expected values $E(X) = \frac{A+B}{2}$ and $E(X^{2}) = \frac{A^{2}+B^{2}}{2}$, but I can't see why this gives a unique distribution (as the statement of the problem suggests).
I also found the distribution function $p(x) = 0$ for $x \in (A,B)$ and $p(A)=\frac{1}{2}$, $p(B)=\frac{1}{2}$ that works for example, but I don't see how this is the only one. Can anyone shed some light please?
Thanks a lot!
 A: If we simplify the problem and scale things appropriately, you're essentially looking for a distribution function $f(x)$ such that 
$$
\int_{-1}^{1} f(x) \, dx = 1, \quad \int_{-1}^1 x f(x) \, dx = 0, \quad \int_{-1}^1 x^2 f(x) \, dx = 1.
$$
Let us look only at the first two integrals first, so that we only look at variables $X$ whose $f$ satisfy
$$
\int_{-1}^1 f(x) \, dx = 1, \quad \int_{-1}^1 x^2 f(x) \, dx = 1.
$$
This implies that 
$$
\int_{-1}^1 (1 - x^2) f(x) \, dx = 0.
$$
Notice that $1-x^2$ is positive and $f$ is a positive measure on $[-1,1]$ for which $\int_{-1}^1 f = 1$. Consider $\varepsilon > 0$ and $A_{\varepsilon} = [-1+\varepsilon, 1 - \varepsilon]$. Assume that $\int_{A_{\varepsilon}} f(x) \, dx > 0$. Therefore 
$$
0 = \int_{-1}^1 (1-x^2)f(x) \, dx \ge \int_{A_{\varepsilon}} (1-x^2) f(x) \, dx \ge \int_{A_\varepsilon} (1-(1-\varepsilon)^2) f(x) \, dx > 0
$$ 
because the last integral is a constant times the integral over $A_{\varepsilon}$ of $f$. This contradiction shows that $\int_{A_{\varepsilon}} f(x) \, dx = 0$ for every $\varepsilon > 0$.
Since probability measures are continuous, we can let $\varepsilon \to 0$ and know that $p(]-1,1[) = 0$. This means $p( \{-1,1\} ) = 1$ by taking complements. Since the expectation has to be $0$, the variable has to be symmetric, i.e. $p(-1) = p(1) = \frac 12$. 
Hope that helps,
A: Let $m=\frac12(A+B)$ and $h=\frac12(B-A)$. The OP indicates in a comment how to prove that any random variable $X$ with values in $[A,B]$ and such that $\mathrm{Var}(X)=h^2$ is such that $\mathbb E(X)=m$ and $\mathbb E((X-m)^2)=h^2$. 
Starting from this point, note that $|X(\omega)-m|\leqslant h$ for every $\omega$ since $A\leqslant X(\omega)\leqslant B$, hence $(X-m)^2\leqslant h^2$ everywhere. Together with the equality $\mathbb E((X-m)^2)=h^2$, this proves that $(X-m)^2=h^2$ almost surely, that is, $X\in\{A,B\}$ almost surely. Now, use once again the fact that $\mathbb E(X)=m$ to deduce that $\mathbb P(X=A)=\mathbb P(X=B)=\frac12$.
Edit: Let us recall why $Y\geqslant0$ almost everywhere and $\mathbb E(Y)=0$ imply that $Y=0$ almost everywhere. 
Fix $\varepsilon\gt0$, then $Y\geqslant0$ almost everywhere hence $Y\geqslant\varepsilon\mathbf 1_{Y\geqslant\varepsilon}$ almost everywhere. This implies that $0=\mathbb E(Y)\geqslant\varepsilon\,\mathbb P(Y\geqslant\varepsilon)$, that is, $\mathbb P(Y\geqslant\varepsilon)=0$. Now, $[Y\ne0]=[Y\gt0]$ is the countable union over every positive integer $n$ of the events $[Y\geqslant1/n]$ hence $\mathbb P(Y\ne0)=0$. QED.
