The problem is given as : - Let the random variable $\mathrm{X}$~$\textrm{Uniform}[0,10]$. Find $\ \textrm{Var[max}(2,min(4,\mathrm{X}))]$.
Here $\textrm{Var}$ denotes variance of $\mathrm{X}$.
My problem is I am stuck at the calculation of $\mathbb{E}{\mathrm{(Y)}}$ and $\mathbb{E}{\mathrm{(Y^2)}}$
• The problem I tried to solve in the following way-
$min(4,\mathrm{X})=\begin{cases} 4 \text{ when } X \geq4 \\ \mathrm{X} \textrm{ when } \mathrm{X}<4 \end{cases}$
$\mathrm{Y}=\textrm{max}(2,min(4,\mathrm{X})) \\ =\begin{cases} \textrm{max}(2,4) \text{ when } \mathrm{X} \geq4 \\ \textrm{max}(2,X) \text{ when } \mathrm{X} <4 \end{cases}\\ = \begin{cases} 4 \text{ when } \mathrm{X} \in [4,10] \\ \mathrm{X} \text{ when } \mathrm{X} \in (2,4) \\ 2 \text{ when } \mathrm{X} \in [0,2]\end{cases}\\ = \begin{cases} 2 \text{ with probability } 0.2 \\ \mathrm{X} \text{ with probability } 0.2 \\ 4 \text{ with probability } 0.6 \end{cases}$
$$\mathbb{E}{\mathrm{(Y)}}\\=\mathbb{E}[2 | Y = 2] \mathbb{P}[\mathrm{Y} = 2] + \mathbb{E}[\mathrm{X} | \mathrm{Y = X}] \mathbb{P}[\mathrm{Y = X}] + \mathbb{E}[4 | Y = 4] \mathbb{P}[Y = 4] \\ \longrightarrow(i)$$
I am not sure how to proceed further from $(i)$, hence cannot calculate the $\mathbb{E}{\mathrm{(Y)}}$. And following this problem cannot even calculate $\mathbb{E}{\mathrm{(Y^2)}}$.
Although I know that I have to use the formula -
$$\mathbb{E}{\mathrm{(Y^2)}}\\=\mathbb{E}[2^2 | Y = 2] \mathbb{P}[\mathrm{Y} = 2] + \mathbb{E}[\mathrm{X^2} | \mathrm{Y = X}] \mathbb{P}[\mathrm{Y = X}] + \mathbb{E}[4^2 | Y = 4] \mathbb{P}[Y = 4] \ \longrightarrow(ii)$$
But again after writing the law of total expectation formula, I cannot think how to proceed from $(ii)$.
Therefore, any help, explanation or suggestion regarding
• how should I calculate $\mathbb{E}{\mathrm{(Y)}}$ and $\mathbb{E}{\mathrm{(Y^2)}}$ is very much helpful, appreciated and valuable to me.
- Also I'd like to understand if this random variable represents a piecewise continuous or a mixed kind of random variable. Thank you in advance.
You see that $Y$ is just a function of $X$. So you compute the expectation in the usual way you do for function. i.e. if $X$ has distribution(pdf) $f$ , then $E(g(X))=\int g(x)f(x)\,dx$
$\displaystyle E(Y)=\int \max(2,\min(4,x))\,f(x)\,dx=\int_{0}^{10}\max(2,\min(4,x))\cdot\frac{1}{10}\,dx$
Now it becomes a high school calculus problem. You have already solved it partially since you have already figured out that $\max(2,\min(4,x))=\begin{cases} 4 \text{ when } x \in [4,10] \\ x \text{ when } x \in (2,4) \\ 2 \text{ when } x \in [0,2]\end{cases}\\$
In particular, $\displaystyle E(Y)=\int_{0}^{2}\frac{2}{10}\,dx+\int_{2}^{4}\frac{x}{10}\,dx+\int_{4}^{10}\frac{4}{10}\,dx$
Now it should not be easy for you to integrate this function above over $0$ to $10$ like you did in highschool.
You cannot really condition on anything here . In particular $E(Y|X)=Y$ which yields nothing. And needless to say as Brian also points out in the comments, all the conditioning and all the lines that succeed it are just non-sense.
Similarly, find $\displaystyle E(Y^{2})=\int_{0}^{10}\bigg(\max(2,\min(4,x))\bigg)^{2}\cdot\frac{1}{10}\,dx$
$$=\int_{0}^{2}\frac{2^{2}}{10}\,dx+\int_{2}^{4}\frac{x^{2}}{10}\,dx+\int_{4}^{10}\frac{4^{2}}{10}\,dx$$
and compute the variance by $E(Y^{2})-(E(Y))^{2}$
Addendum: If you really want to use conditional probability and total probability then do it like this $E(Y)=E(2|X\leq 2)P(X\leq 2)+E(X| 2\leq X\leq 4)P(2\leq X\leq 4)+E(4|X\geq 4)P(X\geq 4)$. Now some justification has to be given as to why conditioned on $2\leq X\leq 4$, $X$ has $\text{Uniform}[2,4]$ distribution but it should be intuitive enough. If you now compute the above expression, you should end up with the expression we deduced by directly computing using the density. Note that I am condtioning on specific events. Conditioning on $X$ gives a fixed value of $Y$ which is not "random".