# Probability of gaussian random variables lying in a certain order

I have two independent gaussians and a known constant:

\begin{align} X_1 &\sim \mathcal{N}(\mu_1, \sigma_1^2) \\ X_2 &\sim \mathcal{N}(\mu_2, \sigma_2^2) \\ c &\in \mathbb{R} \end{align}

How do I calculate the probability $P(X_1 > X_2 > c) = P(X_1 > X_2, X_2 > c)$?

In my specific case it turns out that $\sigma_1 = \sigma_2$, so if needed the problem can be simplified a little

I can get somewhere with

\begin{align} P(X_1 > X_2 > c) &= \int_c^\infty \int_{x_1}^\infty f_\mathcal{N}(x_1|\mu_1, \sigma_1)f_\mathcal{N}(x_2|\mu_2, \sigma_2) \, dx_2 \, dx_1 \\ &= \int_c^\infty f_\mathcal{N}(x_1|\mu_1, \sigma_1) \int_{x_1}^\infty f_\mathcal{N}(x_2|\mu_2, \sigma_2) \, dx_2 \, dx_1 \\ &= \int_c^\infty f_\mathcal{N}(x_1|\mu_1, \sigma_1) Q\left(\frac{x_1 - \mu_2 }{\sigma_2}\right) \, dx_1 \\ &= \int_{c-\mu_1}^\infty f_\mathcal{N}(z'|0, \sigma_1) Q\left(\frac{z' + \mu_1- \mu_2 }{\sigma_2}\right) \, dz' \\ &= \int_\frac{c-\mu_1}{\sigma_1}^\infty f_\mathcal{N}(z) Q\left(\frac{\sigma_1}{\sigma_2}(z + \mu_1- \mu_2 )\right) \, dz \end{align}

Is this the best I can do?

• Yes the probability has no closed-form solution. You will always need to use numerical method for these kinds of multivariate normal probabilities, except some special cases where the set is the intersection of half planes with all the boundaries intersecting at the mean. – BGM May 11 '16 at 3:34
• @BGM: Are there any other functions like $Q$ that can encapsulate that non-closed-form-ness? – Eric May 11 '16 at 5:23
• It will depend on which non-elementary function you want to expressed in terms of. E.g. you want to in terms of the standard bivariate normal CDF with correlation $\rho$, denoted by $\Phi_2(x_1,x_2;\rho)$, then $\Pr\{X_1 > X_2, X_2 > c\} = \Pr\{X_1 > X_2\} - \Pr\{X_1 > X_2, X_2 \leq c\}$, which equals $\displaystyle\Phi\left(\frac{\mu_1-\mu_2}{\sqrt{\sigma_1^2+\sigma_2^2}}\right) -\Phi_2\left(\frac{\mu_1-\mu_2}{\sqrt{\sigma_1^2+\sigma_2^2}},\frac{c-\mu_2}{ \sigma_2};\frac{\sigma_2}{\sqrt{\sigma_1^2+\sigma_2^2}}\right)$, where $\Phi$ is the standard normal CDF. – BGM May 11 '16 at 6:00