# Does a Zero Variance imply a constant random variable? [duplicate]

I managed to show that if a random variable is constant : $P(X = \mu ) = 1$ then the Variance is zero:

$E[X^2] = \sum_{i = 1}^{k} p_iX_i^2 =>$ (given X_i is constant)$=> X^2\sum_{i=1}^kp_i = X^2$

$E[X]^2 = (\sum_{i=1}^{k}p_iX_i)^2 = (X\sum_{i=1}^{k}p_i)^2 = X^2$

This is relatively straight forward with the for on the variance of $E[X^2]-E[X]^2$

However is the converse true? Does a zero variance necessarily imply a constant random variable?

• No, but it is almost surely constant. The probability it takes a different value is $0$. – Henry Oct 4 '16 at 14:59
• What is an example where the converse is false? – rannoudanames Oct 4 '16 at 15:00
• For example, choose $U$ uniformly in $[0,1]$ and let $X=2$ if $U$ is rational and $X=3$ if $U$ is irrational. Then the variance of $X$ is zero – Henry Oct 4 '16 at 15:01
• I understand the conditions to the variable Y, however, I do not see how the variance would be zero, is it because rationals are dense on the reals? – rannoudanames Oct 4 '16 at 15:05
• It is because the Lebesgue measure of $\mathbb{Q}$ is $0$. – Augustin Oct 4 '16 at 15:06

A non-negative random variable with a zero expected value is almost surely equal to $0$. This comes from the properties of the integral.
If you apply this to the random variable $(X-E(X))^2$, which is non-negative, assuming that $V(X)=E\left[(X-E(X))^2\right]=0$ implies that $(X-E(X))^2=0$ a.s., which means that $X=E(X)$ a.s.
• Yes, we may have $X\neq E(X)$ on a null set, which is a subset of a set with $0$ probability. – Augustin Oct 4 '16 at 15:16