# Bayes' Theorem: What It Is, Formula, and Examples

> **Definition**
>
> Bayes' Theorem is a formula used to calculate the probability of an outcome given a known previous outcome that occurred in similar circumstances.

## What Is Bayes' Theorem?

Bayes' Theorem is a mathematical formula for determining conditional probability. Conditional probability is the likelihood of an outcome occurring based on a previous outcome in similar circumstances. Thus, Bayes' Theorem provides a way to revise or update an existing prediction or theory given new evidence.

In finance, Bayes' Theorem can be used to evaluate or reevaluate the [risk](https://www.investopedia.com/terms/r/risk.asp) of lending money to a potential borrower.

Bayes' Theorem is named after 18th-century British mathematician Thomas Bayes. It is also called Bayes' Rule or Bayes' Law and is the foundation of the field of Bayesian statistics.

### Key Takeaways

*   Bayes' Theorem can be used to revise a probability analysis based on new information.
*   It is often employed in finance to calculate or update risk evaluation.
*   It is used widely in other fields, such as analyses of medical test results.

![Bayes' Thereom](https://www.investopedia.com/thmb/qShXSdMimqu1INFptKOO-lHJxfE=/1500x0/filters:no_upscale():max_bytes(150000):strip_icc()/Bayes_Theorem-v2-6d6b2a2293c648ec99f16f78a3c80f09.png)

*— Investopedia / Lara Antal*

## Understanding Bayes' Theorem

Applications of Bayes' Theorem are widespread and not limited to the financial realm. For example, Bayes' theorem can be used to determine the accuracy of medical test results by taking into consideration how likely any given person is to have a disease and the general accuracy of the test. Bayes' theorem relies on incorporating [prior probability](https://www.investopedia.com/terms/p/prior_probability.asp) distributions in order to generate [posterior probabilities](https://www.investopedia.com/terms/p/posterior-probability.asp).

In Bayesian statistical inference, prior probability is the probability of an event occurring before new data is collected. In other words, it represents the best rational assessment of the probability of a particular outcome based on current knowledge before an experiment is performed.

Posterior probability is the revised probability of an event occurring after considering the new information. Posterior probability is calculated by updating the prior probability using Bayes' theorem. Put another way, the posterior probability is the probability of event A occurring, given that event B has occurred.

## Special Considerations

Bayes' Theorem gives the probability of an event based on new information that is or may be related to that event. The formula also can be used to determine how the probability of an event occurring may be affected by hypothetical new information, supposing the new information will turn out to be true.

### Example: A Deck of Cards

Consider drawing a single card from a complete deck of 52 cards. There are four kings in the deck, so the probability that the card is a king is four divided by 52, which equals 1/13 or approximately 7.69%. Now, suppose it is revealed that the selected card is a face card. The probability the selected card is a king, given it is a face card, is four divided by 12, or approximately 33.3%, as there are 12 face cards in a deck.

## Formula for Bayes' Theorem

> $\begin{aligned} &P\left(A|B\right)=\frac{P\left(A\bigcap{B}\right)}{P\left(B\right)}=\frac{P\left(A\right)\cdot{P\left(B|A\right)}}{P\left(B\right)}\\ &\textbf{where:}\\ &P\left(A\right)=\text{ The probability of A occurring}\\ &P\left(B\right)=\text{ The probability of B occurring}\\ &P\left(A|B\right)=\text{The probability of A given B}\\ &P\left(B|A\right)=\text{ The probability of B given A}\\ &P\left(A\bigcap{B}\right))=\text{ The probability of both A and B occurring}\\ \end{aligned}$

## Examples of Bayes' Theorem

Below are two examples of Bayes' Theorem. The first example shows how the formula can be derived from a [stock investing](https://www.investopedia.com/articles/financial-theory/09/bayesian-methods-financial-modeling.asp) example using Amazon.com Inc. ([AMZN](https://www.investopedia.com/markets/quote?tvwidgetsymbol=amzn)). The second example applies Bayes' Theorem to pharmaceutical drug testing.

### Deriving the Bayes' Theorem Formula

Bayes' Theorem follows from the axioms of conditional probability, which is the probability of an event given that another event occurred. For example, a simple probability question may ask: "What is the probability of Amazon's stock price falling?" [Conditional probability](https://www.investopedia.com/terms/c/conditional_probability.asp) takes this question a step further by asking: "What is the probability of Amazon's stock price falling given that the [Dow Jones Industrial Average](https://www.investopedia.com/terms/d/djia.asp) (DJIA) index fell earlier?"

The conditional probability of A, given that B has happened, can be expressed as:

If A is: "AMZN price falls" then P(AMZN) is the probability that AMZN falls; and B is: "The DJIA is already down," and P(DJIA) is the probability that the DJIA fell; then the conditional probability expression reads as "the probability that AMZN drops given a DJIA decline is equal to the probability that AMZN price declines and DJIA declines over the probability of a decrease in the DJIA index.

> P(AMZN|DJIA) = P(AMZN and DJIA) / P(DJIA)

P(AMZN and DJIA) is the probability of both A and B occurring. This is the same as the probability of A occurring multiplied by the probability that B occurs given that A occurs, expressed as P(AMZN) x P(DJIA|AMZN). The fact that these two expressions are equal leads to Bayes' Theorem, which is written as:

> if: P(AMZN and DJIA) = P(AMZN) x P(DJIA|AMZN) = P(DJIA) x P(AMZN|DJIA)

> then: P(AMZN|DJIA) = \[P(AMZN) x P(DJIA|AMZN)\] / P(DJIA).

P(AMZN) and P(DJIA) are the probabilities that Amazon and the Dow have fallen independently of each other.

The formula explains the relationship between the probability of the hypothesis before seeing the evidence that P(AMZN) and the probability of the hypothesis after getting the evidence P(AMZN|DJIA), given a hypothesis for Amazon given evidence in the Dow.

### Numerical Example of Bayes' Theorem

As a numerical example, imagine there is a drug test that is 98% accurate, meaning that 98% of the time, it shows a true positive result for someone using the drug, and 98% of the time, it shows a true negative result for nonusers of the drug.  

Next, assume 0.5% of people use the drug. If a person selected at random tests positive for the drug, the following calculation can be made to determine the probability the person is actually a user of the drug where the terms are:

*   A = Probability that a positive test result is true
*   B = Percent of people that use the drug
*   A x B = the probability that a positive test result is true
*   ( 1 - A ) x ( 1 - B ) = Probability that a negative test result is true

The formula would look like this:

> ( A x B ) / \[ ( A x B ) + { ( 1 - A ) x ( 1 - B ) } \] = Probability of taking the drug

Using the values, the calculation works out as follows:  

> ( 0.98 x 0.005 ) / \[ ( 0.98 x 0.005 ) + { ( 1 - 0.98 ) x ( 1 - 0.005 ) } \] =

> 0.0049 / ( 0.0049 + 0.0199 ) = 19.76%

Bayes' Theorem shows that even if a person tested positive in this scenario, there is a 19.76% chance the person takes the drug and an 80.24% chance they don't.  

## What Is the Bayes' Rule Used for?

The Bayes' rule is used to update a probability with an updated conditional variable. Investment analysts use it to forecast probabilities in the stock market, but it is also used in many other contexts.

## Why Is Bayes' Theorem So Powerful?

Mathematically, Bayes' Theorem shows that two probabilities are equal. Used in statistics, investing, or other contexts, Bayes' Theorem allows you to view conditional probabilities. This means that you can find the likelihood of something happening with an additional piece of information (a condition) taken into account.

## How Do You Know When to Use Bayes' Theorem?

If you need to determine the probability of something occuring given that another condition exists that can influence the occurence, you would use Bayes' theorem.

## The Bottom Line

Bayes' Theorem allows you to assess the likelihood of something happening when something else is taken into account.

For example, it takes a test result and relates it to the conditional probability of that test result given other related events. For high-probability false positives, the theorem gives a more reasoned likelihood of a particular outcome.