Testing the Independence Assumption
Halyard Mail's filter only holds together because it assumes the features of a message have nothing to do with one another. A reviewer wants that assumption audited on one pair of words at a time. Three figures come out of the archive: how often the first word turns up, how often the second turns up, and how often the two of them turn up in the same message. From the first two alone, the assumption implies a figure for the pair -- what you would see if neither word had any bearing on whether the other appeared. The audit sets that against what the archive actually recorded.
Task: Print the assumption's figure, the recorded figure, and the verdict.
Input
One line holding three numbers between 0 and 1, separated by single spaces: how often the first word appears, how often the second appears, and how often the two appear together.
Output
Three lines, in this order. naive and the assumption's figure, to 4 decimal places. observed and the recorded figure, to 4 decimal places. Then independent if the gap between the two is strictly under 0.01, or not independent if it is not. The gap counts the same size in either direction, is measured on the real values rather than the printed ones, and a gap of exactly 0.01 is not independent.
Example:
Input:
0.5 0.4 0.2
Output:
naive 0.2000
observed 0.2000
independent
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