/-- Prove Chebyshev's inequality from Markov's inequality.
Hints: (1) show `{ω | c ≤ |X ω - μ[X]|} = {ω | c ^ 2 ≤ (X ω - μ[X]) ^ 2}` using `sq_le_sq`
and `abs_of_pos`; (2) `(hX.sub (memLp_const _)).integrable_sq` gives integrability of the
square; (3) `variance_eq_integral` rewrites the variance as an integral; (4) finish with
Markov's inequality `mul_meas_ge_le_integral_of_nonneg`. -/
theorem chebyshev [IsProbabilityMeasure μ] {X : Ω → ℝ} (hX : MemLp X 2 μ) {c : ℝ}
(hc : 0 < c) : c ^ 2 * μ.real {ω | c ≤ |X ω - μ[X]|} ≤ Var[X; μ] := by
sorryShow the compiled solution
/-- **Chebyshev's inequality**, proved from Markov's as in the lesson: for `X` with finite
variance and `c > 0`, `c² · P(|X − E X| ≥ c) ≤ Var X`. Proof: `|X − EX| ≥ c` happens exactly
when `(X − EX)² ≥ c²`; apply Markov's inequality to the non-negative variable `(X − EX)²`,
whose expectation is `Var X`. -/
theorem chebyshev [IsProbabilityMeasure μ] {X : Ω → ℝ} (hX : MemLp X 2 μ) {c : ℝ}
(hc : 0 < c) : c ^ 2 * μ.real {ω | c ≤ |X ω - μ[X]|} ≤ Var[X; μ] := by
set m := μ[X]
-- The events `{c ≤ |X − m|}` and `{c² ≤ (X − m)²}` are equal.
have hset : {ω | c ≤ |X ω - m|} = {ω | c ^ 2 ≤ (X ω - m) ^ 2} := by
ext ω
simp only [Set.mem_ofPred_eq]
rw [sq_le_sq, abs_of_pos hc]
-- `(X − m)²` is non-negative and integrable.
have hint : Integrable (fun ω => (X ω - m) ^ 2) μ :=
(hX.sub (memLp_const m)).integrable_sq
have hnn : 0 ≤ᵐ[μ] fun ω => (X ω - m) ^ 2 := Eventually.of_forall fun ω => sq_nonneg _
rw [hset, variance_eq_integral hX.aestronglyMeasurable.aemeasurable]
exact mul_meas_ge_le_integral_of_nonneg hnn hint (c ^ 2)Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ProbabilityTheory.leanTry it in the Lean web editor