# For $\pm 1$-valued random variables, why is the mean absolute error equal to the variance?

Title says it all: if $X$ is a $\pm 1$-valued random variable with mean $\mu$, 'why' is $\mathbf{E}[|X - \mu|] = \mathbf{E}[|X-\mu|^2]$? Obviously one can do a couple of lines of trivial algebra to verify it, but is there a simple-to-state reason? Something you can say to make me say, "Oh yeah, of course" without any calculation?

Thanks!

-
add comment

## 1 Answer

If $x=\pm1$ and $|\mu|\leqslant1$, $\mathrm{sgn}(x-\mu)=x$ hence $$|x-\mu|=x\cdot(x-\mu)=(x-\mu)^2+\mu\cdot(x-\mu).$$ Thus, $|X-\mu|=(X-\mu)^2+\mu\cdot(X-\mu)$ almost surely. Since $\mathrm E(X-\mu)=0$, this yields $\mathrm E(|X-\mu|)=\mathrm E((X-\mu)^2)$.

-
I like this answer. Here is another one I thought of (sorry to give answers to my own questions): –  Ryan O'Donnell Sep 6 '12 at 11:43
It's ultimately similar to your answer. Let $X'$ be a copy of $X$. Then $\mathbf{E}[|X-\mu|] = \mathbf{E}[|X - \mathbf{E}[X']|]$. Fix an outcome $x$ of $X$. Inside the outer expectation we have $|x - \mathbf{E}[X']| = |\mathbf{E}[x - X']|$. Recalling that $x, X' \in \{-1,1\}$ it's clear that $\mathbf{E}[x - X']$ is, up to sign, equal to $2\Pr[X' \neq x]$. Hence we deduce the overall quantity is $2\Pr[X \neq X']$. But of course $\mathbf{Var}[X] = (1/2)\mathbf{E}[(X-X')^2]$, and using the fact that $X, X'$ have range $\{-1,1\}$, this is also clearly equal to $2\Pr[X \neq X']$. –  Ryan O'Donnell Sep 6 '12 at 11:50
In other words, $(X-X')^2=4\mathbf 1_{X\ne X'}$ and $X-\mu=E(X-X'\mid X)=\pm2P(X\ne X'\mid X)$ hence $2E(|X-\mu|)=4P(X\ne X')=E((X-X')^2)=2\sigma^2(X)$. Nice... –  Did Sep 6 '12 at 12:10
Good, I think this is perhaps the most satisfactory phrasing. –  Ryan O'Donnell Sep 6 '12 at 13:13
add comment