# How to calculate an expected value of maximum random variable function

1. Let $X \sim U(0,1)$
$Y=\max(X,0.5)$
$Z=\max(X-0.5,0)$
$W=\max(0.5-X,0)$

ask how to calculate $E(Y)$, $E(Z)$, $E(W)$

-
Hint: $$E[g(X)] = \int_{-\infty}^{\infty} g(x)f_X(x)\mathrm dx$$ where you have been told what $f_X(x)$ is. Sketch the function $g(x) = \max(x,0.5)$ and the function $f_X(x)$, and then the function $g(x)f_X(x)$. Compute the integral above to get $E[Y] = E[\max(X,0.5)]$. Lather, rinse, repeat for the functions $\max(X-0.5,0)$ and $\max(0.5-X,0)$. – Dilip Sarwate Mar 2 '12 at 12:19
@Dilip: +1 for Lather, rinse, repeat. – Did Mar 2 '12 at 12:28
@Dilip Given that my probability exam just was over a few hours back, if not for your comment, I am a goner. I did not realise I had this tool at disposal! – user21436 Mar 2 '12 at 13:01
@KannappanSampath I call this tool LOTUS (an initialism of Law of the Unconscious Statistician) which helps jog my memory just when I need it most.... – Dilip Sarwate Mar 2 '12 at 13:10
@DilipSarwate Now I think I'll remember this rule better. Once again, Thank you for telling me! – user21436 Mar 2 '12 at 13:12

Written to elaborate the already explanatory comment of Dilip Sawarte

Let $X$ be a random variable uniformly distributed on $(0,1)$. This means that $$g_X(x)=1 ~~\text{for}~~ x \in (0,1)$$

We are interested in the expectation of the random variable, $Y=\max\left(X,\dfrac{1}{2}\right)$.

Now, note that \begin{align}\mathbb E(f(X))&=\int_{-\infty}^\infty f(x)g_X(x) \rm{d}x\\&=\int_{0}^1f(x)\mathrm dx\\&=\int_0^{\frac 1 2}\dfrac{1}{2}\mathrm dx+\int_{\frac 1 2}^1x~~\rm dx\\&=\dfrac 1 4+\dfrac 1 2-\dfrac 1 8\\&=\dfrac 5 8\end{align}

Similarly other integrals can be evaluated.

I'll leave only the answers in case you needed to check:

For (b) $\dfrac{1}{8}$

For (c) $\dfrac{1}{8}$

As Dilip Sawarte points out, some graphs you'll find useful are:

for (a):

$\hspace{1 in}$

for (b):

$\hspace{1 in}$

for (c):

$\hspace{1 in}$

Note that the area of the shaded region is the expectation you're in need of!

-
Yes, true. I'll add that in. But, given that the OP is doing Continuous random variable, he should know integration as well! – user21436 Mar 2 '12 at 13:16
@Dilip I added the graphs. Thank you for the pointer. – user21436 Mar 2 '12 at 15:05
@Dilip Thanks for the pointer. GeoGebra does not allow the change AFAIK, so I should probably change the previous terminology. – user21436 Mar 2 '12 at 15:43

Consider using the formula below with $T$ being the statement that $X>0.5$,

$$\mathbb{E}(X)=P(T)\;\mathbb{E}(X \;|\; T)+P(\text{not } T)\; \mathbb{E}(X \;|\; \text{not }T).$$

For example, for the first case we have

$$\mathbb{E}(Y)=(1/2)\; (3/4)+(1/2)\; (1/2)=5/8.$$

-