Bayes' Theorem Calculator
The Bayes' theorem calculator helps you calculate the probability of an event using Bayes' theorem. For a more general introduction to probabilities and how to calculate them, check out our probability calculator. 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.
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 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 which 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 out 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 great breakthrough that has influenced the field of statistics since its inception.
The importance of Bayes' law to statistics can be compared to the importance 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! To find more about it, check the Bayesian inference section below. Or, before you dive in into the article, you may want to check out this great video on the subject:
So how does Bayes' formula actually look? In its most simple 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),
- A and B are certain events.
- P(A) is the probability of event A occurring.
- likewise P(B) is the probability of event B occurring.
- P(A|B) is the conditional probability of event A occurring given that B has happened.
- similarly P(B|A) is the 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:
P(B) = P(A) * P(B|A) + P(not A) * P(B|not A),
P(not A) is the probability of the 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 not shown to have it in the results. Bayes' formula can give you the probabilities of this happening. The table below shows possible outcomes:
|v Test result \ Real situation >||Sick||Healthy|
|Sick||True result||False positive|
|Healthy||False negative||True result|
Bayes' theorem for dummies - Bayes' theorem example
Now that you know the Bayes' theorem formula, you probably want to know how to make calculations using it. Suppose you want to go out but you aren't sure if it is going to 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 percentage 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 that it is going to rain if there was cloudy morning?
To make calculations easier let's convert the percentage to 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 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 the Bayes' theorem calculator does it's magic, feel free to use it instead of doing the calculations by hand.
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 knowns as Bayesian updating, and has a multiplicity 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. ;)