Bayes' Theorem
Statement
For events and with :
In measure-theoretic notation, with denoting the conditional measure:
Visualization
Disease testing. A disease affects 1% of the population. A test is 99% sensitive (true positive rate) and 99% specific (true negative rate).
| Test | Test | Total | |
|---|---|---|---|
| Disease | 99 | 1 | 100 |
| No disease | 99 | 9801 | 9900 |
| Total | 198 | 9802 | 10000 |
- Prior:
- Likelihood:
- Marginal:
Posterior via Bayes:
Despite a 99%-accurate test, only half of positive results indicate true disease — a striking consequence of the low base rate.
Proof Sketch
From the definition and symmetry :
The identity is the multiplication rule.
Connections
Bayes' theorem is the foundation of Bayesian inference, where the prior is updated by evidence to yield the posterior . The law of total probability decomposes the denominator into cases. In the context of this showcase, the rigorous measure-theoretic conditional measure underpins Markov's InequalityMarkov's InequalityA non-negative random variable rarely exceeds a multiple of its expectationRead more → and Chebyshev's InequalityChebyshev's InequalityA random variable rarely deviates from its mean by more than a few standard deviationsRead more → — all three live in the same -algebra framework.
Lean4 Proof
The proof uses ProbabilityTheory.cond_eq_inv_mul_cond_mul from Mathlib.Probability.ConditionalProbability (Mathlib v4.28.0), which is explicitly labelled Bayes' Theorem in Mathlib.
cond_eq_inv_mul_cond_mul is proved in Mathlib by unfolding the conditional measure definition , rewriting via cond_mul_eq_inter, and simplifying with Set.inter_comm.
Lean4 Proof
import Mathlib.Probability.ConditionalProbability
namespace MoonMath
open MeasureTheory ProbabilityTheory
/-- **Bayes' theorem** (measure-theoretic form).
`μ[A | B] = (μ B)⁻¹ * μ[B | A] * μ A`
for measurable `A`, `B` and finite `μ`. -/
theorem bayes_theorem
{Ω : Type*} {m : MeasurableSpace Ω} (μ : Measure Ω)
[IsFiniteMeasure μ]
{A B : Set Ω} (hA : MeasurableSet A) (hB : MeasurableSet B) :
μ[A | B] = (μ B)⁻¹ * μ[B | A] * μ A :=
cond_eq_inv_mul_cond_mul hB hA μ
end MoonMathReferenced by
- Absolutely Continuous FunctionsAnalysis
- Monotone Class TheoremAnalysis
- Law of Total ExpectationProbability