# Expectation of a random variable

1. Jun 28, 2011

### Maybe_Memorie

1. The problem statement, all variables and given/known data

I'm wondering how I go about calculating the expectation of a random variable?
Is it a different process for a discrete and a continuous?

Can you show me an example? Say Poisson and expoential?

Also, in the formula
Var(X) = E[X^2] - (E[X])^2

how does one calculate E[X^2] ?

Thanks!

2. Jun 29, 2011

### I like Serena

Hi Maybe_Memorie!

To calculate an expectation you need to multiply the chance of each outcome with the value of each outcome and add everything up.

The difference between discrete and continuous is that the first uses a summation while the second uses an integral.

So:
$$E[X] = \sum P(x) \cdot x$$
and
$$E[X^2] = \sum P(x) \cdot x^2$$

So for a six sided dice you would get:
$$E[X] = \sum_{k=1}^6 P(k) \cdot k = \frac 1 6 \cdot 1 + \frac 1 6 \cdot 2 + \frac 1 6 \cdot 3 + \frac 1 6 \cdot 4 + \frac 1 6 \cdot 5 + \frac 1 6 \cdot 6 = 3 \frac 1 2$$

3. Jul 2, 2011

### I like Serena

I see you didn't respond.

Do you already know what you wanted to know?
Is perhaps the strange wiggly symbol (sigma) putting you off?
Or is there something else that you don't understand but don't want to ask about?

4. Jul 3, 2011

### Maybe_Memorie

I think I understand.

Suppose I wanted the expectation of the exponential random variable.

f(x) = the probability density function.

A = lambda

E[X] = integral of xf(x) dx

E[X] = integral of (xAe^(-Ax)) dx between + and - infinity.

Do I have to use integration by parts? In none of my classes have I come across integration with infinity as a limit

Last edited: Jul 3, 2011
5. Jul 3, 2011

### I like Serena

Ah, there you are! :)

You certainly seem to understand.
Your boundaries are slightly off though.
The exponential distribution only has non-zero values for positive x, so the bottom boundary should be zero (and not - infinity).

And yes, you have to use integration by parts.
So you are already aware of that. Good.

As for infinity as a boundary, you have not come across it ... yet!
It means you have to integrate to an arbitrary boundary, and then take the limit of that boundary to infinity.

So in your case, you'll get:
$$\begin{eqnarray} E[X] &=& \int_0^{\infty} \lambda e^{-\lambda x} \cdot x dx \\ &=& \left[ - e^{-\lambda x} \cdot x \right]_0^{\infty} - \int_0^{\infty} - e^{-\lambda x} \cdot 1 dx \\ &=& (\lim_{x \to \infty} - e^{-\lambda x} \cdot x) - (- e^{-\lambda \cdot 0} \cdot 0) - \int_0^{\infty} - e^{-\lambda x} \cdot 1 dx \\ &=& 0 - 0 - \int_0^{\infty} - e^{-\lambda x} \cdot 1 dx \\ &=& ... \\ &=& \frac 1 {\lambda} \end{eqnarray}$$

6. Jul 3, 2011

### Maybe_Memorie

Ah! Thank you very much!

I have another question. A related application.

The system S is composed of two components, C1 and C2, in parallel (S works provided at least 1 of the components works). The two components have lifetimes T1 and T2 and are exponentially distributed with the same parameter A=0.01

(i) What is the probability that T1 is greater than 100?
P(x>100) = 1 - e^(-100(0.01))

(ii) What is the probability that Ts, the lifetime of the system, is greater than 100?
Do I just add the probabilities that T1 and T2 are greater than 100?

(iii) What is the probability density function of Ts?
I'm lost here

(iv) Derive the expectation of Ts.
When I find the PDF, multiply by x and integrate between 0 and infinity with respect to x.

7. Jul 3, 2011

### I like Serena

You're welcome!

You have calculated P(x<100)....

Do you know the rule about the probability of independent events occurring simultaneously?
That is P(A and B) where events A and B are independent?

For that you first need to answer (ii), which would show what the cumulative probability function of Ts is.

Yep! :)
(But perhaps it will turn out to be easier. )

8. Jul 3, 2011

### Maybe_Memorie

Isn't it P(A and B) = P(A).P(B) ?

9. Jul 3, 2011

### I like Serena

Yes! So you should not add up the probabilities for T1 and T2, but multiply them!

10. Jul 3, 2011

### Maybe_Memorie

Thanks!

I still need to find the PDF.

Is it the same as multiplying the PDF of T1 and T2?

11. Jul 3, 2011

### I like Serena

No, to find the PDF you need to find the CDF first, and deduce from that the PDF.

Actually, the PDF is the derivative of the CDF.

For reference did you properly solve (i) and (ii)?
Because you need them, and you'd be making it easier for me if I know that you got those and understood those.

12. Jul 3, 2011

### Maybe_Memorie

For (i), the probability is 1/e, whatever that works out at...

For (ii), I'm slightly confused. The system doesn't need T1 and T2 to be greater than 100 for Ts to be > 100. It needs only one of them to be greater than 100.
So I'm not sure why I'm using P(A and B)

13. Jul 3, 2011

### I like Serena

Good!
And more in general: [itex]P(X > x) = e^{-\lambda x}[/tex]

Yes, only one needs to be greater than 100.
But this means there are 3 cases that overlap: either T1 can be greater than 100, or T2 can be greater than 100, or both can be greater than 100.
I guess I was a little sloppy with this before.

A little sharper is, that they cannot both be less than 100.

Do you know how to calculate the corresponding probability?

14. Jul 3, 2011

### Maybe_Memorie

Is it P(A) + P(B) + P(A and B)
where A = T1 > 100
B = T2 > 100

15. Jul 3, 2011

### I like Serena

Almost. ;)
The proper formula is (sum rule): P(A or B) = P(A) + P(B) - P(A and B)

16. Jul 3, 2011

### Maybe_Memorie

So the probability is (2e-1)/e^2

Is this correct?

How does this relate to the cdf?

17. Jul 3, 2011

### I like Serena

Yes, this is correct.
You just found the probability for Ts to be greater than 100.

Can you generalize for Ts greater than some x?

And then the cdf(x) for Ts is the probability that Ts is less than x.
Can you calculate that?

18. Jul 3, 2011

### Maybe_Memorie

P(Ts>x) = 2e^(-Ax) - e^(-2Ax)

so CDF = 1 - 2e^(-Ax) + e^(-2Ax)

PDF = -2Ae^(-2Ax) + 2Ae^(-Ax)

E[X] = 3/2A

Is this correct?

19. Jul 3, 2011

### I like Serena

I believe so!

Did you really have to do this for high school?
It seems to be a bit out of its scope.

20. Jul 3, 2011

### Maybe_Memorie

Thank you so much!

I'm not in high school, I'm in university in Ireland.
Due to various personal reasons I was unable to attend lectures, failed the statistics exam and now have to sit another stats exam in August to be allowed to progress to second year. so I'm going through all the exam papers and coming here with the ones I'm having difficulty with.