# Why is independent condition needed in $Pr(X=Y)=0$

I know that if $$X,Y$$ are independent random variables then $$Pr(X=Y)=0$$. It kind of make sense to me to ask for independence since $$Pr(X=X)=1$$. I know the proof of this when $$X,Y$$ are discrete but when trying to prove it for continuous independent variables I came out with the fact that I don't need independence. This is offcourse wrong but I can't find my mistake. I will leave my "proof" here so you guys can point the mistake out:

The fake proof:

$$Pr(X=Y)=Pr((X,Y)\in \{(x,y):x=y\})=\underset{\{(x,y):x=y\}}\iint f_{X,Y}(x,y)\;dx\;dy$$ $$= \int_x^x \int_{-\infty}^\infty f_{X,Y}(x,y)\;dx\;dy \underbrace{=}_{\text{Fubini}} \int_{-\infty}^\infty \int_x^x f_{X,Y}(x,y)\;dy\;dx=0$$

I can kind of guess that my mistake might be somewhere near the word "Fubini" because, probably, I'm missing the right hipotesis for use this theorem. Also, I'd say that it should be important to use te fact that $$f_{X,Y}=f_X f_Y$$ since $$X \perp Y$$, but I still don´t get it.

• Independence of random variables $X$ and $Y$ does not imply that $P(X=Y)=0$. We can even have $P(X=Y)=1$ in that situation. This if $P(X=c=Y)=1$ for some constant $c$. Also if there are two independent tosses of a coin where $X$ denotes the number of heads by first and $Y$ by second toss then $X$ and $Y$ are independent but not with $P(X=Y)=0$. – drhab Feb 22 at 14:05
• Ok... So what I can guess from your comment and @drhab 's comment is that in your example $X$ and $Y$ have no PDFs, is this right? – Natalio Feb 22 at 16:15

If $$X,Y$$ have a common PDF $$f_{X,Y}$$ then $$P(X=Y)=0$$.

For this we do not need independence.

If $$[x=y]=1$$ if $$x=y$$ and $$[x=y]=0$$ otherwise then:$$P(X=Y)=\mathbb E[X=Y]=\int\int[x=y]f_{X,Y}(x,y)\;dx\;dy=\int0\;dy=0$$

Things are different if $$X,Y$$ have a common PMF $$p_{X,Y}$$.

In that case: $$P(X=Y)=\mathbb E[X=Y]=\sum_{(x,y)\in S}[x=y]p_{X,Y}(x,y)=\sum_{(z,z)\in S}p_{X,Y}(z,z)$$where $$S$$ denotes the countable set $$\{(x,y)\in\mathbb R^2\mid p_{X,Y}(x,y)>0\}$$.

If $$X$$ and $$Y$$ are moreover independent and have PMF $$p_X$$ and $$p_Y$$ respectively then $$S=S_X\times S_Y$$ where $$S_X=\{x\in\mathbb R\mid p_X(x)>0\}$$ and $$S_Y=\{y\in\mathbb R\mid p_Y(y)>0\}$$ .

So in that case we have:$$P(X=Y)=\mathbb E[X=Y]=\sum_{z\in S_X\cap S_Y}p_{X}(z)p_Y(z)$$ where the RHS is positive if $$S_X\cap S_Y\neq\varnothing$$.

• So what you are saying is that my proof was right if $X,Y$ are independent and each has a density beacuse in this case the common PDF is the product? – Natalio Feb 22 at 16:14
• What I am saying is that independence is not necessary in the continuous case. It is enough then for $X,Y$ to have a common PDF $f_{X,Y}$. Further that independence is not sufficient in the discrete case: If $S_X\cap S_Y\neq\varnothing$ then $P(X=Y)>0$. – drhab Feb 22 at 16:19
• It is quite well possible though that $X$ and $Y$ are continuous random variables that do not have a common PDF. This e.g. if $X$ of them is a continuous random variable and $Y=f(X)$ for some function $f$. In your "fake proof" you preassumed the existence of a PDF, so it leaded you to $P(X=Y)=0$. – drhab Feb 22 at 16:27