# How can I estimate the probability of a random member from one population being “better” than a random member from a different population?

Suppose I have samplings from two distinct populations. If I measure how long it takes each member to do a task, I can easily estimate the mean and variance of each population.

If I now hypothesise a random pairing with one individual from each population, can I estimate the probability that the first is faster than the second?

I do have a concrete example in mind: the measurements are timings for me cycling from A to B and the populations represent different routes I could take; I’m trying to work out what the probability is that picking route A for my next cycle will be faster than picking route B. When I actually do the cycle, I’ve got another data point for my sample set :).

I’m aware that this is a horribly simplistic way to try to work this out, not least because on any given day the wind is more likely to affect my time than anything else, so please let me know if you think I’m asking the wrong question…

### Solution

Let the two means be $$μx\mu_x$$ and $$μy\mu_y$$ and their standard deviations be $$σx\sigma_x$$ and $$σy\sigma_y$$, respectively. The difference in timings between two rides ($$Y−XY-X$$) therefore has mean $$μy−μx\mu_y - \mu_x$$ and standard deviation $$√σ2x+σ2y\sqrt{\sigma_x^2 + \sigma_y^2}$$. The standardized difference (“z score”) is

$$z=μy−μx√σ2x+σ2y.z = \frac{\mu_y - \mu_x}{\sqrt{\sigma_x^2 + \sigma_y^2}}.$$

Unless your ride times have strange distributions, the chance that ride $$YY$$ takes longer than ride $$XX$$ is approximately the Normal cumulative distribution, $$Φ\Phi$$, evaluated at $$zz$$.

### Computation

You can work this probability out on one of your rides because you already have estimates of $$μx\mu_x$$ etc. :-). For this purpose it’s easy to memorize a few key values of $$Φ\Phi$$: $$Φ(0)=.5=1/2\Phi(0) = .5 = 1/2$$, $$Φ(−1)≈0.16≈1/6\Phi(-1) \approx 0.16 \approx 1/6$$, $$Φ(−2)≈0.022≈1/40\Phi(-2) \approx 0.022 \approx 1/40$$, and $$Φ(−3)≈0.0013≈1/750\Phi(-3) \approx 0.0013 \approx 1/750$$. (The approximation may be poor for $$|z||z|$$ much larger than $$22$$, but knowing $$Φ(−3)\Phi(-3)$$ helps with the interpolation.) In conjunction with $$Φ(z)=1−Φ(−z)\Phi(z) = 1 - \Phi(-z)$$ and a bit of interpolation, you can quickly estimate the probability to one significant figure, which is more than precise enough given the nature of the problem and the data.

### Example

Suppose route $$XX$$ takes 30 minutes with a standard deviation of 6 minutes and route $$YY$$ takes 36 minutes with a standard deviation of 8 minutes. With enough data covering a wide range of conditions, the histograms of your data might eventually approximate these: (These are probability density functions for Gamma(25, 30/25) and Gamma (20, 36/20) variables. Observe that they are decidedly skewed to the right, as one would expect for ride times.)

Then

$$μx=30,μy=36,σx=6,σy=8.\mu_x = 30, \quad \mu_y = 36, \quad \sigma_x = 6, \quad \sigma_y = 8.$$

Whence

$$z=36−30√62+82=0.6.z = \frac{36 - 30}{\sqrt{6^2 + 8^2}} = 0.6.$$

We have

$$Φ(0)=0.5;Φ(1)=1−Φ(−1)≈1−0.16=0.84.\Phi(0) = 0.5; \quad \Phi(1) = 1 - \Phi(-1) \approx 1 - 0.16 = 0.84.$$

We therefore estimate the answer is 0.6 of the way between 0.5 and 0.84: 0.5 + 0.6*(0.84 – 0.5) = approximately 0.70. (The correct but overly precise value for the Normal distribution is 0.73.)

There’s about a 70% chance that route $$YY$$ will take longer than route $$XX$$. Doing this calculation in your head will take your mind off the next hill. 🙂

(The correct probability for the histograms shown is 72%, even though neither is Normal: this illustrates the scope and utility of the Normal approximation for the difference in trip times.)