Premium problem82. Is the Alert Real?

Medium Locked

An anomaly detector fires on a true anomaly with probability tpr and on normal traffic with probability fpr. Anomalies make up a prevalence fraction of events. The detector just fired. Return the probability it is a real anomaly.

This is the base rate problem that makes alerting hard: at 0.1% prevalence, a detector with a 1% false positive rate produces mostly noise no matter how good its true positive rate is.

Input

prevalence = 0.001
tpr = 0.99
fpr = 0.01

Output

0.09016393442622951

Premium problem

This one's part of Premium. Unlock the full Probability track plus every other premium problem on the site.

Implement solve(...)