Baye's Theorm
Bayes' Theorem
Bayes can do magic!
Ever wondered how computers learn about people?
Bayes’ Theorem is a way of finding a probability when we know certain other probabilities.
The formula is:
P(A|B) = P(A) P(B|A)P(B)
Which tells us: | how often A happens given that B happens, written P(A|B), | |
When we know: | how often B happens given that A happens, written P(B|A) | |
and how likely A is on its own, written P(A) | ||
and how likely B is on its own, written P(B) |
Let us say P(Fire) means how often there is fire, and P(Smoke) means how often we see smoke, then:
P(Fire|Smoke) means how often there is fire when we can see smoke
P(Smoke|Fire) means how often we can see smoke when there is fire
P(Smoke|Fire) means how often we can see smoke when there is fire
So the formula kind of tells us "forwards" P(Fire|Smoke) when we know "backwards" P(Smoke|Fire)
Remembering
First think "AB AB AB" then remember to group it like: "AB = A BA / B"
P(A|B) = P(A) P(B|A)P(B)
"A" With Two Cases
One of the famous uses for Bayes Theorem is False Positives and False Negatives.
For those we have two possible cases for "A", such as Pass/Fail (or Yes/No etc)
We want to know the chance of having the allergy when test says "Yes", written P(Allergy|Yes)
Let's get our formula:
P(Allergy|Yes) = P(Allergy) P(Yes|Allergy)P(Yes)
- P(Allergy) is Probability of Allergy = 1%
- P(Yes|Allergy) is Probability of test saying "Yes" for people with allergy = 80%
- P(Yes) is Probability of test saying "Yes" (to anyone) = ??%
Oh no! We don't know what the general chance of the test saying "Yes" is ...
... but we can calculate it by adding up those with, and those without the allergy:
- 1% have the allergy, and the test says "Yes" to 80% of them
- 99% do not have the allergy and the test says "Yes" to 10% of them
Let's add that up:
P(Yes) = 1% × 80% + 99% × 10% = 10.7%
Which means that about 10.7% of the population will get a "Yes" result.
So now we can complete our formula:
P(Allergy|Yes) = 1% × 80%10.7% = 7.48%
P(Allergy|Yes) = about 7%
This is the same result we got on False Positives and False Negatives.
In fact we can write a special version of the Bayes' formula just for things like this:
P(A|B) = P(A)P(B|A) P(A)P(B|A) + P(not A)P(B|not A)
Comments
Post a Comment