# Probability Calculator

## Bayesian Probability (Bayes' Rule) Calculator for Updating the Prior Probability of a Hypothesis using One or Multiple Pieces of Evidence (Conditionally Independent Variables)

Bayes' theorem provides a useful method of rationally determining probabilities by considering a prior probability and updating that with new information. Using this method, this calculator will tell you how likely a hypothesis is to be true based on the available evidence. For example, did you pick a weighted coin out of a bag with weighted and fair coins? Based on various pieces of evidence (that is, tests, events, or observations of things that would inform the likelihood of the hypothesis being true), and how probable those observations would be when the hypothesis is true or not true, it will calculate the probability that the hypothesis is true using Bayes' theorem.

How the calculator works: Bayes' theorem calculates probabilities as follows: P(H|E) = [P(E|H) * P(H)] / [P(E|H) * P(H) + P(E|¬H) * (1-P(H))] where P(H|E) is the probability of a hypothesis being true given some evidence, P(E|H) is the expectation of the evidence being as it is assuming the hypothesis is true, P(H) is the prior probability that the hypothesis is true, and P(E|¬H) is the expectation of the evidence being as it is assuming the hypothesis is not true. In other words, you can calculate the probability that a hypothesis is true given a new piece of data by multiplying how likely the hypothesis was initially by the probability that the data would be as it was if the hypothesis was indeed true, and dividing that by the total probability that the data would have been as it was regardless of if the hypothesis is true. This calculator takes the inputs for the prior probability and expectations for individual pieces of evidence dependent on whether or not the hypothesis is true and displays the resulting posterior probability in the Results section. It also indicates the Bayes' factor, which is the ratio of the expectation for the evidence assuming the hypothesis is true over the expectation for the evidence assuming the hypothesis is false. This Bayes' factor can be regarded as an indicator for the strength of the evidence itself, regardless of the prior probability, with values greater than 1 indicating evidence in favor of the hypothesis and values between 0 and 1 indicating evidence against the hypothesis. (Learn more about Bayes' theorem at Bayes' theorem (Wikipedia), Bayes theorem (YouTube: 3Blue1Brown), You Know I’m All About that Bayes: Crash Course Statistics #24 (YouTube: CrashCourse), A visual guide to Bayesian thinking (YouTube: Julia Galef), and Bayes’ Theorem Problems, Definition and Examples (Statistics How To).) In this calculator, the result from one section becomes the new prior probability for the next section. Take care when deciding what the hypothesis is, what the evidence is, and what probabilities should be assigned into each field, so that the calculation works properly.

One important note here is that the calculation requires the evidence in each section to be conditionally independent given the hypothesis. Meaning, the expected likelihood of the evidence or observation being as it is given the hypothesis being true and given the hypothesis being false should be unaffected by other evidence considered in the calculation, so the same evidence will not influence the results twice. Another way to think about what it means for the evidence variables to be conditionally independent is that if you were to know only whether the hypothesis is true or false, and based on that you have some assigned expectation for the existence of evidence datums E1 and E2, then if you learn evidence E1, that discovery should give you no additional knowledge about the expectation of E2.

To illustrate this with an example, let's say you wanted to calculate the probability of the hypothesis that a bathroom is empty (before knocking on the door). To do this, you may consider two pieces of evidence: E1, that you notice the door is ajar, and E2, that you hear no noises from inside the bathroom. Now, assuming your hypothesis that the bathroom is vacant would be true, let's say you may expect something like an approximately 60% chance of the door being ajar and a 99.99% chance of not hearing noises from inside, while if it was instead occupied you may expect something like an approximately 0.5% chance of the door being ajar and a 10% chance of not hearing noises from inside. And so here, if you would hypothetically suddenly know for certain that the bathroom is indeed vacant, then you know to expect the 99.99% chance of hearing no noises from inside (or if you knew it was occupied, you would know there was the 10% chance of hearing no noises from inside), and if you would then see that the door to the bathroom is ajar, that would not tell you anything more about how likely to expect no noises from inside, and vice versa. This shows that the variables used as evidence are conditionally independent, and this calculator can be used in this situation. If there's a prior probability that at any given time there's a 90% chance that the bathroom is vacant, then factoring in the evidence would come up with an estimated 99.9907% probability that the bathroom is indeed vacant. If, on the other hand, you wanted to use the observation that the door is ajar and that the door is unlocked, those pieces of evidence would not be conditionally independent, because if you hypothetically knew that the bathroom was occupied, finding the door to be ajar would be indicative that it's less likely to be locked than you would have otherwise known. Instead, these two observations would need to be combined as a single point of evidence, namely that the door both ajar and unlocked.

Note also that such decimal precision in the above example would not mean that it is perfectly accurate to that precision. Results are only as good as the inputs, and without more reliable statistics, such an example would only be using estimates for the inputs. In such cases, trying both high end and low end estimates for the input fields can give a range of plausible estimated results.

This calculator can be used for any hypothesis you wish where probabilities can be updated based on evidence (events, observations, or tests), but not all hypotheses will be able to be calculated with the same objectivity. Some hypotheses (such as a coin being fair and not weighted, or a patient having a medical condition given some test results) will have well informed statistics available, and the calculator will in turn provide a reliable probability. Other hypotheses on the other hand may be subject to more subjective and speculative input, like the probability that extraterrestrials have visited Earth based on anecdotal accounts, or the probability that you got the job based on your interview performance.

For these more subjective issues, using Bayesian reasoning to estimate probabilities will still be a rational process which is better than relying on a hunch or feeling, and it will be able to tell you how likely you believe the hypothesis to be true, but it will not provide perfectly reliable probabilities. Additionally, for such hypotheses, if you are inputing more extreme values like 0.9999 or 0.0001, make sure you have justification for your numbers and that you're not being driven by personal biases. Beware of cognitive biases such as confirmation bias which can cause people to interpret information in a way that is more favorable towards their existing beliefs. Too much biased input can result in very skewed results. A single decimal place can make the difference between your hypothesis being calculated as probably true and probably false. (Note especially that in the evidence sections, not counting the Prior Probability section, numbers very close to 0 will affect the final results more than numbers very close to 1.) For best results, be careful that you input reasonable, intellectually honest values into the calculation.

For each section, you can input a value between 0 and 1. 1 correlates to 100%, 0.5 correlates to 50%, 0.00001 correlates to one chance in 100,000, and so on. (In the Prior Probability section the input must be more than 0 and less than 1, and in the evidence sections the inputs must be more than 0, because otherwise the results would be absolutely 100%, 0%, or undefined, and there would be no need to calculate probabilities.) The number may have as many decimal places as you like. In the Prior Probability section, enter a value for how likely you would expect the hypothesis to be true prior to considering the points of evidence calculated later. For example, if your hypothesis is that you picked a weighted coin from a bag, the prior probability would represent the proportion of weighted coins in the bag. If 3 out of 10 coins are weighted, the Prior Probability would be 0.3.

For each of the remaining sections, there are two input boxes. The left input box is "Expectation If Hypothesis Is True." Here, enter a value between 0 and 1 (which equals 0% to 100%) to represent how likely you would expect the given evidence to be as it is assuming the hypothesis is true. For example, if you flipped the coin and it landed on heads, and there’s an 80% chance that a weighted coin would land on heads, enter 0.8 into this field. Entering a higher value in this field represents a higher likelihood that the hypothesis is true.

In the box on the right, "Expectation If Hypothesis Is False," enter a value for how likely you would expect the given evidence to be as it is assuming the hypothesis is false. Continuing the coin example, if you didn’t pick a weighted coin, then it would have had a 50% chance of landing on heads, so enter 0.5 into this field. Entering a higher value in this field represents a lower likelihood that the hypothesis is true.

By default, the calculator displays one evidence section for calculating the effect of one event, test, or observation. If you would like to factor additional observations or pieces of evidence in to the calculation, press the "Add a section" button at the bottom. You can use this to add extra sections and thereby, for this example, factor in the effect of additional coin flips to update the probability with the extra information. If you have added a section and you would rather not factor that particular item into the equation, simply leave both values at 0.5. Any section where the "Expectation If Hypothesis Is True” and the "Expectation If Hypothesis Is False" values are equal will not affect the results of the calculation.

Disclaimer: This calculator is not guaranteed to tell you perfect probabilities. By using this calculator, you accept all responsibility for the results of the calculation and any actions you take based on usage of this calculator. We disclaim all responsibility for any consequences, direct or indirect, arising from use of this page or any features thereof.

Prior probability

Before considering the evidence (i.e. the events, tests, or observations) below, what is the probability that the hypothesis is true? For example, if you are determining the probability that you picked an unfair coin out of a bag with 7 fair coins and 3 unfair coins, the prior probability would be 0.3 (which represents 30%).

Another example of applying Bayes' theorem is in analyzing cancer screening results. For such an example, if you are screening for a particular cancer where 1 out of 40 people in that demographic have that cancer, and you want to know the probability that a person has cancer based on cancer screening results, enter 0.025 (which represents 2.5%) for the prior probability.

If your hypothesis is about a more subjective issue, like the probability that your house is haunted for a more out-there example, you may want to make your prior probability something like the product of how likely you initially expect that houses can be haunted (consider, does the idea seem plausible to you, or has any house been empirically demonstrated to be haunted?) by how frequently you would most likely expect them to be haunted, but keep in mind that for hypotheses such as this the results will be very subjective and speculative and only represent how likely you believe it to be true as opposed to an objective probability of how likely it is to be true.

In the number box below, enter a decimal number somewhere between 0 and 1 (which represents 0% to 100%), and this will be the Prior Probability. For example, 0.5 would represent a 50% initial expectation that the hypothesis is true, or 0.001 would represent a 0.1% initial expectation.

Probability results should display in this area when the page finishes loading.

If it does not, please make sure you have JavaScript enabled.

Share Results

Disclaimer: This calculator is not guaranteed to provide perfect probabilities. By using this calculator, you accept all responsibility for the results of the calculation and any actions you take based on usage of this calculator. We disclaim all responsibility for any consequences, direct or indirect, arising from use of this page or any features thereof.