Bayes' Theorem
MediumProbabilityMath
Description
Given the prior probability P(A), the likelihood P(B|A), and the likelihood P(B|not A), return the posterior probability P(A|B) using Bayes’ theorem. The total evidence is P(B) = P(A)P(B|A) + (1 - P(A))P(B|not A). Round the result to 4 decimal places.
Examples
Input:
0.01, 0.9, 0.05Output:
0.1538Explanation:
Bayes’ theorem scales the prior by how strongly the evidence supports it, divided by every way that evidence could arise.
Input:
0.5, 0.9, 0.1Output:
0.9Explanation:
Bayes’ theorem scales the prior by how strongly the evidence supports it, divided by every way that evidence could arise.
Input:
0.1, 0.8, 0.2Output:
0.3077Explanation:
Bayes’ theorem scales the prior by how strongly the evidence supports it, divided by every way that evidence could arise.
Constraints
- •
0 ≤ each probability ≤ 1 - •
P(B) > 0