# Expectation of absolute value of a function

Let x be real valued random variable taking values on $a_1,\ldots, a_n$. Let $\Pr(x=a_i)=p_i$. Let $f$ be real valued function defined on $a_1, \ldots, a_n$

It is known that $$E(f(x))=\sum_{i=1}^nf(a_i)p_i.$$

Would be the same formula true for $E(|f(x)|)$, i. e. $$E(|f(x)|)=\sum_{i=1}^n|f(a_i)|p_i?$$

Thank you.

-
Yes. As $|f|$ is "a real valued function, defined on ..." .. just apply your formula to $|f|$. –  martini Jul 10 '12 at 20:24
Let $g(x) := |f(x)|$ be defined on $a_1, \dots, a_n$. The composition of two real valued functions is a real valued function.
Now computing $E(g(x))$...