<< Back

# Simple Bayes Problem

### Facts:

Imagine you are in the army, and you are in combat. Also imagine you have an amazing new piece of equipment, namely a new helmet that's impervious to all rifle fire. Also you know something about soldiers in the enemy army. You know that 99% of them are regular soldiers, and of those soldiers only 20% of time are they capable of firing a rifle from 400 yards and hitting a target in the head. But there's another group within the enemy army; the sharpshooters, the elite, and they are 1% of the force, but they are also really good at shooting from long distances. 90% of the time when they aim at a target at 400 yards away they can hit it in the head.

### Problem:

I want you to imagine you are out in the field and you look over the horizon and you spot a sole enemy soldier at 400 yards. Now you pick you head just above the edge of the hole you are in to see if that person saw you, and you get shoot right in the head. What are the chances that that person was a: regular soldier or a sniper...?

### Solution:

Note: I will use up to 4 significant digits to make the result as accurate as I can.

P(B1): 0.99 (Probability that's a regular soldier)
P(B2): 0.01 (Probability that's a sniper)

C: Special talent. In this case the skill of being able to hit a target at 400 yards.

P(C/B1): 0.20 (Probability of having special talent, "given" that's a regular soldier)
P(C/B2): 0.90 (Probability of having special talent, "given" that's a sniper)

Now we need to find P(B2/C), which is the probability that is a sniper, "given" that it didn't miss from 400 yards.

Bayes Rule:

$P(B_2/C) = { P(C/B_2) \times P(B_2) \over P(C) \; = \; {\sum_{i=1}^n P(C/B_i) \times P(B_i)} }$

A little explanation of Bayes Rule... here P(B2/C) is the "posterior" probability "given" or "having accounted" for C. P(C/B2) is the "likelihood", P(B2) is the "prior" probability and P(C) is the Total Probability or "evidence".

Now we have the following probability tree:

#### One Hit:

If we receive "1 Hit" to our helmet from 400 yards away, then:

$P(B_2/C) = { P(C/B_2) \times P(B_2) \over P(C) \; = \; {\sum_{i=1}^n P(C/B_i) \times P(B_i)} } = { 0.9 \times 0.01 \over (0.99 \times 0.2) + (0.01 \times 0.9) } = 0.04348 = 4.348\%$

This posterior probability of 4.348% is the probability that the shooter was a snipper "given" that we received a hit from 400 yards away.

#### Two Hits:

If we receive "2 Consecutive Hits" to our helmet from 400 yards away, then:
Observation: For this case we must use the posterior probability from the previous experiment/event as the prior probability of this current experiment/event. This is called Bayesian Updating. That means that we must replace 0.01 with 0.04348.

$P(B_2/C) = { P(C/B_2) \times P(B_2) \over P(C) \; = \; {\sum_{i=1}^n P(C/B_i) \times P(B_i)} } = { 0.9 \times 0.04348 \over (0.99 \times 0.2) + (0.01 \times 0.9) } = 0.1890 = 18.90\%$

This posterior probability of 18.90% is the probability that the shooter was a snipper "given" that we received two hits from 400 yards away. Here we can see that our posterior probability of the shooter being a snipper has claimed to 18.90% from 4.348%.

#### Three Hits:

If we receive "3 Consecutive Hits" to our helmet from 400 yards away, then:
Observation: We update our prior probability again. That means that we must replace 0.04348 with 0.1890.

$P(B_2/C) = { P(C/B_2) \times P(B_2) \over P(C) \; = \; {\sum_{i=1}^n P(C/B_i) \times P(B_i)} } = { 0.9 \times 0.1890 \over (0.99 \times 0.2) + (0.01 \times 0.9) } = 0.8217 = 82.17\%$

This posterior probability of 82.17% is the probability that the shooter was a snipper "given" that we received three hits from 400 yards away. Here we can see that our posterior probability of the shooter being a snipper has claimed to 82.17% from 18.90%.

#### Three Hits & One Miss:

If we received "3 Consecutive Hits" and now "1 Miss" (Suppose we heard the shot) then:
Observation: What we must do in this case is use the previous posterior probability as our prior in order to represent the "3 Hits", but the likelihood of missing "given" that's a snipper over the evidence or Total Probability of missing, in order to represent the current "1 Miss".

$P(B_2/\overline{C}) = { P(\overline{C}/B_2) \times P(B_2) \over P(\overline{C}) \; = \; {\sum_{i=1}^n P(\overline{C}/B_i) \times P(B_i)} } = { 0.1 \times 0.8217 \over (0.8 \times 0.99) + (0.1 \times 0.01) } = 0.1036 = 10.36\%$

Now we can see that our probability that the shooter is a snipper after three hits and one miss has dropped to 10.36%. The reason the drop on the probability was so drastic is because the probability of missing is much higher for a regular soldier than for a snipper. But still our current probability of 10.36% is still much higher than our initial 1%, before any shot was fired.

### Shots/Probability Table:

$\begin{array}{c|lcr}Probability & \text{No Shot} & \text{First Shot} & \text{Second Shot} & \text{Third Shot} & \text{Fourth Shot} \\\hline Regular & 0.99 & 0.95652 & 0.811 & 0.1783 & 0.8964 \\Snipper & 0.01 & 0.04348 & 0.1890 & 0.8217 & 0.1036 \\\hline & \text{} & \text{Hit} & \text{Hit} & \text{Hit} & \text{Miss} \\\hline \end{array}$