All problems

Updating Belief After Two Positive Tests

mediumPythonBayes' Theorem

A Northbeam Health resident's screen came back positive, so the clinic did what the protocol says: took a fresh sample a week later and ran the same test again. That one came back positive too. The resident is now sitting in front of a nurse asking the only question that matters - after two positives, how bad is it?

The answer depends on three rates: how common the illness is in the county before any testing at all, how often a single run reads positive in someone who has it, and how often a single run reads positive in someone who does not. The clinic follows the same protocol on every programme it runs, and those three rates are different for each.

Treat the two runs as independent: whether the second reads positive depends only on whether this resident is ill, never on what the first one said.

Task: Print the probability that the resident has the illness given that both runs came back positive, as a single number rounded to 4 decimals. Round only the number you print - nothing in between.

Input

Three lines, each a decimal between 0 and 1: how common the illness is in the county, then the chance one run reads positive in an ill person, then the chance one run reads positive in a healthy person.

Output

One line holding the probability, rounded to 4 decimals and printed the way Python prints a float - 0.4769.

Example:

Input:
0.01
0.95
0.1

Output:
0.4769

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

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…