The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V20. Probability

Mathlib.Probability.Moments.Variance

68 declarations. Mathlib docs · Source

Variance of random variables

We define the variance of a real-valued random variable as Var[X] = 𝔼[(X - 𝔼[X])^2] (in the ProbabilityTheory locale).

Main definitions

  • ProbabilityTheory.evariance: the variance of a real-valued random variable as an extended non-negative real.
  • ProbabilityTheory.variance: the variance of a real-valued random variable as a real number.

Main results

  • ProbabilityTheory.variance_le_expectation_sq: the inequality Var[X] ≤ 𝔼[X^2].
  • ProbabilityTheory.meas_ge_le_variance_div_sq: Chebyshev's inequality, i.e., ℙ {ω | c ≤ |X ω - 𝔼[X]|} ≤ ENNReal.ofReal (Var[X] / c ^ 2).
  • ProbabilityTheory.meas_ge_le_evariance_div_sq: Chebyshev's inequality formulated with evariance without requiring the random variables to be L².
  • ProbabilityTheory.IndepFun.variance_add: the variance of the sum of two independent random variables is the sum of the variances.
  • ProbabilityTheory.IndepFun.variance_sum: the variance of a finite sum of pairwise independent random variables is the sum of the variances.
  • ProbabilityTheory.variance_le_sub_mul_sub: the variance of a random variable X satisfying a ≤ X ≤ b almost everywhere is at most (b - 𝔼 X) * (𝔼 X - a).
  • ProbabilityTheory.variance_le_sq_of_bounded: the variance of a random variable X satisfying a ≤ X ≤ b almost everywhere is at most ((b - a) / 2) ^ 2.

def ProbabilityTheory.evariance E3 #

{Ω : Type u_1} → {mΩ : MeasurableSpace Ω} → (Ω → ℝ) → MeasureTheory.Measure Ω → ENNReal

The ℝ≥0∞-valued variance of a real-valued random variable defined as the Lebesgue integral of ‖X - 𝔼[X]‖^2.

def ProbabilityTheory.variance E3 #

{Ω : Type u_1} → {mΩ : MeasurableSpace Ω} → (Ω → ℝ) → MeasureTheory.Measure Ω → ℝ

The ℝ-valued variance of a real-valued random variable defined by applying ENNReal.toReal to evariance.

def ProbabilityTheory.«termEVar[_;_]» E1 #

Lean.ParserDescr

The ℝ≥0∞-valued variance of the real-valued random variable X according to the measure μ.

This is defined as the Lebesgue integral of (X - 𝔼[X])^2.

def ProbabilityTheory.«termEVar[_]» E1 #

Lean.ParserDescr

The ℝ≥0∞-valued variance of the real-valued random variable X according to the volume measure.

This is defined as the Lebesgue integral of (X - 𝔼[X])^2.

def ProbabilityTheory.«termVar[_;_]» E1 #

Lean.ParserDescr

The ℝ-valued variance of the real-valued random variable X according to the measure μ.

It is set to 0 if X has infinite variance.

def ProbabilityTheory.«termVar[_]» E1 #

Lean.ParserDescr

The ℝ-valued variance of the real-valued random variable X according to the volume measure.

It is set to 0 if X has infinite variance.

theorem ProbabilityTheory.evariance_congr E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X Y : Ω → ℝ} {μ : MeasureTheory.Measure Ω},
  X =ᵐ[μ] Y → ProbabilityTheory.evariance X μ = ProbabilityTheory.evariance Y μ

theorem ProbabilityTheory.variance_congr E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X Y : Ω → ℝ} {μ : MeasureTheory.Measure Ω},
  X =ᵐ[μ] Y → ProbabilityTheory.variance X μ = ProbabilityTheory.variance Y μ

theorem ProbabilityTheory.evariance_zero_measure E0 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X : Ω → ℝ}, ProbabilityTheory.evariance X 0 = 0

theorem ProbabilityTheory.variance_zero_measure E0 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X : Ω → ℝ}, ProbabilityTheory.variance X 0 = 0

theorem ProbabilityTheory.evariance_lt_top E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X : Ω → ℝ} {μ : MeasureTheory.Measure Ω} [MeasureTheory.IsFiniteMeasure μ],
  MeasureTheory.MemLp X 2 μ → ProbabilityTheory.evariance X μ < ⊤

theorem ProbabilityTheory.evariance_ne_top E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X : Ω → ℝ} {μ : MeasureTheory.Measure Ω} [MeasureTheory.IsFiniteMeasure μ],
  MeasureTheory.MemLp X 2 μ → ProbabilityTheory.evariance X μ ≠ ⊤

theorem ProbabilityTheory.evariance_eq_top E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X : Ω → ℝ} {μ : MeasureTheory.Measure Ω} [MeasureTheory.IsFiniteMeasure μ],
  MeasureTheory.AEStronglyMeasurable X μ → ¬MeasureTheory.MemLp X 2 μ → ProbabilityTheory.evariance X μ = ⊤

theorem ProbabilityTheory.evariance_lt_top_iff_memLp E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X : Ω → ℝ} {μ : MeasureTheory.Measure Ω} [MeasureTheory.IsFiniteMeasure μ],
  MeasureTheory.AEStronglyMeasurable X μ → (ProbabilityTheory.evariance X μ < ⊤ ↔ MeasureTheory.MemLp X 2 μ)

theorem ProbabilityTheory.evariance_eq_top_iff E0 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X : Ω → ℝ} {μ : MeasureTheory.Measure Ω} [MeasureTheory.IsFiniteMeasure μ],
  MeasureTheory.AEStronglyMeasurable X μ → (ProbabilityTheory.evariance X μ = ⊤ ↔ ¬MeasureTheory.MemLp X 2 μ)

theorem ProbabilityTheory.variance_of_not_memLp E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X : Ω → ℝ} {μ : MeasureTheory.Measure Ω} [MeasureTheory.IsFiniteMeasure μ],
  MeasureTheory.AEStronglyMeasurable X μ → ¬MeasureTheory.MemLp X 2 μ → ProbabilityTheory.variance X μ = 0

theorem ProbabilityTheory.memLp_two_of_variance_ne_zero E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X : Ω → ℝ} {μ : MeasureTheory.Measure Ω} [MeasureTheory.IsFiniteMeasure μ],
  MeasureTheory.AEStronglyMeasurable X μ → ProbabilityTheory.variance X μ ≠ 0 → MeasureTheory.MemLp X 2 μ

theorem ProbabilityTheory.ofReal_variance E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X : Ω → ℝ} {μ : MeasureTheory.Measure Ω} [MeasureTheory.IsFiniteMeasure μ],
  MeasureTheory.MemLp X 2 μ → ENNReal.ofReal (ProbabilityTheory.variance X μ) = ProbabilityTheory.evariance X μ

theorem MeasureTheory.MemLp.evariance_lt_top E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X : Ω → ℝ} {μ : MeasureTheory.Measure Ω} [MeasureTheory.IsFiniteMeasure μ],
  MeasureTheory.MemLp X 2 μ → ProbabilityTheory.evariance X μ < ⊤

Alias of ProbabilityTheory.evariance_lt_top.

theorem MeasureTheory.MemLp.evariance_ne_top E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X : Ω → ℝ} {μ : MeasureTheory.Measure Ω} [MeasureTheory.IsFiniteMeasure μ],
  MeasureTheory.MemLp X 2 μ → ProbabilityTheory.evariance X μ ≠ ⊤

Alias of ProbabilityTheory.evariance_ne_top.

theorem MeasureTheory.MemLp.ofReal_variance_eq E0 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X : Ω → ℝ} {μ : MeasureTheory.Measure Ω} [MeasureTheory.IsFiniteMeasure μ],
  MeasureTheory.MemLp X 2 μ → ENNReal.ofReal (ProbabilityTheory.variance X μ) = ProbabilityTheory.evariance X μ

Alias of ProbabilityTheory.ofReal_variance.

theorem ProbabilityTheory.evariance_eq_lintegral_ofReal E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} (X : Ω → ℝ) (μ : MeasureTheory.Measure Ω),
  ProbabilityTheory.evariance X μ = ∫⁻ (ω : Ω), ENNReal.ofReal ((X ω - ∫ (x : Ω), X x ∂μ) ^ 2) ∂μ

theorem ProbabilityTheory.variance_eq_integral E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X : Ω → ℝ} {μ : MeasureTheory.Measure Ω},
  AEMeasurable X μ → ProbabilityTheory.variance X μ = ∫ (ω : Ω), (X ω - ∫ (x : Ω), X x ∂μ) ^ 2 ∂μ

theorem ProbabilityTheory.ae_eq_integral_of_variance_eq_zero E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X : Ω → ℝ} {μ : MeasureTheory.Measure Ω} [MeasureTheory.IsFiniteMeasure μ],
  MeasureTheory.MemLp X 2 μ → ProbabilityTheory.variance X μ = 0 → ∀ᵐ (ω : Ω) ∂μ, X ω = ∫ (x : Ω), X x ∂μ

A random variable with variance 0 is almost surely constant.

theorem ProbabilityTheory.variance_of_integral_eq_zero E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X : Ω → ℝ} {μ : MeasureTheory.Measure Ω},
  AEMeasurable X μ → ∫ (x : Ω), X x ∂μ = 0 → ProbabilityTheory.variance X μ = ∫ (ω : Ω), X ω ^ 2 ∂μ

theorem ProbabilityTheory.evariance_zero E0 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : MeasureTheory.Measure Ω}, ProbabilityTheory.evariance 0 μ = 0

theorem ProbabilityTheory.evariance_eq_zero_iff E0 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X : Ω → ℝ} {μ : MeasureTheory.Measure Ω},
  AEMeasurable X μ → (ProbabilityTheory.evariance X μ = 0 ↔ X =ᵐ[μ] fun x ↦ ∫ (x : Ω), X x ∂μ)

theorem ProbabilityTheory.evariance_mul E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} (c : ℝ) (X : Ω → ℝ) (μ : MeasureTheory.Measure Ω),
  ProbabilityTheory.evariance (fun ω ↦ c * X ω) μ = ENNReal.ofReal (c ^ 2) * ProbabilityTheory.evariance X μ

theorem ProbabilityTheory.variance_zero E0 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} (μ : MeasureTheory.Measure Ω), ProbabilityTheory.variance 0 μ = 0

theorem ProbabilityTheory.covariance_self E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : MeasureTheory.Measure Ω} {X : Ω → ℝ},
  AEMeasurable X μ → ProbabilityTheory.covariance X X μ = ProbabilityTheory.variance X μ

theorem ProbabilityTheory.variance_nonneg E0 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} (X : Ω → ℝ) (μ : MeasureTheory.Measure Ω), 0 ≤ ProbabilityTheory.variance X μ

theorem ProbabilityTheory.variance_const_mul E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} (c : ℝ) (X : Ω → ℝ) (μ : MeasureTheory.Measure Ω),
  ProbabilityTheory.variance (fun ω ↦ c * X ω) μ = c ^ 2 * ProbabilityTheory.variance X μ

theorem ProbabilityTheory.variance_mul_const E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} (c : ℝ) (X : Ω → ℝ) (μ : MeasureTheory.Measure Ω),
  ProbabilityTheory.variance (fun ω ↦ X ω * c) μ = ProbabilityTheory.variance X μ * c ^ 2

theorem ProbabilityTheory.variance_smul E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} (c : ℝ) (X : Ω → ℝ) (μ : MeasureTheory.Measure Ω),
  ProbabilityTheory.variance (c • X) μ = c ^ 2 * ProbabilityTheory.variance X μ

theorem ProbabilityTheory.variance_smul' E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {A : Type u_2} [inst : CommSemiring A] [inst_1 : Algebra A ℝ] (c : A)
  (X : Ω → ℝ) (μ : MeasureTheory.Measure Ω),
  ProbabilityTheory.variance (c • X) μ = c ^ 2 • ProbabilityTheory.variance X μ

theorem ProbabilityTheory.variance_eq_sub E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : MeasureTheory.Measure Ω} [MeasureTheory.IsProbabilityMeasure μ]
  {X : Ω → ℝ},
  MeasureTheory.MemLp X 2 μ → ProbabilityTheory.variance X μ = ∫ (x : Ω), (X ^ 2) x ∂μ - (∫ (x : Ω), X x ∂μ) ^ 2

theorem ProbabilityTheory.variance_add_const E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X : Ω → ℝ} {μ : MeasureTheory.Measure Ω}
  [MeasureTheory.IsProbabilityMeasure μ],
  MeasureTheory.AEStronglyMeasurable X μ →
    ∀ (c : ℝ), ProbabilityTheory.variance (fun ω ↦ X ω + c) μ = ProbabilityTheory.variance X μ

theorem ProbabilityTheory.variance_const_add E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X : Ω → ℝ} {μ : MeasureTheory.Measure Ω}
  [MeasureTheory.IsProbabilityMeasure μ],
  MeasureTheory.AEStronglyMeasurable X μ →
    ∀ (c : ℝ), ProbabilityTheory.variance (fun ω ↦ c + X ω) μ = ProbabilityTheory.variance X μ

theorem ProbabilityTheory.variance_fun_neg E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X : Ω → ℝ} {μ : MeasureTheory.Measure Ω},
  ProbabilityTheory.variance (fun ω ↦ -X ω) μ = ProbabilityTheory.variance X μ

theorem ProbabilityTheory.variance_neg E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X : Ω → ℝ} {μ : MeasureTheory.Measure Ω},
  ProbabilityTheory.variance (-X) μ = ProbabilityTheory.variance X μ

theorem ProbabilityTheory.variance_sub_const E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X : Ω → ℝ} {μ : MeasureTheory.Measure Ω}
  [MeasureTheory.IsProbabilityMeasure μ],
  MeasureTheory.AEStronglyMeasurable X μ →
    ∀ (c : ℝ), ProbabilityTheory.variance (fun ω ↦ X ω - c) μ = ProbabilityTheory.variance X μ

theorem ProbabilityTheory.variance_const_sub E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X : Ω → ℝ} {μ : MeasureTheory.Measure Ω}
  [MeasureTheory.IsProbabilityMeasure μ],
  MeasureTheory.AEStronglyMeasurable X μ →
    ∀ (c : ℝ), ProbabilityTheory.variance (fun ω ↦ c - X ω) μ = ProbabilityTheory.variance X μ

theorem ProbabilityTheory.variance_add E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X Y : Ω → ℝ} {μ : MeasureTheory.Measure Ω} [MeasureTheory.IsFiniteMeasure μ],
  MeasureTheory.MemLp X 2 μ →
    MeasureTheory.MemLp Y 2 μ →
      ProbabilityTheory.variance (X + Y) μ =
        ProbabilityTheory.variance X μ + 2 * ProbabilityTheory.covariance X Y μ + ProbabilityTheory.variance Y μ

theorem ProbabilityTheory.variance_fun_add E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X Y : Ω → ℝ} {μ : MeasureTheory.Measure Ω} [MeasureTheory.IsFiniteMeasure μ],
  MeasureTheory.MemLp X 2 μ →
    MeasureTheory.MemLp Y 2 μ →
      ProbabilityTheory.variance (fun ω ↦ X ω + Y ω) μ =
        ProbabilityTheory.variance X μ + 2 * ProbabilityTheory.covariance X Y μ + ProbabilityTheory.variance Y μ

theorem ProbabilityTheory.variance_sub E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X Y : Ω → ℝ} {μ : MeasureTheory.Measure Ω} [MeasureTheory.IsFiniteMeasure μ],
  MeasureTheory.MemLp X 2 μ →
    MeasureTheory.MemLp Y 2 μ →
      ProbabilityTheory.variance (X - Y) μ =
        ProbabilityTheory.variance X μ - 2 * ProbabilityTheory.covariance X Y μ + ProbabilityTheory.variance Y μ

theorem ProbabilityTheory.variance_fun_sub E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X Y : Ω → ℝ} {μ : MeasureTheory.Measure Ω} [MeasureTheory.IsFiniteMeasure μ],
  MeasureTheory.MemLp X 2 μ →
    MeasureTheory.MemLp Y 2 μ →
      ProbabilityTheory.variance (fun ω ↦ X ω - Y ω) μ =
        ProbabilityTheory.variance X μ - 2 * ProbabilityTheory.covariance X Y μ + ProbabilityTheory.variance Y μ

theorem ProbabilityTheory.variance_sum' E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : MeasureTheory.Measure Ω} {ι : Type u_2} {s : Finset ι} {X : ι → Ω → ℝ}
  [MeasureTheory.IsFiniteMeasure μ],
  (∀ i ∈ s, MeasureTheory.MemLp (X i) 2 μ) →
    ProbabilityTheory.variance (∑ i ∈ s, X i) μ = ∑ i ∈ s, ∑ j ∈ s, ProbabilityTheory.covariance (X i) (X j) μ

theorem ProbabilityTheory.variance_sum E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : MeasureTheory.Measure Ω} {ι : Type u_2} {X : ι → Ω → ℝ}
  [MeasureTheory.IsFiniteMeasure μ] [inst : Fintype ι],
  (∀ (i : ι), MeasureTheory.MemLp (X i) 2 μ) →
    ProbabilityTheory.variance (∑ i, X i) μ = ∑ i, ∑ j, ProbabilityTheory.covariance (X i) (X j) μ

theorem ProbabilityTheory.variance_fun_sum' E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : MeasureTheory.Measure Ω} {ι : Type u_2} {s : Finset ι} {X : ι → Ω → ℝ}
  [MeasureTheory.IsFiniteMeasure μ],
  (∀ i ∈ s, MeasureTheory.MemLp (X i) 2 μ) →
    ProbabilityTheory.variance (fun ω ↦ ∑ i ∈ s, X i ω) μ = ∑ i ∈ s, ∑ j ∈ s, ProbabilityTheory.covariance (X i) (X j) μ

theorem ProbabilityTheory.variance_fun_sum E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : MeasureTheory.Measure Ω} {ι : Type u_2} {X : ι → Ω → ℝ}
  [MeasureTheory.IsFiniteMeasure μ] [inst : Fintype ι],
  (∀ (i : ι), MeasureTheory.MemLp (X i) 2 μ) →
    ProbabilityTheory.variance (fun ω ↦ ∑ i, X i ω) μ = ∑ i, ∑ j, ProbabilityTheory.covariance (X i) (X j) μ

theorem ProbabilityTheory.variance_dirac E0 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X : Ω → ℝ} [MeasurableSingletonClass Ω] (x : Ω),
  ProbabilityTheory.variance X (MeasureTheory.Measure.dirac x) = 0

theorem ProbabilityTheory.variance_map E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {X : Ω → ℝ} {Ω' : Type u_3} {mΩ' : MeasurableSpace Ω'}
  {μ : MeasureTheory.Measure Ω'} {Y : Ω' → Ω},
  AEMeasurable X (MeasureTheory.Measure.map Y μ) →
    AEMeasurable Y μ →
      ProbabilityTheory.variance X (MeasureTheory.Measure.map Y μ) = ProbabilityTheory.variance (X ∘ Y) μ

theorem MeasureTheory.MeasurePreserving.variance_fun_comp E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : MeasureTheory.Measure Ω} {Ω' : Type u_3} {mΩ' : MeasurableSpace Ω'}
  {ν : MeasureTheory.Measure Ω'} {X : Ω → Ω'},
  MeasureTheory.MeasurePreserving X μ ν →
    ∀ {f : Ω' → ℝ}, AEMeasurable f ν → ProbabilityTheory.variance (fun ω ↦ f (X ω)) μ = ProbabilityTheory.variance f ν

theorem ProbabilityTheory.variance_map_equiv E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {Ω' : Type u_3} {mΩ' : MeasurableSpace Ω'} {μ : MeasureTheory.Measure Ω'}
  (X : Ω → ℝ) (Y : Ω' ≃ᵐ Ω),
  ProbabilityTheory.variance X (MeasureTheory.Measure.map (⇑Y) μ) = ProbabilityTheory.variance (X ∘ ⇑Y) μ

theorem ProbabilityTheory.variance_id_map E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : MeasureTheory.Measure Ω} {X : Ω → ℝ},
  AEMeasurable X μ → ProbabilityTheory.variance id (MeasureTheory.Measure.map X μ) = ProbabilityTheory.variance X μ

theorem ProbabilityTheory.variance_le_expectation_sq E3 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : MeasureTheory.Measure Ω} [MeasureTheory.IsProbabilityMeasure μ]
  {X : Ω → ℝ}, MeasureTheory.AEStronglyMeasurable X μ → ProbabilityTheory.variance X μ ≤ ∫ (x : Ω), (X ^ 2) x ∂μ

theorem ProbabilityTheory.evariance_def' E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : MeasureTheory.Measure Ω} [MeasureTheory.IsProbabilityMeasure μ]
  {X : Ω → ℝ},
  MeasureTheory.AEStronglyMeasurable X μ →
    ProbabilityTheory.evariance X μ = ∫⁻ (ω : Ω), ‖X ω‖ₑ ^ 2 ∂μ - ENNReal.ofReal ((∫ (x : Ω), X x ∂μ) ^ 2)

theorem ProbabilityTheory.meas_ge_le_evariance_div_sq E3 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : MeasureTheory.Measure Ω} {X : Ω → ℝ},
  MeasureTheory.AEStronglyMeasurable X μ →
    ∀ {c : NNReal}, c ≠ 0 → μ {ω | ↑c ≤ |X ω - ∫ (x : Ω), X x ∂μ|} ≤ ProbabilityTheory.evariance X μ / ↑c ^ 2

Chebyshev's inequality for ℝ≥0∞-valued variance.

theorem ProbabilityTheory.meas_ge_le_variance_div_sq E3 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : MeasureTheory.Measure Ω} [MeasureTheory.IsFiniteMeasure μ] {X : Ω → ℝ},
  MeasureTheory.MemLp X 2 μ →
    ∀ {c : ℝ}, 0 < c → μ {ω | c ≤ |X ω - ∫ (x : Ω), X x ∂μ|} ≤ ENNReal.ofReal (ProbabilityTheory.variance X μ / c ^ 2)

Chebyshev's inequality: one can control the deviation probability of a real random variable from its expectation in terms of the variance.

theorem ProbabilityTheory.IndepFun.variance_add E3 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : MeasureTheory.Measure Ω} {X Y : Ω → ℝ},
  MeasureTheory.MemLp X 2 μ →
    MeasureTheory.MemLp Y 2 μ →
      ProbabilityTheory.IndepFun X Y μ →
        ProbabilityTheory.variance (X + Y) μ = ProbabilityTheory.variance X μ + ProbabilityTheory.variance Y μ

The variance of the sum of two independent random variables is the sum of the variances.

theorem ProbabilityTheory.IndepFun.variance_fun_add E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : MeasureTheory.Measure Ω} {X Y : Ω → ℝ},
  MeasureTheory.MemLp X 2 μ →
    MeasureTheory.MemLp Y 2 μ →
      ProbabilityTheory.IndepFun X Y μ →
        ProbabilityTheory.variance (fun ω ↦ X ω + Y ω) μ =
          ProbabilityTheory.variance X μ + ProbabilityTheory.variance Y μ

The variance of the sum of two independent random variables is the sum of the variances.

theorem ProbabilityTheory.IndepFun.variance_sum E3 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : MeasureTheory.Measure Ω} {ι : Type u_3} {X : ι → Ω → ℝ} {s : Finset ι},
  (∀ i ∈ s, MeasureTheory.MemLp (X i) 2 μ) →
    ((↑s).Pairwise fun i j ↦ ProbabilityTheory.IndepFun (X i) (X j) μ) →
      ProbabilityTheory.variance (∑ i ∈ s, X i) μ = ∑ i ∈ s, ProbabilityTheory.variance (X i) μ

The variance of a finite sum of pairwise independent random variables is the sum of the variances.

theorem ProbabilityTheory.variance_sum_pi E1 #

∀ {ι : Type u_2} [inst : Fintype ι] {Ω : ι → Type u_3} {mΩ : (i : ι) → MeasurableSpace (Ω i)}
  {μ : (i : ι) → MeasureTheory.Measure (Ω i)} [∀ (i : ι), MeasureTheory.IsProbabilityMeasure (μ i)]
  {X : (i : ι) → Ω i → ℝ},
  (∀ (i : ι), MeasureTheory.MemLp (X i) 2 (μ i)) →
    ProbabilityTheory.variance (∑ i, fun ω ↦ X i (ω i)) (MeasureTheory.Measure.pi μ) =
      ∑ i, ProbabilityTheory.variance (X i) (μ i)

theorem ProbabilityTheory.variance_le_sub_mul_sub E3 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : MeasureTheory.Measure Ω} [MeasureTheory.IsProbabilityMeasure μ] {a b : ℝ}
  {X : Ω → ℝ},
  (∀ᵐ (ω : Ω) ∂μ, X ω ∈ Set.Icc a b) →
    AEMeasurable X μ → ProbabilityTheory.variance X μ ≤ (b - ∫ (x : Ω), X x ∂μ) * (∫ (x : Ω), X x ∂μ - a)

The Bhatia-Davis inequality on variance

The variance of a random variable X satisfying a ≤ X ≤ b almost everywhere is at most (b - 𝔼 X) * (𝔼 X - a).

theorem ProbabilityTheory.variance_le_sq_of_bounded E3 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : MeasureTheory.Measure Ω} [MeasureTheory.IsProbabilityMeasure μ] {a b : ℝ}
  {X : Ω → ℝ},
  (∀ᵐ (ω : Ω) ∂μ, X ω ∈ Set.Icc a b) → AEMeasurable X μ → ProbabilityTheory.variance X μ ≤ ((b - a) / 2) ^ 2

Popoviciu's inequality on variances

The variance of a random variable X satisfying a ≤ X ≤ b almost everywhere is at most ((b - a) / 2) ^ 2.

theorem ProbabilityTheory.variance_add_prod E1 #

∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : MeasureTheory.Measure Ω} {Ω' : Type u_3} {mΩ' : MeasurableSpace Ω'}
  {ν : MeasureTheory.Measure Ω'} [MeasureTheory.IsProbabilityMeasure μ] [MeasureTheory.IsProbabilityMeasure ν]
  {X : Ω → ℝ} {Y : Ω' → ℝ},
  MeasureTheory.MemLp X 2 μ →
    MeasureTheory.MemLp Y 2 ν →
      ProbabilityTheory.variance (fun p ↦ X p.1 + Y p.2) (μ.prod ν) =
        ProbabilityTheory.variance X μ + ProbabilityTheory.variance Y ν

theorem ProbabilityTheory.variance_dual_prod' E1 #

∀ {E : Type u_3} {F : Type u_4} [inst : NormedAddCommGroup E] [inst_1 : NormedSpace ℝ E] {mE : MeasurableSpace E}
  [inst_2 : NormedAddCommGroup F] [inst_3 : NormedSpace ℝ F] {mF : MeasurableSpace F} {μ : MeasureTheory.Measure E}
  [MeasureTheory.IsProbabilityMeasure μ] {ν : MeasureTheory.Measure F} [MeasureTheory.IsProbabilityMeasure ν]
  {L : StrongDual ℝ (E × F)},
  MeasureTheory.MemLp (⇑(L ∘SL ContinuousLinearMap.inl ℝ E F)) 2 μ →
    MeasureTheory.MemLp (⇑(L ∘SL ContinuousLinearMap.inr ℝ E F)) 2 ν →
      ProbabilityTheory.variance (⇑L) (μ.prod ν) =
        ProbabilityTheory.variance (⇑(L ∘SL ContinuousLinearMap.inl ℝ E F)) μ +
          ProbabilityTheory.variance (⇑(L ∘SL ContinuousLinearMap.inr ℝ E F)) ν

theorem ProbabilityTheory.variance_dual_prod E1 #

∀ {E : Type u_3} {F : Type u_4} [inst : NormedAddCommGroup E] [inst_1 : NormedSpace ℝ E] {mE : MeasurableSpace E}
  [inst_2 : NormedAddCommGroup F] [inst_3 : NormedSpace ℝ F] {mF : MeasurableSpace F} {μ : MeasureTheory.Measure E}
  [MeasureTheory.IsProbabilityMeasure μ] {ν : MeasureTheory.Measure F} [MeasureTheory.IsProbabilityMeasure ν]
  {L : StrongDual ℝ (E × F)},
  MeasureTheory.MemLp id 2 μ →
    MeasureTheory.MemLp id 2 ν →
      ProbabilityTheory.variance (⇑L) (μ.prod ν) =
        ProbabilityTheory.variance (⇑(L ∘SL ContinuousLinearMap.inl ℝ E F)) μ +
          ProbabilityTheory.variance (⇑(L ∘SL ContinuousLinearMap.inr ℝ E F)) ν