# Probability that value from distribution A will be greater than value from distribution B

I have 2 normal probability distributions, A and B. If random values were to be chosen from each, what's the probability that the value from A will be greater than the value from B? How can I calculate that knowing the means and std of each distribution, or conceptually from the areas under the curves:

## migrated from stackoverflow.comApr 25 at 20:53

This question came from our site for professional and enthusiast programmers.

Assuming independence (because in the case of dependence, you should provide the joint PDF), linear combinations of normal RVs are still normal. So, $$A-B$$ will be a normal RV. Then, we have $$P(A>B)=P(A-B>0)$$. In order to calculate this probability we need to know the mean and the variance of $$C=A-B$$. And, it is: $$\mu_c=E[C]=E[A-B]=\mu_a-\mu_b$$ $$\sigma_C^2=\operatorname{var}(C)=\operatorname{var}(A-B)=\operatorname{var}(A)+\operatorname{var}(B)=\sigma_A^2+\sigma_B^2$$
Then, you'll have the following probability: $$P(C>0)=P\left(\frac{C-\mu_c}{\sigma_c}>\frac{0-\mu_c}{\sigma_c}\right)=P\left(Z>\frac{0-\mu_c}{\sigma_c}\right)$$ Where you can use a Z-table to figure out the approximate probability.
• There are no simple integrals to calculate CDF of normals, which is why we have numeric Z tables. Common statistical tests (like t-test, f-test etc.) are data-driven and for deciding if the two samples differ by mean/std or not, they don't calculate $P(A>B)$. – gunes Apr 26 at 12:07