homechevron_rightProfessionalchevron_rightStatistics

Bayes’ theorem

This online calculator calculates posterior probabilities according to Bayes’ theorem.

This online calculator calculates posterior probabilities according to Bayes’ theorem. It can be used as a solver for Bayes' theorem problems. To use it, you need to input the "probability tree" configuration. Below the calculator, you can find examples of how to do this as well theory recap.

PLANETCALC, Bayes’ theorem

Bayes’ theorem

Probabilities table

arrow_upwardarrow_downwardIDarrow_upwardarrow_downwardParent IDarrow_upwardarrow_downwardNamearrow_upwardarrow_downwardValue
Items per page:

Probability tree
 
The file is very large. Browser slowdown may occur during loading and creation.
Digits after the decimal point: 4

Theory recap

For a quick theory recap, we need some formulas.

Definition: The conditional probability of an event A, given that event B has occurred, is defined as
P(A/B)=\frac{P(A \cap B)}{P(B)}, given that P(B)>0

Definition: Two events are called independent if and only if P(A \cap B)=P(A) P(B).

Definition: Two events A and B are mutually exclusive if A \cap B= \emptyset and they are called possible if P(A) \not= 0 \not= P(B)

Theorem: Two possible mutually exclusive events are always dependent (that is, not independent).

Theorem: Two possible independent events are not mutually exclusive.

Definition: Let S be a set and let \mathcal P = \{A_i\}_{i=1}^{m} be a collection of subsets of S. The collection \mathcal P is called a partition of S if
S=\bigcup_{i=1}^{m} A_i \\ A_i \cap A_j = \emptyset,
for i \not= j

Theorem: If the events \{B_i\}_{i=1}^{m} constitute a partition of the sample space S and P(B_i) \not= 0 for i = 1, 2, ...,m, then for any event A in S
P(A)=\sum_{i=1}^{m} P(B_i)P(A/B_i)

Theorem: If the events \{B_i\}_{i=1}^{m} constitute a partition of the sample space S and P(B_i) \not= 0 for i = 1, 2, ...,m, then for any event A in S such that P(A) \not= 0,
P(B_{k}/A)=\frac{P(B_{k}) P(A/B_{k})}{\sum_{i=1}^{m} P(B_i)P(A/B_i)}

This theorem is called Bayes' Theorem. P(B_{k}) is called prior probability, P(B_{k}/A) is called posterior probability.

In probability theory and statistics, Bayes’ theorem (aka Bayes’ law or Bayes' rule) deals with so-called backward conditional probabilities. It describes the probability of an event based on prior knowledge of conditions related to the event.

It is handy when we have a two-stage process and can only access the second stage's outcomes while the first stage is hidden. With Bayes' theorem, we can predict this hidden first stage. Consider this example from wikipedia:

Example

Problem: Suppose a test for using a particular drug is 99% sensitive and 99% specific. The test will produce 99% true positive results for drug users and 99% true negative results for non-drug users. Suppose that 0.5% of people are users of the drug. What is the probability that a randomly selected individual with a positive test is a user?

How to use the calculator:

  1. Select default data in the table and delete it (click on the top checkbox to select all, then click on the "bin" icon on a table header).
  2. Add probability tree configuration.

After that, you will get the table with all backward conditional probabilities. The row which reads Probability of 'User' given 'Positive test' has occurred is the answer, and it is 0.3322.

Show me

So, we are not actually interested in the second stage outcome - test outcome, but we are interested in the first stage outcome - is an individual user or not. And Bayes' theorem gives us an answer - there is only 0.3322 probability. Why? Even though the test appears to be highly accurate, the number of non-users is large compared to the number of users. The number of false positives outweighs the number of true positives.

URL copied to clipboard
Creative Commons Attribution/Share-Alike License 3.0 (Unported) PLANETCALC, Bayes’ theorem

Comments