# Notation and explanation for certain conditional random variables

This is a two part question. I apologize if the title and tags are vague. Please edit if a more suitable title or tags are appropriate.

## Part 1

Ok, so if $X$ and $Y$ are independent, continuous random variables with range $\mathbb{R}$, then we can write (assuming pdfs exist):

\begin{align*} P(Y \gt X) &= \int_{\{(x,y) \in \mathbb{R}^2 : \; y \gt x\}} p_{X,Y}(x,y) \; dx dy \\ &= \int_{-\infty}^{\infty} \int_{-\infty}^y p_X(x)p_Y(y) \; dx dy \\ &= \int_{-\infty}^{\infty} P_X(X \leq y) \; p_Y(y) \; dy \\ &= E_Y[P(X \lt Y|Y)] \end{align*}

Is the last step valid, and how would one read this out loud / explain it intuitively?

## Part 2

Next, take $Y$ to be Bernoulli with range $\{0, 1\}$ and $X$ with the same range as before. However, $X$ and $Y$ are now not independent. I want to consider the distributions, $X|Y=0$ and $X|Y=1$, and proceed like the previous case with $X|Y=0$ taking the place of $X$ and $X|Y=1$ taking the place of $Y$, but I'm kind of lost in notation and understanding.

1. How do we write that $X|Y=1$ is independent of $X|Y=0$? What is the notation for the joint distribution?
2. Does it even make sense that $X|Y=1$ and $X|Y=0$ could be independent? In words, it seems like it's feasible: the distribution of the value of $X$ given that $Y=1$ might not tell you anything about the distribution of the value of $X$ given that $Y=0$.
3. $P(X|Y=1 \gt X|Y=0)$ seems horribly confusing. What is the notation for this?

### Edit: update for Part 2

What I wrote for part was gibberish. So let me update with what my intentions were.

Consider four random variables: $X_1,X_2,Y_1,Y_2$. The ranges of $X_1$ and $X_2$ are both $\mathbb{R}$, while the ranges of $Y_1$ and $Y_2$ are both $\{0,1\}$. Similar to Part 1, I am interested in computing:

$$P(X_1 > X_2 | Y_1=1,Y_2=0)$$

I was curious what assumptions on the $X_1,X_2,Y_1,Y_2$ allow for a similar calculation. It turns out that we must have both that $(X_1,Y_1)$ is independent of $(X_2,Y_2)$ and $Y_1$ is independent of $Y_2$. Under these assumptions,

$$P(X_1 > X_2 | Y_1=1,Y_2=0) = \int_{\mathbb{R}} P(X_2 \lt x_1 | Y_2=0) p(x_1|Y_1=1) dx_1$$

• In Part 2 (2), there must be a typographical error. In Part 2 (3), yes it's horribly confusing--what do you mean? – whuber Aug 11 '15 at 0:58
• Unfortunately, there is no random variable defined as $X|Y=1$. So the whole Part 2 does not make sense within probability theory. – Xi'an Nov 1 '15 at 14:21
• @Xi'an yes, my part 2 was not well thought-out. I've clarified what I intended in the edit above. – Chester Nov 1 '15 at 15:31

Part 1: this is valid, and it would be entirely reasonable to go directly to the last equality, as you are basically rederiving a special case of the law of total expectation. Recall that for random variables $A$ and $B$ we can write $\text{E}(A) = \text{E}[\text{E}(A \mid B)]$. Since probabilities can themselves be viewed as expectations your equation follows from this.
Part 2: you're not being very clear about the underlying probability model, so it's difficult to answer this. In particular, what does it mean to talk about $X \mid (Y = 0)$ and $X \mid (Y = 1)$ being independent? Are we sampling $X$ under the condition that $Y = 1$, and then taking another realization of $X$ under the event $Y = 0$? These random variables could be either dependent or independent, regardless of the joint distribution of $X$ and $Y$. But, I suspect that this isn't what you mean.
• Basically, I want to apply the result of Part 1 to the random variables $X|Y=0$ and $X|Y=1$ in place of $X$ and $Y$ in Part 1 respectively (overloading variable names, sorry). You are correct in your interpretation: I'm interested in the probability that a realization of the value of $X$ given $Y=1$ is larger than a realization of the value of $X$ given that $Y=0$. To this end, I need to consider (in)dependence of these random quantities, which I think coincides with your last couple of sentences. – Chester Aug 11 '15 at 3:24
• I guess I'm just caught up on notation. Usually, we just say two random vars, $A$ and $B$, are independent if $P(A,B) = P(A)P(B)$. In this case, $A:=X|Y=1$, $B:=X|Y=0$. Is there a nice or accepted way of writing that these quantities are independent? – Chester Aug 11 '15 at 3:27
• Hmm. I'm not sure what you mean by that last equality, or where the RHS comes from. Let me try to be more clear: $X$ is a continuous rv. $Y$ is Bernoulli. Define the new rv's, $A = X|(Y=1)$ and $B = X|(Y=0)$. This is a valid thing to do, no? From Part 1, $P(A \gt B) = E[ P(A \gt B |A) ]$. I'm simply asking how this can be written without introducing the new variables, $A$ and $B$? Furthermore, I'm asking how to write the intermediate steps without introducing $A$ and $B$, as well. – Chester Aug 11 '15 at 13:06
• Ok, I misread the post and thought $X$ was also Bernoulli. I'll repost a corrected comment. – dsaxton Aug 11 '15 at 13:19
• If you want to apply the idea from the first part (which by the way should probably use the notation $E[P(X<Y \mid Y)]$; $P_X(X \leq Y)$ doesn't make a lot of sense) then you would write this expectation as $P(Y=1)P(X<Y \mid Y=1)+P(Y=0)P(X<Y \mid Y=0)$. We aren't introducing any new r.v.'s here, everything is in terms of $X$ and $Y$. – dsaxton Aug 11 '15 at 13:20