# Expected value from graph

#### tkhunny

##### Moderator
Staff member
Hi. I'm trying to calculate the expected value of X using this graph and I'm really struggling for some reason. Can anyone please help?
View attachment 10760
The probability density function should go like this (my calculation):
-0.1x-0.5 for x=(-9;-7)
0.2 for x=(-7;-5)
Calculus? Don't really need it. Just wondering.

Definition? Sum x * p(x) over all x.

Last edited:

#### Stripey

##### New member
Calculus? Don't really need it. Just wondering.

Definition? Sum x * p(x) over all x.
This is f(x) (continuous function), that's the problem. Integrals will be necessary

#### tkhunny

##### Moderator
Staff member
This is f(x) (continuous function), that's the problem. Integrals will be necessary
Well, if you can use the integral, please show it. It's okay if it's piecewise.

#### tkhunny

##### Moderator
Staff member
Well, I tried to calculate the EV for -0.1x-0.5 for x=(-9;-7) separately:

View attachment 10761
but the answer is -4.86 which is obviously wrong.
Why is that obviously wrong? [-9,-7] is NOT a Probability Distribution. Keep working until you've covered the whoie distribution.

For the record, if you gross up the partial you did, you may be happier with the interim and partial result. -4.86 / 0.6 = -8.1 and you probably feel better about that. Don't let this distract you from the actual problem.

#### Stripey

##### New member
Why is that obviously wrong? [-9,-7] is NOT a Probability Distribution. Keep working until you've covered the whoie distribution.

For the record, if you gross up the partial you did, you may be happier with the interim and partial result. -4.86 / 0.6 = -8.1 and you probably feel better about that. Don't let this distract you from the actual problem.
So if EV of "0.2 for x=(-7;-5)" is -6, how do I work out the final result? By the way, -8.1 makes sense. Where did you get that 0.6 from?

#### Jomo

##### Elite Member
So if EV of "0.2 for x=(-7;-5)" is -6, how do I work out the final result? By the way, -8.1 makes sense. Where did you get that 0.6 from?
What is the area under the curve from -9 to -7? Please don't bother with integration as it is a simple trapezoid that you have.

Last edited:

#### JeffM

##### Elite Member
EDIT

I have deleted my original answer because tkhunny is correct that I had lost sight of the fact that the problem is to calculate an expected value rather than a pdf.

Last edited:

#### tkhunny

##### Moderator
Staff member
So if EV of "0.2 for x=(-7;-5)" is -6, how do I work out the final result? By the way, -8.1 makes sense. Where did you get that 0.6 from?
Two things:

1) I told you not to be distracted by that. Let it go and complete the integrals.

2) The other contributors seem to have missed that we need the expected value, not the area. It's a probability distribution. It should sum to unity. It's always a good idea to check that. Since we need the expected value, you'll need the Center of Mass of the trapezoid, not just it's area. Again, you don't NEED the calculus, but you'll have to pull that formula out of your hat.

#### Harry_the_cat

##### Senior Member
Well, I tried to calculate the EV for -0.1x-0.5 for x=(-9;-7) separately:

View attachment 10761
but the answer is -4.86 which is obviously wrong.
You now have to find integral(from -7 to -5) of (0.2)*x , for the other part of the pdf, and add it on. (I'm being lazy with LaTex - hey it's NYE!!)

#### Stripey

##### New member
You now have to find integral(from -7 to -5) of (0.2)*x , for the other part of the pdf, and add it on. (I'm being lazy with LaTex - hey it's NYE!!)
This is the other issue. On (-7, -5) it's uniform distribution, but when I use the formula fot its EV: E(X) = (a+b)/2, the result is -6 (which seems logical), whereas if I use integral the same way as with the first part of the pdf, the answer is -2.4. Why is that?

#### JeffM

##### Elite Member
This is the other issue. On (-7, -5) it's uniform distribution, but when I use the formula fot its EV: E(X) = (a+b)/2, the result is -6 (which seems logical), whereas if I use integral the same way as with the first part of the pdf, the answer is -2.4. Why is that?
Formulas are dangerous. Definitions are your friend.

The definition of a uniform distribution is that its probability density function is

$$\displaystyle f(x) = \dfrac{1}{b - a} \text { if } a \le x \le b \text { and } f(x) = 0 \text { otherwise.}$$

$$\displaystyle -\ 5 - (-\ 7) = 2 \implies \dfrac{1}{-\ 5 - (-\ 7)} = \dfrac{1}{2} = 0.5 \ne 0.2 = f(x).$$

In other words, you are not dealing with a uniform distribution. So you are not using a formula that is relevant.

$$\displaystyle g(x) = 0.5 \text { if } -\ 7 \le x \le -\ 5 \implies$$

$$\displaystyle \displaystyle \int_{-7}^{-5} 0.5 * x \ dx = 0.25(-\ 5)^2 - 0.25(7^2) = \dfrac{25 - 49}{4} = \dfrac{-\ 24}{4} = -\ 6.$$

The formula works if you have a uniform distribution, but you can't just assume that a distribution is uniform. All uniform distributions are rectangular, but not all rectangular distributions are uniform.

#### tkhunny

##### Moderator
Staff member
This is the other issue. On (-7, -5) it's uniform distribution, but when I use the formula fot its EV: E(X) = (a+b)/2, the result is -6 (which seems logical), whereas if I use integral the same way as with the first part of the pdf, the answer is -2.4. Why is that?

#### Attachments

• 20.3 KB Views: 1
Last edited:

#### Stripey

##### New member
Formulas are dangerous. Definitions are your friend.

The definition of a uniform distribution is that its probability density function is

$$\displaystyle f(x) = \dfrac{1}{b - a} \text { if } a \le x \le b \text { and } f(x) = 0 \text { otherwise.}$$

$$\displaystyle -\ 5 - (-\ 7) = 2 \implies \dfrac{1}{-\ 5 - (-\ 7)} = \dfrac{1}{2} = 0.5 \ne 0.2 = f(x).$$

In other words, you are not dealing with a uniform distribution. So you are not using a formula that is relevant.

$$\displaystyle g(x) = 0.5 \text { if } -\ 7 \le x \le -\ 5 \implies$$

$$\displaystyle \displaystyle \int_{-7}^{-5} 0.5 * x \ dx = 0.25(-\ 5)^2 - 0.25(7^2) = \dfrac{25 - 49}{4} = \dfrac{-\ 24}{4} = -\ 6.$$

The formula works if you have a uniform distribution, but you can't just assume that a distribution is uniform. All uniform distributions are rectangular, but not all rectangular distributions are uniform.
Thank you, this is actually really helpful. Happy new year by the way

#### JeffM

##### Elite Member
Thank you, this is actually really helpful. Happy new year by the way
Happy New Year to you as well. Glad to have been of any help. Probability theory is not my strongest topic.

I just was warning you that relying on formulas is no substitute for attention to definitions and for logical thought.

But it is tkhunny who is trying very patiently to walk you through the logic of this kind of problem.

#### Stripey

##### New member
Happy New Year to you as well. Glad to have been of any help. Probability theory is not my strongest topic.

I just was warning you that relying on formulas is no substitute for attention to definitions and for logical thought.

But it is tkhunny who is trying very patiently to walk you through the logic of this kind of problem.
Oh I must have mistaken you two for each other (for the record, it was 1AM on New Year's Day ). The comment is meant for both of you then 