Lesson 6 of 15
Bayes' Theorem
Inverting Conditional Probabilities
Bayes' theorem lets you flip a conditional probability — turning into :
The denominator comes from the law of total probability:
The Medical Test Example
A disease affects 1% of the population. A test has 99% sensitivity (true positive rate) and 5% false positive rate.
You test positive. What is the probability you have the disease?
Only 17% — the low base rate dominates. This is the base-rate fallacy.
Terminology
- — prior: your belief before seeing evidence
- — posterior: updated belief after evidence
- — likelihood ratio: how much the evidence updates you
Your Task
Implement bayes(p_h, p_e_given_h, p_e_given_not_h) that returns , rounded to 4 decimal places.
Pyodide loading...
Loading...
Click "Run" to execute your code.