DEV Community

Academic Quant
Academic Quant

Posted on Originally published at academicquant.co.uk

Three probability interview questions where the first guess is wrong

These three come up again and again in quant interviews, and in each of them almost everyone's first answer is wrong. I think the fastest way through all three is to count things, so that's how I'd answer them out loud.

A positive test

Suppose a condition affects 1% of people and there's a test that catches 99% of cases while correctly clearing 95% of healthy people. If you test positive, how likely is it that you've actually got it?

Most people I ask say 99%, and I think the easiest way to see why that's wrong is to picture 10,000 people. About 100 of them have the condition and the test catches 99 of those, while the other 9,900 are healthy (although 5% of them, which is 495 people, still test positive). So 594 people test positive and only 99 of them are actually ill, which works out at exactly one in six or roughly 16.7%, and that calculation is really all Bayes' theorem is:

P(ill∣+)=0.01×0.990.01×0.99+0.99×0.05=16 P(\text{ill} \mid +) = \frac{0.01 \times 0.99}{0.01 \times 0.99 + 0.99 \times 0.05} = \frac{1}{6}

If you then get a second positive from an independent test, you'd start from one in six this time, and with the same accuracy it takes you up to about 79.8%.

A shared birthday

How many people do you need in a room for an even chance that two of them share a birthday? The usual guess is somewhere near 183 (half of 365), although the answer is only 23, and with 23 people the chance is 50.7% while with 57 it's already over 99%.

I find counting pairs is what makes it believable, since twenty-three people make 253 pairs and each pair matches with probability 1/365, so you'd expect about 0.69 matching pairs in the room. The guess of 183 probably comes from a different question (how many other people you'd need before someone shares your own birthday), and even that one actually takes 253.

The bus

Suppose buses come every 10 minutes on average and you arrive at a random time. If they run exactly on time you'll wait 5 minutes on average, although if they arrive at random with the same average rate you'll wait 10.

The reason is that you're more likely to turn up during a long gap than a short one, so the gap you land in is longer than the average gap. With random arrivals the gaps are exponential and the gap you land in averages twice the usual gap (20 against the usual 10 minutes), and you arrive halfway through it on average. In general, for gaps of length X:

expected wait=E[X2]2 E[X] \text{expected wait} = \frac{E[X^2]}{2\,E[X]}

I checked all three by computing them exactly and by simulation, and I built small calculators for each so you can change the numbers. There are more questions of this kind with worked answers here: https://academicquant.co.uk/quant-questions-probability?utm_source=devto&utm_medium=post&utm_campaign=devto-probability-first-guess-wrong

Top comments (0)