# Determining the probability of $X_2 \ge X_1$ given they have different probability functions

Suppose that I have a random variable $X_1$ which is normally distributed, and a random variable $X_2$ having the density function shown in the figure below. How would I determine ${\rm P}(X_1 \le X_2)$? • In the absence of any information about the joint distribution of $X_1$ and $X_2$, you can make the answer work out to be almost anything you like. – Dilip Sarwate Mar 22 '14 at 12:44
• @DilipSarwate Thank you. Yes, since they are independent there isn't any information on their Joint Distribution. I was thinking of just subtracting the Area associated with ${\rm P}(X_2)$ from that associated with ${\rm P}(X_1 \le X_2)$. I know that you said I could do anything, but does this sound reasonable enough? – user131983 Mar 22 '14 at 12:49
• If they are independent, you know their joint distribution if you know their marginal distributions. $P(X_1\leq t, X_2\leq s)=P(X_1 \leq t)P(X_2 \leq s)$. – ekvall Mar 22 '14 at 13:31

Assuming that random variables $X_1$ and $X_2$ have joint density $f_{X_1, X_2}$ and marginal densities $f_{X_1}$ and $f_{X_2}$, we have $$P(X_1 \leq X_2) = \int_{-\infty}^{\infty}\int_{-\infty}^{x_2} f_{X_1, X_2} (x_1, x_2) dx_1 dx_2 .$$ If the two random variables are independent, the probability is \begin{align*} P(X_1 \leq X_2) & = \int_{-\infty}^{\infty} \int_{-\infty}^{x_2} f_{X_1}(x_1) f_{X_2}(x_2) dx_1 dx_2\\ & = \int_{-\infty}^{\infty} f_{X_2}(x_2) \left\{\int_{-\infty}^{x_2} f_{X_1}(x_1) dx_1\right\} dx_2 \\ & = \int_{-\infty}^{\infty} f_{X_2}(x_2) F_{X_1}(x_2) dx_2 \\ & = E\left\{ F_{X_1}(X_2) \right\}. \end{align*} Similarly, we have $P(X_2 \leq X_1) = E\left\{ F_{X_2}(X_1) \right\}$, and hence $$P(X_1 \leq X_2) = E\left\{ F_{X_1}(X_2) \right\} = 1 - E\left\{ F_{X_2}(X_1) \right\}.$$ Note that if $X_1$ and $X_2$ have the same distribution, then $U = F_{X_1}(X_2) = F_{X_2}(X_2)$ follows a uniform $U(0, 1)$ distribution, and hence $P(X_1 \leq X_2) = E(U) = 0.5$ as one would expect.

Now, based on your graphic and the information provided in one of your comments, it seems that a shifted exponential distribution would be a reasonable choice for the distribution of $X_2$. So, if $X_1 \sim N(\mu, \sigma^2)$ and $X_2$ follows a shifted exponential distribution with rate $\lambda > 0$ and location parameter $a$, that is $F_{X_2}(x) = 1 - \exp\{-\lambda(x-a)\}$ if $x > a$ and $F_{X_2}(x) = 0$ otherwise, then the probability is \begin{align} P(X_1 \leq X_2) &= 1 - \int_{-\infty}^{\infty} F_{X_2}(x) f_{X_1}(x) dx \\ &= 1 - \int_{a}^{\infty} [ 1 - \exp\{-\lambda(x-a)\} ] f_{X_1}(x) dx \\ &= 1 - P(X_1 > a) + \int_{a}^{\infty} \exp\{-\lambda(x-a)\} f_{X_1}(x) dx \\ &= \Phi\left( \frac{a - \mu}{\sigma} \right) + \exp \left\{ \lambda (a - \mu) + \frac{\lambda^2\sigma^2}{2} \right\} \Phi\left( \frac{\mu - a - \lambda \sigma^2}{\sigma} \right), \end{align} where $\Phi(\cdot)$ denotes the standard normal distribution function.

In your case, numerical values of the parameters could be $a = 2$ and $\lambda = 1$ (assuming that $X_2$ corresponds to "Strain" $\times 1000$).

• @Quantlbex Thanks. I have literally manufactured the graph in the question by using the equation y=(4.754/78504)*exp(-779.4*x), where each value on the X-Axis is directly associated with a probability. I am therefore unsure what the PDF or CDF would be, or if it even has one. Also, may I ask why you don't believe the answer suggested below won't work? – user131983 Mar 22 '14 at 14:45
• What makes you think that I believe that another answer won't work? – QuantIbex Mar 22 '14 at 15:09
• The function you manifactured is unlikely to be a PDF; it doesn't seem to integrate to 1. The exponential distribution with an appropriate rate parameter might suit your needs. – QuantIbex Mar 22 '14 at 15:13
• Note that with $a = 2$ and $\lambda = 1$, $P(X_2 > 8) \approx 0.0025$, which is rather small. I'll let you determine if putting a probability of $0.0025$ (instead of $0$) on values larger that $8$ is a problem in your application. – QuantIbex Mar 22 '14 at 22:41
• I've corrected the typos I found when re-doing the computations to get the final expression. Feel free to do the computations yourself to double check. – QuantIbex Apr 7 '14 at 18:34

The difference between two independent variables has a distribution given by the convolution of the two individual distributions. So basically just smooth that curve above with the normal distribution. It will extend into the negative region and have a smooth peak somewhere in the positive region. That's about all there is to say about it.

• Thanks. May I know why you say the difference between the two independent variables is given by the convolution of the two distribution? Also, when you say smooth the curve with the Normal Distribtuion, do you effectively mean just joining the two curves together? – user131983 Mar 22 '14 at 14:11
• Well, here is source on it.dartmouth.edu/~chance/teaching_aids/books_articles/… – Dave31415 Mar 22 '14 at 14:16
• If you wanted to prove it, you can just do a transformation from X, Y to Z=X+Y and W=X-Y which will be independent if X and Y are. Then just integrate over Z. That leaves P(W) as a convolution. – Dave31415 Mar 22 '14 at 18:27
• Thanks, I understand what you mean now. I get the following expression: $\int_{0}^{z} (lambda*e^{-lambda(k-z)}*e^{-(k^2/2)})/sqrt(2*pi)dk$ – user131983 Mar 22 '14 at 18:46
• The integral should go 0 to infinity and so you can write it as an Error function. – Dave31415 Mar 22 '14 at 20:10

If your graph above represents a probability density, then you can find the density for $X_2 - X_1$ via the convolution integral. Then $P(X_2 <= X_1)$ is equivalent to the probability that $P(X_2 - X_1 <= 0)$, using the density function derived from convolution. If you have discrete distributions, then there's an equivalent process using a sum instead of an integral.

For the analytic approach, see if this helps: http://courses.washington.edu/bioen316/Assignments/316_SCP.pdf

If you can sample from both, then simulations of $X_2 - X_1$ will give a working approximation. I'm only familiar with how to do that with an inverse CDF, but there's a computational method mentioned here that may interest you: http://blog.quantitations.com/tutorial/2012/11/20/sampling-from-an-arbitrary-density/