homechevron_rightStudychevron_rightMath

Bayes’ theorem

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

This page exists due to the efforts of the following people:

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

Created on PLANETCALC

Bayes’ theorem

Probabilities table

IDParent IDNameValue
Items per page:

Probability tree
 
Bayes' probabilities
Digits after the decimal point: 4
Save the calculation to reuse next time or share with friends.

Theory recap

For 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 that might be related to the event.

It is very useful when we have a two stage process and can only access outcomes of second stage, while first stage is hidden. With Bayes' theorem we can make a prediction about this hidden first stage. Consider this example from wikipedia:

Example

Problem: Suppose that a test for using a particular drug is 99% sensitive and 99% specific. That is, 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 clicking on top checkbox and then clicking on "bin" icon on 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 occured 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 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 outweights the number of true positives.

Comments

533 calculators in total.