# If $Z=X$ on $A$ and $Z=Y$ on $A^c$ then $Z$ is a random variable

Let $X$ and $Y$ be random random variables and let $A \in \mathcal{B}$. Prove that the function $Z$ defined by $$Z(\omega)=\begin{cases} X(\omega),& \text{ if } \omega \in A \\ Y(\omega),& \text{ if } \omega \in A^{c} \end{cases}$$ is a random variable

Proof so far: $$Z^{-1}((-\infty,a])=\{\omega:Z(\omega)\geq a\}=\{\omega: Z(\omega)\geq a, \omega \in A\}\cup\{\omega: Z(\omega)\leq a, \omega \in A^{c}\}=Y^{-1}[a,\infty) \cup X^{-1}([a,\infty))$$ So $Z$ is measurable

• Every single equality is wrong, please take your time and rework the details of your proof. – Dominik Sep 23 '15 at 16:39
• It might be worth mentioning once again, since the accepted answer wrongly claims that the proof in the question is correct modulo some small typos, that the identity $$Z^{-1}((-\infty,a])=Y^{-1}[a,\infty) \cup X^{-1}([a,\infty))$$ is actually squarely wrong, as would be the identity $$Z^{-1}([a,\infty))=Y^{-1}([a,\infty)) \cup X^{-1}([a,\infty))$$ – Did Nov 27 '15 at 10:15

Let $X, Y$ be random variables in $(\Omega, \mathcal B, \mathbb P)$.

If $A \in \mathcal B$, then $1_A$ and $1_{A^C}$ are random variables.

Note that

$$Z = X1_A + Y1_{A^C}$$

Since sums or products of random variables in $(\Omega, \mathcal B, \mathbb P)$ are random variables in $(\Omega, \mathcal B, \mathbb P)$, $Z$ is a random variable in $(\Omega, \mathcal B, \mathbb P)$.

As for your proof, I think you should say:

1. $\forall a \in \mathbb R$

2. have $Z \ge a$ instead of $Z \le a$

3. $Z$ is $\mathcal B$-measurable

Let $B$ be a borel set then $$Z^{-1}(B)=[Z^{-1}(B)\cap A] \cup [Z^{-1}(B)\cap A^{c}]=[X^{-1}(B)\cap A] \cup [X^{-1}(B)\cap A^{c}]$$ By the property of $\sigma$ field we see that $Z$ is a random variable

• @Dominik check out my solution – Josh Sep 24 '15 at 13:34
• Josh, I don't think Dominik was notified because he didn't edit or comment on this post. Looks okay. Pretty much the same as the one you gave in OP (by uniqueness lemma) I guess. I think you can omit the A's at the end but should replace 1 of the X's with a Y – BCLC Nov 26 '15 at 23:57