science-notes/source/statistics/bayes_theorem.rst
2023-10-17 08:43:37 +02:00

37 lines
1.3 KiB
ReStructuredText

Bayes' Theorem
---------------
This page is inpired from:
* `MathIsFun <https://www.mathsisfun.com/data/bayes-theorem.html>`__
* `Wikipedia <https://en.wikipedia.org/wiki/Bayes%27_theorem>`__
Theorem
=========
The Bayes's theorem describes the probability of an event, based on prior knowledge of conditions
that might be related to the event.
To compute :math:`P(A|B)`, in other words, the probability of the event :math:`A` to happen, knowing that :math:`B`
already happen, the following drawing can be used:
.. figure:: figures/bayes_theorem.svg
:align: center
:width: 400px
:math:`\,`
The red area represents :math:`P(B)=a3+a4`. Thus, to compute :math:`P(A|B)` we do:
.. math::
P(A|B)=\frac{a3}{a3+a4}=\frac{P(A)P(B|A)}{P(A)P(B|A)+P(\neg A)P(B|\neg A)}=\frac{P(A)P(B|A)}{P(B)}
This final formula is the Baye's Theorem.
See the `3Blue1Brown video <https://www.youtube.com/watch?v=HZGCoVF3YvM>`__ for a better understanding.
Example
=========
Hunter says she is itchy. There is a test for Allergy to Cats, but this test is not always right:
For people that really do have the allergy, the test says "Yes" 80% of the time
For people that do not have the allergy, the test says "Yes" 10% of the time ("false positive")
If 1% of the population have the allergy, and Hunter's test says "Yes", what are the chances that Hunter really has the allergy?