Someone takes a test for a rare disease and it comes back positive. Write chance_sick(base_rate, catch_rate, false_alarm_rate): the chance they are actually sick. base_rate is the share of people who have it, catch_rate the chance a sick person tests positive, and false_alarm_rate the chance a healthy person tests positive anyway.
1,000 people take a test for a disease that 1 in 1,000 people have. It catches 99% of sick people, and goes off for 1% of healthy people anyway. Someone tests positive.
chance_sick(base_rate, catch_rate, false_alarm_rate)| base_rate | share of people who have the disease | e.g. 0.01 |
| catch_rate | chance a sick person tests positive | e.g. 0.9 |
| false_alarm_rate | chance a healthy person tests positive | e.g. 0 |
| returns | the chance they are sick | |