Omni Calculator logo
Last updated:

Bayes' Theorem Calculator

New

Table of contents

What is Bayes' theorem?What is the Bayes' formula?Bayes' rule formula – testsBayes' theorem for dummies – Bayes' theorem exampleBayesian inference – real life applicationsFAQs

The Bayes' theorem calculator helps you calculate the probability of an event using Bayes' theorem. The Bayes' theorem calculator finds a conditional probability of an event based on the values of related known probabilities.

Bayes' rule or Bayes' law are other names that people use to refer to Bayes' theorem, so if you are looking for an explanation of what these are, this article is for you. Below you can find the Bayes' theorem formula with a detailed explanation as well as an example of how to use Bayes' theorem in practice.

You can check out our conditional probability calculator to read more about this subject!

💡 For a more general introduction to probabilities and how to calculate them, check out our probability calculator.

What is Bayes' theorem?

Bayes' theorem is named after Reverend Thomas Bayes, who worked on conditional probability in the eighteenth century. Bayes' rule calculates what can be called the posterior probability of an event, taking into account the prior probability of related events.

To give a simple example – looking blindly for socks in your room has lower chances of success than taking into account places that you have already checked. If you have a recurring problem with losing your socks, our sock loss calculator may help you. On the other hand, taking an egg out of the fridge and boiling it does not influence the probability of other items being there. These may be funny examples, but Bayes' theorem was a tremendous breakthrough that has influenced the field of statistics since its inception.

The importance of Bayes' law to statistics can be compared to the significance of the Pythagorean theorem to math. Nowadays, the Bayes' theorem formula has many widespread practical uses. You may use them every day without even realizing it! To find more about it, check the Bayesian inference section below.

So how does Bayes' formula actually look?

What is the Bayes' formula?

In its simplest form, we are calculating the conditional probability denoted as P(A|B) – the likelihood of event A occurring provided that B is true. Bayes' rule is expressed with the following equation:

P(A|B) = [P(B|A) × P(A)] / P(B),

where:

  • P(A), P(B) – Probability of event A and even B occurring, respectively;
  • P(A|B) – Conditional probability of event A occurring given that B has happened; and similarly
  • P(B|A) – Conditional probability of event B occurring given that A has happened.

The equation can also be reversed and written as follows to calculate the likelihood of event B happening provided that A has happened:

P(B|A) = [P(A|B) × P(B)] / P(A)

Bayes' rule formula – tests

The Bayes' theorem can be extended to two or more cases of event A. This can be useful when testing for false positives and false negatives. The probability of event B is then defined as:

P(B) = P(A) × P(B|A) + P(not A) × P(B|not A),

where P(not A) is the probability of event A not occurring.

The following equation is true: P(not A) + P(A) = 1 as either event A occurs or it does not.

The extended Bayes' rule formula would then be:

P(A|B) = [P(B|A) × P(A)] / [P(A) × P(B|A) + P(not A) × P(B|not A)]

In medicine – it can help improve the accuracy of allergy tests. Bayes' theorem can help determine the chances that a test is wrong. What is the likelihood that someone has an allergy? A false positive is when results show someone with no allergy having it. A false negative would be the case when someone with an allergy is shown not to have it in the results. Bayes' formula can give you the probability of this happening. The table below shows possible outcomes:

Test result \ Reality

Sick

Healthy

Sick

True result

False positive

Healthy

False negative

True result

Bayes' theorem for dummies – Bayes' theorem example

Now that you know Bayes' theorem formula, you probably want to know how to make calculations using it.

Suppose you want to go out but aren't sure if it will rain. Do you need to take an umbrella? Let's assume you checked past data, and it shows that this month's 6 of 30 days are usually rainy. In this case, the probability of rain would be 0.2 or 20%. To quickly convert fractions to percentages, check out our fraction to percentage calculator. Let's also assume clouds in the morning are common; 45% of days start cloudy. Additionally, 60% of rainy days start cloudy. So what are the chances it will rain if it is an overcast morning?

To make calculations easier, let's convert the percentage to a decimal fraction, where 100% is equal to 1, and 0% is equal to 0. Now, let's match the information in our example with variables in Bayes' theorem:

  • A is the rain event.
  • B is the cloudy morning event.
  • P(A) is the probability of rain. In this case, 20% or 0.2.
  • Likewise P(B) is the probability of clouds occurring – 45% or 0.45.
  • P(A|B) is the probability of rain occurring given the cloudy morning – this is what we want to calculate.
  • Similarly P(B|A) is the probability of clouds on a rainy day – 60% or 0.6.

P(A|B) = [0.6 × 0.2] / 0.45) ≈ 0.27

In this case, the probability of rain occurring provided that the day started with clouds equals about 0.27 or 27%. Roughly a 27% chance of rain. So how about taking the umbrella just in case? Or do you prefer to look up at the clouds?

A quick side note; in our example, the chance of rain on a given day is 20%. Providing more information about related probabilities (cloudy days and clouds on a rainy day) helped us get a more accurate result in certain conditions. The example shows the usefulness of conditional probabilities. Now that we have seen how Bayes' theorem calculator does its magic, feel free to use it instead of doing the calculations by hand.

💡 If you'd like to learn how to calculate a percentage, you might want to check our percentage calculator.

Bayesian inference – real life applications

Bayesian inference is a method of statistical inference based on Bayes' rule. While Bayes' theorem looks at pasts probabilities to determine the posterior probability, Bayesian inference is used to continuously recalculate and update the probabilities as more evidence becomes available. This is possible where there is a huge sample size of changing data.

This technique is also known as Bayesian updating and has an assortment of everyday uses that range from genetic analysis, risk evaluation in finance, search engines and spam filters to even courtrooms. Jurors can decide using Bayesian inference whether accumulating evidence is beyond a reasonable doubt in their opinion.

Similarly, spam filters get smarter the more data they get. Seeing what types of emails are spam and what words appear more frequently in those emails leads spam filters to update the probability and become more adept at recognizing those foreign prince attacks. 😉

FAQs

When should I use Bayes' theorem?

To know when to use Bayes' formula instead of the conditional probability definition to compute P(A|B), reflect on what data you are given:

  • If you know the probability P(A) and the conditional probability P(B|A), use Bayes' formula.
  • If you know the probability of intersection P(A∩B), use the conditional probability formula.

How do I use Bayes' theorem?

To find the conditional probability P(A|B) using Bayes' formula, you need to:

  1. Make sure the probability P(B) is non-zero.
  2. Take the probabilities P(B|A) and P(A) and compute their product.
  3. Divide the result from Step 2 by P(B).
  4. That's it! You've just successfully applied Bayes' theorem!

How can I prove Bayes theorem?

The simplest way to derive Bayes' theorem is via the definition of conditional probability. Let A, B be two events of non-zero probability. Then:

  1. Write down the conditional probability formula for A conditioned on B: P(A|B) = P(A∩B) / P(B).

  2. Repeat Step 1, swapping the events: P(B|A) = P(A∩B) / P(A).

  3. Solve the above equations for P(A∩B). We obtain P(A|B) × P(B) = P(B|A) × P(A).

  4. Solve for P(A|B): what you get is exactly Bayes' formula: P(A|B) = P(B|A) × P(A) / P(B).

Enter the values of probabilities between 0% and 100%.

Check out 34 similar probability theory and odds calculators 🎲
AccuracyBertrand's box paradoxBertrand's paradox...31 more