# Bayes' Theorem

**Bayes' theorem** is a fundamental concept in probability theory that allows us to update our beliefs or probabilities based on new evidence. We have already considered the law of total probability, Bayes' theorem is very similar to this law. Let's look at the formulation:

Let's provide explanations:

- We have to split our space of elementary events into
`n`

different**incompatible events**; - We know that event A results from the stochastic experiment. It means that A
**has already occurred**; - We want to understand which segment H we experimented with by calculating the corresponding
**conditional probability**.

## Example

Suppose a diabetes medical test is `90%`

accurate in detecting a specific disease.

The disease is rare and occurs in only `1%`

of the population. If a person tests positive for the disease, what is the probability that the person has the disease?

### Solution

To solve this problem, it is necessary to consider that the test can be false positive and false negative. This is why we need to use Bayes' theorem.

**H₁**: The probability of a randomly selected individual having diabetes is `0.01`

.**H₂**: The probability of a randomly selected individual not having diabetes is `0.99`

.**A**: the test result is positive (diabetes is detected by test).**P(A|H₁)**: the probability that the test detects diabetes and the person is ill equals `0.9`

( true positive result).**P(not A|H₂)**: the probability that the test doesn't detect diabetes and the person is not ill equals `0.9`

(true negative result).**P(A|H₂)**: the probability that the test detects diabetes and the person is not ill equals 1 - P(not A|H₂) = `0.1`

(false positive result).

We have to find **P(H₁|A)** - the probability that a person is really ill if the test detects diabetes

Everything was clear?

Course Content

Probability Theory Basics

## Probability Theory Basics

5. Covariance and Correlation

# Bayes' Theorem

**Bayes' theorem** is a fundamental concept in probability theory that allows us to update our beliefs or probabilities based on new evidence. We have already considered the law of total probability, Bayes' theorem is very similar to this law. Let's look at the formulation:

Let's provide explanations:

- We have to split our space of elementary events into
`n`

different**incompatible events**; - We know that event A results from the stochastic experiment. It means that A
**has already occurred**; - We want to understand which segment H we experimented with by calculating the corresponding
**conditional probability**.

## Example

Suppose a diabetes medical test is `90%`

accurate in detecting a specific disease.

The disease is rare and occurs in only `1%`

of the population. If a person tests positive for the disease, what is the probability that the person has the disease?

### Solution

To solve this problem, it is necessary to consider that the test can be false positive and false negative. This is why we need to use Bayes' theorem.

**H₁**: The probability of a randomly selected individual having diabetes is `0.01`

.**H₂**: The probability of a randomly selected individual not having diabetes is `0.99`

.**A**: the test result is positive (diabetes is detected by test).**P(A|H₁)**: the probability that the test detects diabetes and the person is ill equals `0.9`

( true positive result).**P(not A|H₂)**: the probability that the test doesn't detect diabetes and the person is not ill equals `0.9`

(true negative result).**P(A|H₂)**: the probability that the test detects diabetes and the person is not ill equals 1 - P(not A|H₂) = `0.1`

(false positive result).

We have to find **P(H₁|A)** - the probability that a person is really ill if the test detects diabetes

Everything was clear?