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

#### Probabilities table

IDParent IDNameValue
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).