Expectation of function of random variable

conditional-expectationexpected valueprobability

Let $X_1$ and $X_2$ be two independent identically distributed random variables with range $[0,100]$. And let $ g(X_1) =X_1$ for $X_1>c$ and $g(X_1) =X_2$ for $X_1<c$ where $c$ is a constant.

What would be the Expectation of $g(X_1)$. This is what I have tried so far using the law of total expectation I get
\begin{align}
E[g(X_1)]&=E[g(X_1) |X_1>c] P(X_1>c) +E[g(X_1) |X_1<c]P(X_1<c)\\
&=E[X_2] P(X_1>c) +E[X_1|X_1<c]P(X_1<c)
\end{align}

The rest can be computed given the probability distribution. What I don't understand is the justification of this? Does law of expectation remain valid for this even though the output of the function is not a random variable but two random variables. I have only seen this law applied if it just depends on one random variable not two so I am not sure about this.

Best Answer

A better way (without assuming that $0<\mathsf{P}(X_1>c)<1$) would be writing the expectation of $Z\equiv X_21\{X_1\le c\}+X_11\{X_1>c\}$ as \begin{align} \mathsf{E}Z&=\mathsf{E}[X_21\{X_1\le c\}]+\mathsf{E}[X_11\{X_1>c\}] \\ &=\mathsf{E}[X_2]\mathsf{P}(X_1\le c)+\mathsf{E}[X_11\{X_1>c\}]. \end{align}

Related Question