# How to calculate this expected value

How do you calculate this expected value? I have tried everything and I cant seem to get the right answer. The distribution function of a random variable $X$ is given by: $$F(X)=\begin {cases} 0& x\lt -3 \\ \frac38 &-3 \le x \lt 0 \\ \frac12 & 0 \le x \lt 3 \\ \frac34 & 3 \le x \lt 4 \\ 1 & x \ge 4\end {cases}$$

I hope this makes sense, in my practice book it has it all lined up nice and neat if it helps to think of it that way. I know that $E(X)=\frac58$ but I'm just not sure how thats the answer.

-
See if I got the $\LaTeX$ right. You can right click and Show Math as > TeX commands to see what I did. – Ross Millikan Oct 26 '12 at 5:17

Note that the function $F$ is the cumulative distribution function of $X$. The usual notation is $F(x)$, or $F_X(x)$ if we want to be reminded of whch random variable we are working with. Very importantly, it should never be written $F(X)$.

By definition, $$F_X(x)=\Pr(X\le x).$$ With continuous random variables, we can be pretty casual about the use of inequality symbols. With discrete random variables, we have to be much more careful, and cannot casually replace $\le$ by $\lt$.

Look at the first part of the specification of $F$. It tells us, among other things, that $F(-17)=0$. So $\Pr(X\le -17)=0$: there is no "weight" at $-17$ or to the left of it. We also have $F(-\pi)=0$: so $\Pr(X\le -\pi)=0$.

There is a sudden jump in the cumulative distribution function at $-3$. A tiny bit to the left of $-3$, it was $0$. But all of a sudden, at $-3$, $F$ has value $\dfrac{3}{8}$. The jump at $-3$ means that we must have $\Pr(X=-3)=\dfrac{3}{8}$.

Then things are steady until $0$, the cumulative distribution function is $\dfrac{3}{8}$ at $-2$, $-1$, $-0.2$. So $\Pr(X\le -0.2)=\dfrac{3}{8}$, no weight has been added. But at $x=0$, the cdf jumps to $\dfrac{1}{2}$. So $\Pr(X=0)=\dfrac{1}{2}-\dfrac{3}{8}=\dfrac{1}{8}$.

Similarly, $\Pr(X=3)=\dfrac{3}{4}-\dfrac{1}{2}=\dfrac{1}{4}$. similarly, $\Pr(X=4)=\dfrac{1}{4}$.

Now we are at a simple expected value problem. $$E(X)=(-3)\frac{3}{8}+(0)\frac{1}{8}+(3)\frac{1}{4}+(4)\frac{1}{4}=\frac{5}{8}.$$

Remark: For a non-negative integer-valued random variable $Y$, there is a useful way to compute $E(Y)$: $$E(Y)=\sum_{i=1}^\infty \Pr(Y\ge i).$$ We can adapt this to our problem by adding $3$ to $X$, computing the expectation by using the above formula, and subtracting $3$ at the end. One needs to be careful in using the cdf to calculate $\Pr(X\ge i)$.

There is a useful analogue of the above formula for non-negative random variables with continuous distribution. For some details, please look at this.

-
if by definition the $E(X)= \sum_x xP(x)$ how come you dont include the numbers between the steps like for this one -2, and -1 times their probability of (3/8) and so on? – TheHopefulActuary Oct 26 '12 at 12:32
I was worried that if you had not seen the special formula in the comment, it might confuse you. So look only at the main part. Suppose you win $1$ dollar with probability $\frac{5}{6}$, $3$ dollars with probabiity $\frac{1}{9}$, and $7$ dollars with probability $\frac{1}{18}$. Then your mean win is $(1)(5/6)+(3)(1/9)+(7)(1/18)$. The in-between numbers don't figure at all in the calculation. But you know that. The important point is that the fact that the cdf is $3/8$ at $x=-2$, and for that matter at $-2.1234$, does not mean that we get $-2$ with probability $3/8$. (continued) – André Nicolas Oct 26 '12 at 13:27
(Cont) The function of your problem, which should have been called $F_X(x)$, is the cumulative distribution function, it does not give the probability that $X=x$, it gives the probability that $X\le x$. That's crucially important. In our case, $F(-2)=3/8$, and $F(-0.7)=3/8$. So with probability $3/8$, $X\le -2$, and with the same probability $3/8$, $X\le -0.7$. That means that there is probability $0$ that $-2\lt X\le -0.7$. When caps are used, like $F$, it usually means cumulative. The problem should have said cumulative distribution function, for clarity. – André Nicolas Oct 26 '12 at 13:36
@Kyle: Your comment above shows you may have some trouble with (cumulative) distribution function. So I altered the beginning of my answer to try to explain a little more. – André Nicolas Oct 26 '12 at 13:58