# Thread: Expected value of normal function (conditional)

1. ## Expected value of normal function (conditional)

Hi Guys

I am trying to find the expected value of Y given that Y>0 and Y ~ N(-3,16)

The answer I get is not reasonable so I am trying to work out where I went wrong.

$\displaystyle E(x) = \frac{1}{1-Fy(0)}\int_{0}^{+\infty}xfy(x)\,dx$

$\displaystyle Now, evaluating \int_{0}^{+\infty}xfy(x)\,dx = \int_{0}^{+\infty}\frac{x}{4\sqrt{2\pi}}\,e^-1/2(\frac{x+3}{4})^2\, dx$

I used integration using substitution, using z = (x+3)/4 and after splitting up the integral, arrived at an integral (between 3/4 and infinity) minus 2 * P(Z>3/4)

After working out the value for E(x) I get a negative number.

Any help would be appreciated,

Thanks,

Thomas

2. Originally Posted by tompa909
Hi Guys

I am trying to find the expected value of Y given that Y>0 and Y ~ N(-3,16)

The answer I get is not reasonable so I am trying to work out where I went wrong.

$\displaystyle E(x) = \frac{1}{1-Fy(0)}\int_{0}^{+\infty}xfy(x)\,dx$

$\displaystyle Now, evaluating \int_{0}^{+\infty}xfy(x)\,dx = \int_{0}^{+\infty}\frac{x}{4\sqrt{2\pi}}\,e^-1/2(\frac{x+3}{4})^2\, dx$

I used integration using substitution, using z = (x+3)/4 and after splitting up the integral, arrived at an integral (between 3/4 and infinity) minus 2 * P(Z>3/4)

After working out the value for E(x) I get a negative number.

Any help would be appreciated,

Thanks,

Thomas
$\displaystyle Y(Y | Y > 0) = \int_{-\infty}^{+\infty} y \, f(y | Y > 0) \, dy = \int_{0}^{+\infty} y \, \frac{f(y)}{\Pr(Y > 0)} \, dy = \frac{\int_{0}^{+\infty} y \, f(y) \, dy}{\Pr(Y > 0)}$

where f(y) is the pdf for Y.

Use technology to calculate $\displaystyle \Pr(Y > 0)$ and $\displaystyle \int_{0}^{+\infty} y \, f(y) \, dy$.

I still wish to work out the integral by hand though.

$\displaystyle P(Y>0)$ is easy to work out however I am making a mistake somewhere in the process of solving the integral for the expected value of the normal function between 0 and infinity.

4. Originally Posted by tompa909

I still wish to work out the integral by hand though.

$\displaystyle P(Y>0)$ is easy to work out however I am making a mistake somewhere in the process of solving the integral for the expected value of the normal function between 0 and infinity.
Unless you're willing to use the Error Function, Pr(Y > 0) cannot be done by hand.

Show the details of your calculation of the integral $\displaystyle \int_{0}^{+\infty} y \, f(y) \, dy$.

5. Ok, I am allowed to standardize P(Y>0) and get the probability using Z-tables.

With the integral I have,

$\displaystyle \int_{0}^{+\infty} y \, \frac{1}{4\,\sqrt{2\pi}} \, e^{-\frac{1}{2}(\frac{y+3}{4})^2} \, dy$

Using substitution z = (y+3)/4, we get y = 4z-3 dy = 4dz

$\displaystyle \int_{3/4}^{+\infty} \, \frac{4z-3}{\sqrt{2\pi}} \, e^{-\frac{1}{2}z^2} \, dz$

$\displaystyle \int_{3/4}^{+\infty} \, \frac{4z}{\sqrt{2\pi}} \, e^{-\frac{1}{2}z^2} \, dz \, - \int_{3/4}^{+\infty} \, \frac{3}{\sqrt{2\pi}} \, e^{-\frac{1}{2}z^2} \, dz$

$\displaystyle \frac{4}{\sqrt{2\pi}}\int_{3/4}^{+\infty} \, z \, e^{-\frac{1}{2}z^2} \, dz \, - 12\int_{3/4}^{+\infty} \, \frac{1}{4\sqrt{2\pi}} \, e^{-\frac{1}{2}z^2} \, dz$

$\displaystyle \frac{4}{\sqrt{2\pi}} \, (-e^{-\frac{1}{2}(+\infty)^2}--e^{-\frac{1}{2}(\frac{3}{4})^2}) - 12 * P(Z > 3/4)$

$\displaystyle \frac{4}{\sqrt{2\pi}} \, (0.75484) - 12 * 0.2266$

Thus
$\displaystyle \int_{0}^{+\infty} y \, \frac{1}{4\,\sqrt{2\pi}} \, e^{-\frac{1}{2}(\frac{y+3}{4})^2} \, dy = -1.51465$

Going back to original question

$\displaystyle E(Y|Y>0) =$
$\displaystyle \frac{\int_{0}^{+\infty} y \, f(y) \, dy}{\Pr(Y > 0)}= \frac{-1.51465}{P(Y>0)} = \frac{-1.51465}{P(Z>3/4)} =\frac{-1.51465}{0.2266} = -6.68425$

6. Originally Posted by tompa909
Ok, I am allowed to standardize P(Y>0) and get the probability using Z-tables.

With the integral I have,

$\displaystyle \int_{0}^{+\infty} y \, \frac{1}{4\,\sqrt{2\pi}} \, e^{-\frac{1}{2}(\frac{y+3}{4})^2} \, dy$

Using substitution z = (y+3)/4, we get y = 4z-3 dy = 4dz

$\displaystyle \int_{3/4}^{+\infty} \, \frac{4z-3}{\sqrt{2\pi}} \, e^{-\frac{1}{2}z^2} \, dz$

$\displaystyle \int_{3/4}^{+\infty} \, \frac{4z}{\sqrt{2\pi}} \, e^{-\frac{1}{2}z^2} \, dz \, - \int_{3/4}^{+\infty} \, \frac{3}{\sqrt{2\pi}} \, e^{-\frac{1}{2}z^2} \, dz$

$\displaystyle \frac{4}{\sqrt{2\pi}}\int_{3/4}^{+\infty} \, z \, e^{-\frac{1}{2}z^2} \, dz \, - 12\int_{3/4}^{+\infty} \, \frac{1}{4\sqrt{2\pi}} \, e^{-\frac{1}{2}z^2} \, dz$ *

$\displaystyle \frac{4}{\sqrt{2\pi}} \, (-e^{-\frac{1}{2}(+\infty)^2}--e^{-\frac{1}{2}(\frac{3}{4})^2}) - 12 * P(Z > 3/4)$

$\displaystyle \frac{4}{\sqrt{2\pi}} \, (0.75484) - 12 * 0.2266$

Thus $\displaystyle \int_{0}^{+\infty} y \, \frac{1}{4\,\sqrt{2\pi}} \, e^{-\frac{1}{2}(\frac{y+3}{4})^2} \, dy = -1.51465$

Going back to original question

$\displaystyle E(Y|Y>0) =$
$\displaystyle \frac{\int_{0}^{+\infty} y \, f(y) \, dy}{\Pr(Y > 0)}= \frac{-1.51465}{P(Y>0)} = \frac{-1.51465}{P(Z>3/4)} =\frac{-1.51465}{0.2266} = -6.68425$

In the line marked * why do you have $\displaystyle 12 \int_{3/4}^{+\infty} \, \frac{1}{{\color{red}4}\sqrt{2\pi}} \, e^{-\frac{1}{2}z^2} \, dz$ ? This is NOT equal to 12 Pr(Z > 3/4).

You should have left it as $\displaystyle 3 \int_{3/4}^{+\infty} \, \frac{1}{\sqrt{2\pi}} \, e^{-\frac{1}{2}z^2} \, dz = 3 \Pr(Z > 3/4)$.

Then you'll get the correct answer.

7. Thanks heaps for your help, that worked perfectly

Best Regards

Thomas

8. Originally Posted by tompa909
Thanks heaps for your help, that worked perfectly

Best Regards

Thomas