# Thread: Prob A>B where A and B are from normal distributions

1. ## Prob A>B where A and B are from normal distributions

If we have a random number A taken from a normal distribution with mean M1 and variance V1 and a number B taken from a normal distribution with mean M2 and variance V2, what is the probability that A > B?

A link to an online answer would do fine- I'm sure its a standard problem, I just don't know how to look it up.

2. ## Re: Prob A>B where A and B are from normal distributions

Originally Posted by mickreiss
If we have a random number A taken from a normal distribution with mean M1 and variance V1 and a number B taken from a normal distribution with mean M2 and variance V2, what is the probability that A > B?

A link to an online answer would do fine- I'm sure its a standard problem, I just don't know how to look it up.
A-B has a normal distribution with mean M1-M2 and variance V1+V2, so what is the probability that A-B>0.

CB

3. ## Re: Prob A>B where A and B are from normal distributions

Originally Posted by CaptainBlack
A-B has a normal distribution with mean M1-M2 and variance V1+V2, so what is the probability that A-B>0.

CB
I have a library function cumul(x) which gives the cumulative area of a normal distribution of zero mean and unit variance where the argument is the number of standard deviations away from the centre. I.e. cumul(-infinity) = 0, cumul(0) = 0.5 and cumul(infinity) = 1. By my calculations your suggestion means the the probability of A being greater than B is:

1 - cumul( -1 * (M1-M2)/sqrt(V1+V2) )

As an example if M1 = 10 and M2 = 11 and V1=V2=1 then my formula says the answer is 0.24

But doing a simulation with a large number of samples from these distributions I get an answer of 0.11

Clearly I've made some mistake - which one is right?

4. ## Re: Prob A>B where A and B are from normal distributions

Originally Posted by mickreiss
I have a library function cumul(x) which gives the cumulative area of a normal distribution of zero mean and unit variance where the argument is the number of standard deviations away from the centre. I.e. cumul(-infinity) = 0, cumul(0) = 0.5 and cumul(infinity) = 1. By my calculations your suggestion means the the probability of A being greater than B is:

1 - cumul( -1 * (M1-M2)/sqrt(V1+V2) )

As an example if M1 = 10 and M2 = 11 and V1=V2=1 then my formula says the answer is 0.24

But doing a simulation with a large number of samples from these distributions I get an answer of 0.11

Clearly I've made some mistake - which one is right?

Code:
>N=10000;
>
>
>
>A=normal(1,N)*1+10;B=normal(1,N)*1+11;
>
>sum(A>B)/N
0.2407
>
CB

5. ## Re: Prob A>B where A and B are from normal distributions

Thanks for that - just found a bug in my monte-carlo code. It seems "1 - cumul( -1 * (M1-M2)/sqrt(V1+V2) )" was correct after all.
Cheers.