# How do we calculate the expected value E(X) for a density function?

1. Jul 22, 2013

### EdmureTully

Give me an example like:

X: random variable representing the sum of 1 dice roll

p: probability of getting a dice result

E(X) = sum of X*p = 1(1/6) + 2(1/6) + 3(1/6) + 4(1/6) + 5(1/6) +6(1/6)

BONUS POINT:

what would be the E(X) for 3 dice rolls?

Sorry, I am really dumb. I am trying to understand exactly what E(X) means.

2. Jul 22, 2013

### Stephen Tashi

It means the "expected value of X", which also called "the mean value of X". Are those terms defined in your study materials?

3. Jul 22, 2013

### EdmureTully

I just don't really know how to find the E(X) of a density function and how to apply the theory for any case.

4. Jul 23, 2013

### Stephen Tashi

Your situation isn't clear. Are you studying a book? Or are you trying to take some sort of quiz without having ever studied a book on probability theory or statistics? Your post which begins "Give me an example like" isn't even clear. Are you saying that someone gave you an example like that? Are you requesting another example?

5. Jul 23, 2013

### EdmureTully

I am requesting an example for a density function and not a mass function.

6. Jul 23, 2013

### HallsofIvy

Staff Emeritus
The problem, as you stated it, tells you all of that. For a single dice roll, there are 6 possible outcomes, all equally likely so the "density function" is f(1)= 1/6, f(2)= 1/6, f(3)= 1/6, f(4)= 1/6, f(5)= 1/6, f(6)= 1/6. The "mass function" (also called "cumulative probability function") is F(1)= 1/6, F(2)= 2/6= 1/3, f(3)= 3/6= 1/3, f(4)= 4/6= 2/3, f(5)= 5/6, f(6)= 6/6= 1.

E(x), the "expected value", is the sum of each value times it probability: 1(1/6)+ 2(1/6)+ 3(1/6)+ 4(1/6)+ 5(1/6)+ 6(1/6)= (1/6)(1+ 2+ 3+ 4+ 5+ 6)= (1/6)(21)= 3.5.

Of course, the calculations for three rolls are much harder. The lowest possible sum of three rolls is 1+ 1+ 1= 3 and that will occur only if all three rolls are 1. The probabability of that is (1/6)(1/6)(1/6)= 1/216. You can get a total of 4 with 2+ 1+ 1- that is 2 on die 1, and 1 on the other 2. Since the probability of any one number is 1/6, the probability of "2, 1, 1" is also (1/6)(1/6)(1/6)= 1/216. But we can also get 4 with 1+ 2+ 1- 1 on die 1, 2 on die 2, and 1 on die 3, or 1+ 1+2- 1 on dice 1 and 2, 2 on die 3. The probability of each of those is each 1/216 but the probability of a total of 4 in any of those ways is 1/216+ 1/216+ 1/216= 3/216= 1/72. And for a total of 5, it gets worse! 1+ 1+ 3, 1+ 3+ 1, 3+ 1+ 1, 2+ 2+ 1, 2+ 1+ 2, 1+ 2+ 2, etc.

7. Jul 23, 2013

### Stephen Tashi

In many books the term "density function" is often used for both discrete and continuous random variables, but perhaps your study materials use "mass function" exclusively for discrete random variables and you are asking for an example of computing $E(X)$ for a continuous random variable. Is that your question?

8. Jul 23, 2013

### jbunniii

The expected value for a real-valued random variable which has a density function $p$ is defined as
$$E[X] = \int_{-\infty}^{\infty} x p(x) dx$$
For example, if $X$ is uniformly distributed over the interval $[2,4]$, then we have
$$p(x) = \begin{cases} \frac{1}{2} & \text{ if }2 \leq x \leq 4 \\ 0 & \text{ otherwise} \\ \end{cases}$$
and therefore
$$E[X] = \int_{2}^{4} \frac{1}{2} x dx = 3$$

9. Jul 23, 2013

### chiro

Also recall that the expectation operator has the following property:

E[aX+bY] = aE[X] + bE[Y] for constants a,b and random variables X and Y.