How Reliable Is a Positive Test Result?
Northbeam Health runs county-wide screening programmes, and the phone line is busier than anyone planned for. Every caller asks the nurse the same thing, and the nurse needs a straight answer: I tested positive - how likely is it that I actually have this?
Three numbers come out of each programme's trial data. They are routinely confused with one another, so read them slowly:
- how common the illness is across the county, before anybody is tested;
- among people who do have it, how often the test comes back positive;
- among people who do not have it, how often the test comes back positive anyway.
Northbeam runs several programmes, for illnesses of very different rarity and with tests of very different quality, so the nurse's answer has to be worked out from that programme's three figures rather than remembered.
Task: Print the probability that a caller who has tested positive really does have the illness, as a single number rounded to 4 decimals. Round once, at the end.
Input
Three lines, each a decimal between 0 and 1: how common the illness is in the county, then the chance an ill person tests positive, then the chance a healthy person tests positive.
Output
One line holding the probability, rounded to 4 decimals and printed the way Python prints a float - 0.0876.
Example:
Input:
0.01
0.95
0.1
Output:
0.0876
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in