# 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 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.

Save the calculation to reuse next time, toextensionembed in your website orshareshare 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

, given that

Definition: Two events are called independent if and only if .

Definition: Two events A and B are mutually exclusive if and they are called possible if

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

Theorem: Two possible independent events are not mutually exclusive.

Definition: Let be a set and let be a collection of subsets of . The collection is called a partition of if

,

for

Theorem: If the events constitute a partition of the sample space S and for , then for any event A in S

Theorem: If the events constitute a partition of the sample space S and for , then for any event A in S such that ,

This theorem is called **Bayes' Theorem**. is called **prior probability**, 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:

- Select default data in the table and delete it clicking on top checkbox and then clicking on "bin" icon on table header.
- 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.

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