# $P(X>Y)$ for $X$, $Y$ not necessarily independent

I am interested in deriving an expression for the probability of a value $$X$$ being larger than a value $$Y$$. More specifically: I want to calculate an expression for $$P(X>Y|I)$$ and I know the probability densities $$P(X|I)$$ and $$P(Y|I)$$. The $$I$$ is some background knowledge I have concerning both variables.

Let us assume that $$X$$, $$Y$$ are real-valued and absolutely continuous values in $$(x_{min},x_{max})$$ and $$(y_{min},y_{max})$$ respectively. The intervals might be infinite,but do not have to be. Here is what I arrived at (steps shown at the end of the question):

$$P(X>Y|I) = \int_{x_{min}}^{x_{max}} dX \, P(X|I) \int_{y_{min}}^{\min(X,y_{max})} dY \, P(Y|X,I)$$

where the comma (,) notation means a logical and.

My questions

• Is this expression correct?
• What other assumptions about my $$X$$,$$Y$$ have I made that I am unaware of?

Calculation To arrive at the expression I wrote

$$\begin{eqnarray}P(X>Y|I) &=& \int_{x_{min}}^{x_{max}} dX \int_{y_{min}}^{y_{max}} dY \, P(X>Y,X,Y|I) \\ &=& \int_{x_{min}}^{x_{max}} dX \, \int_{y_{min}}^{y_{max}} dY P(X>Y|X,Y,I)\cdot P(Y|X,I)\cdot P(X|I) \end{eqnarray}$$ and now I can write $$P(X>Y|X,Y,I)=\theta(X-Y)$$ where $$\theta$$ is the step function. From this follows:

$$P(X>Y|I) = \int_{x_{min}}^{x_{max}} dX \, P(X|I) \int_{y_{min}}^{y_{max}} dY \, P(X|I) \cdot \theta(X-Y)\cdot P(Y|X,I)$$

Using the $$\theta$$ function to constrain the upper integration border, the expression above should follow... I hope.

Notes: Related Question on math/SE

I am aware of this related question on math/SE but I am specifically interested in an expression where $$X$$,$$Y$$ need not be independent.

• When it comes to your first question ("Is this expression correct?"), I would say yes. Commented Feb 13, 2020 at 7:51

Bayesian Inference for $$P(X Using Asymmetric Dependent Distributions