Bayes Rule Calculator
The Bayes' Rule Calculator handles problems that can be solved using Bayes' rule (duh!). It computes the probability of one event, based on known probabilities of other events. And it generates an easy-to-understand report that describes the analysis step-by-step.
For help in using the calculator, read the Frequently-Asked Questions or review the Sample Problem. To understand the analysis, read the Summary Report that is produced with each computation. To learn more about Baye's rule, read Stat Trek's tutorial on Bayes theorem.
The Bayes Rule Calculator uses Bayes Rule (aka, Bayes theorem, the multiplication rule of probability) to compute the probability of one event, based on known probabilities of other events.
What is Bayes Rule?
Let A be one event; and let B be any other event from the same sample space, such that P(B) > 0. Then, Bayes rule can be expressed as:
P(A|B) = | P(A) P(B|A)
P(B) |
where
- P(A) is the probability of Event A.
- P(B) is the probability of Event B.
- P(A|B) is the conditional probability of Event A, given Event B.
- P(B|A) is the conditional probability of Event B, given Event A.
How to Use Bayes Rule
Bayes rule is a simple equation with just four terms. Any time that three of the four terms are known, Bayes Rule can be applied to solve for the fourth term. We've seen in the previous section how Bayes Rule can be used to solve for P( A | B ). By rearranging terms, we can derive equations to solve for each of the other three terms, as shown below:
P(B|A) = | P(B) P(A|B)
P(A) |
P(A) = | P(B) P(A|B)
P(B|A) |
P(B) = | P(A) P(B|A)
P(A|B) |
Frequently-Asked Questions
Instructions: To find the answer to a frequently-asked question, simply click on the question.
When can I use Bayes Rule?
Sample Problem
Problem 1
-
Marie is getting married tomorrow, at an outdoor ceremony in the desert. In recent years, it has rained only 5 days each year. Unfortunately, the weatherman has predicted rain for tomorrow. When it actually rains, the weatherman correctly forecasts rain 90% of the time. When it doesn't rain, he incorrectly forecasts rain 8% of the time. What is the probability that it will rain on the day of Marie's wedding?
Solution:
We begin by defining the events of interest.
- Event A. It rains on Marie's wedding.
- Event B. The weatherman predicts rain.
In terms of probabilities, we know the following:
- P(A) = 5/365 = 0.0137 [It rains 5 days out of the year.]
- P(A') = 360/365 = 0.9863 [It does not rain 360 days out of the year.]
- P(B|A) = 0.9 [The weatherman predicts rain 90% of the time, when it rains.]
- P(B|A') = 0.08 [The weatherman predicts rain 8% of the time, when it does not rain.]
We want to know P(A|B), the probability that it will rain, given that the weatherman has predicted rain. We could use Bayes Rule to compute P(A|B) if we knew P(A), P(B), and P(B|A). Two of those probabilities - P(A) and P(B|A) - are given explicitly in the problem statement. The third probability that we need is P(B), the probability that the weatherman predicts rain. Although that probability is not given to us explicitly, we can calculate it.
P(B) = P(B|A) * P(A) + P(B|A') * P(A')
P(B) = 0.9 * 0.0137 + 0.08 * 0.9863
P(B) = 0.091
Now, we know P(A), P(B), and P(B|A) - all of the probabilities required to compute P(A|B) using Bayes Rule. We plug those probabilities into the Bayes Rule Calculator, and the calculator reports that the probability that it will rain on Marie's wedding is 0.1355.
Alternatively, we could have used Baye's Rule to compute P(A|B) manually. Here's how:
P( A | B ) = P( A ) P( B | A )
P( B )P( A | B ) = 0.0137 * 0.9
0.091P( A | B ) = 0.1355
Note the somewhat unintuitive result. Even when the weatherman predicts rain, it rains only about 14 percent of the time. Despite the weatherman's gloomy prediction, there is a good chance that Marie will not get rained on at her wedding.