# show it is a random variable

Let X and Y be random variables and let A be an event. Show that the function $$Z(\omega)=\begin{cases}X(\omega) \quad \text{if} \; \omega \in A\\ Y(\omega) \quad \text{if} \; \omega \in A^c \end{cases}$$ is a random variable. I considered the case in which $Z(\omega)=I_A(\omega)$, where $$I_{A}(\omega)=\begin{cases}1 \quad \text{if} \; \omega \in A\\ 0 \quad \text{if} \; \omega \in A^c \end{cases}$$ since the indicator is a measurable function.

Is my intuition correct?

Many thanks

• So the whole question is how you know the piecwise function is measurable? – Michael Hardy Oct 15 '13 at 22:59
• Hint: try to write $Z$ as a polynomial in $X$, $Y$ and $I_A$. – Alexander Shamov Oct 15 '13 at 23:05

If $A$ is measurable, then the indicator function $1_A$ is measurable.
Sums and products of measurable functions are measurable, hence $Z = X \cdot 1_A + Y \cdot 1_{A^c}$ is measurable.