# 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.

• Select a goal from the dropdown box.
• Enter a probability in the text boxes below.
• Click the Calculate button to compute probability.
• Click the Report button to describe the analysis.

## Summary Report

This 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)

Instructions: To find the answer to a frequently-asked question, simply click on the question.

### What is Bayes Rule?

Bayes Rule is an equation that expresses the conditional relationships between two events in the same sample space. 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.

### When can I use Bayes Rule?

Bayes Rule is a simple equation with just four terms:

• 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.

Any time that three of the four terms are known, Bayes Rule can be used to solve for the fourth term. See the Sample Problem for an example that illustrates how to use Bayes Rule.

### What if Bayes Rule generates a probability greater than 1.0?

If Event A occurs 100% of the time, the probability of its occurrence is 1.0; that is, P(A) = 1.0. In the real world, an event cannot occur more than 100% of the time; so a real-world event cannot have a probability greater than 1.0.

Bayes Rule is just an equation. It is possible to plug into Bayes Rule probabilities that cannot occur together in the real world. When that happens, it is possible for Bayes Rule to generate a probability that could not occur in the real world; that is, a probability greater than 1.0. Here's how that can happen:

P(A) = P(A|B)*P(B) + P(A|B')*P(B')

where

• P(A) is the probability that Event A occurs.
• P(B) is the probability that Event B occurs.
• P(B') is the probability that Event B does not occur.
• P(A|B) is the probability that A occurs, given that B occurs.
• P(A|B') is the probability that A occurs, given that B does not occur.

From this equation, we see that P(A) should never be less than P(A|B)*P(B). If we plug numbers into Bayes Rule that violate this maxim, we get strange results. For example, suppose you plug the following numbers into Bayes Rule:

• P(A) = 0.1
• P(B) = 0.5
• P(A|B) = 0.6.

Given these inputs, Bayes Rule will compute a value of 3.0 for P(B|A), clearly an impossible result in the real world. If Bayes Rule produces a probability greater than 1.0, that is a warning sign. It means your probability inputs do not reflect real-world events.

### What is E Notation?

The Bayes Rule Calculator uses E notation to express very small numbers. E notation is a way to write numbers that are too large or too small to be concisely written in a decimal format.

With E notation, the letter E represents "times ten raised to the power of". Here is an example of a very small number written using E notation:

3.02E-12 = 3.02 * 10-12 = 0.00000000000302

If a probability can be expressed as an ordinary decimal with fewer than 14 digits, the Bayes Rule Calculator will do so. But if a probability is very small (nearly zero) and requires a longer string of digits, the calculator will use E notation to display its value.

## Sample 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.091

P( 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. ## Problem?

Oops! Something went wrong.