All problems

How Trustworthy Is a Spam Flag?

easyPythonBayes' Theorem

Whetcode Mail is rewording its junk folder. Everything the filter catches is dropped into a folder labelled Spam, and support keeps hearing from customers who eventually found a real invoice sitting in it. Before the label is changed, the product team wants a number: when the filter drops a message into that folder, how likely is it that the message really is spam?

The answer turns on three measured rates: what share of incoming mail is spam, what share of spam the filter flags, and what share of legitimate mail it flags anyway. The team runs the figure separately for each kind of mailbox it serves, because the share of spam arriving at a quiet corporate domain and at a scraped public address are nothing alike.

Task: Print the probability that a flagged message really is spam, as a single number rounded to 4 decimals. Round once, at the end.

Input

Three lines, each a decimal between 0 and 1: the share of incoming messages that are spam, then the chance a spam message is flagged, then the chance a legitimate message is flagged.

Output

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

Example:

Input:
0.2
0.9
0.05

Output:
0.8182

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…