fact stringlengths 6 3.84k | type stringclasses 11
values | library stringclasses 32
values | imports listlengths 1 14 | filename stringlengths 20 95 | symbolic_name stringlengths 1 90 | docstring stringlengths 7 20k ⌀ |
|---|---|---|---|---|---|---|
_root_.ProbabilityTheory.Kernel.HasSubgaussianMGF_congr {Y : Ω → ℝ} (h : X =ᵐ[κ ∘ₘ ν] Y) :
HasSubgaussianMGF X c κ ν ↔ HasSubgaussianMGF Y c κ ν :=
⟨fun hX ↦ congr hX h, fun hY ↦ congr hY (ae_eq_symm h)⟩ | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | _root_.ProbabilityTheory.Kernel.HasSubgaussianMGF_congr | null |
of_map {Ω'' : Type*} {mΩ'' : MeasurableSpace Ω''} {κ : Kernel Ω' Ω''}
{Y : Ω'' → Ω} {X : Ω → ℝ} (hY : Measurable Y) (h : HasSubgaussianMGF X c (κ.map Y) ν) :
HasSubgaussianMGF (X ∘ Y) c κ ν where
integrable_exp_mul t := by
have h1 := h.integrable_exp_mul t
rwa [← Measure.map_comp _ _ hY, integrable_map_measure h1.aestronglyMeasurable (by fun_prop)]
at h1
mgf_le := by
filter_upwards [h.ae_forall_integrable_exp_mul, h.mgf_le] with ω' h_int h_mgf t
convert h_mgf t
ext t
rw [map_apply _ hY, mgf_map hY.aemeasurable]
convert (h_int t).1
rw [map_apply _ hY] | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | of_map | null |
measure_ge_le_exp_add (h : HasSubgaussianMGF X c κ ν) (ε : ℝ) :
∀ᵐ ω' ∂ν, ∀ t, 0 ≤ t → (κ ω').real {ω | ε ≤ X ω} ≤ exp (- t * ε + c * t ^ 2 / 2) := by
filter_upwards [h.mgf_le, h.ae_forall_integrable_exp_mul, h.isFiniteMeasure] with ω' h1 h2 _ t ht
calc (κ ω').real {ω | ε ≤ X ω}
_ ≤ exp (-t * ε) * mgf X (κ ω') t := measure_ge_le_exp_mul_mgf ε ht (h2 t)
_ ≤ exp (-t * ε + c * t ^ 2 / 2) := by
rw [exp_add]
gcongr
exact h1 t | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | measure_ge_le_exp_add | null |
measure_ge_le (h : HasSubgaussianMGF X c κ ν) {ε : ℝ} (hε : 0 ≤ ε) :
∀ᵐ ω' ∂ν, (κ ω').real {ω | ε ≤ X ω} ≤ exp (- ε ^ 2 / (2 * c)) := by
by_cases hc0 : c = 0
· filter_upwards [h.measure_univ_le_one] with ω' h
simp only [hc0, NNReal.coe_zero, mul_zero, div_zero, exp_zero]
refine ENNReal.toReal_le_of_le_ofReal zero_le_one ?_
simp only [ENNReal.ofReal_one]
exact (measure_mono (Set.subset_univ _)).trans h
filter_upwards [measure_ge_le_exp_add h ε] with ω' h
calc (κ ω').real {ω | ε ≤ X ω}
_ ≤ exp (- (ε / c) * ε + c * (ε / c) ^ 2 / 2) := h (ε / c) (by positivity)
_ = exp (- ε ^ 2 / (2 * c)) := by congr; field_simp; ring | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | measure_ge_le | Chernoff bound on the right tail of a sub-Gaussian random variable. |
measure_pos_eq_zero_of_hasSubGaussianMGF_zero (h : HasSubgaussianMGF X 0 κ ν) :
∀ᵐ ω' ∂ν, (κ ω') {ω | 0 < X ω} = 0 := by
have hs : {ω | 0 < X ω} = ⋃ ε : {ε : ℚ // 0 < ε}, {ω | ε ≤ X ω} := by
ext ω
simp only [Set.mem_setOf_eq, Set.mem_iUnion, Subtype.exists, exists_prop]
constructor
· intro hp
obtain ⟨q, h1, h2⟩ := exists_rat_btwn hp
exact ⟨q, (q.cast_pos.1 h1), h2.le⟩
· intro ⟨q, h1, h2⟩
exact lt_of_lt_of_le (q.cast_pos.2 h1) h2
have hb (ε : ℚ) : ∀ᵐ ω' ∂ν, 0 < ε → (κ ω') {ω | ε ≤ X ω} = 0 := by
filter_upwards [h.measure_ge_le_exp_add ε, h.isFiniteMeasure] with ω' hm _ hε
simp only [neg_mul, NNReal.coe_zero, zero_mul, zero_div, add_zero] at hm
suffices (κ ω').real {ω | ε ≤ X ω} = 0 by simpa [Measure.real, ENNReal.toReal_eq_zero_iff]
have hl : Filter.Tendsto (fun t ↦ rexp (-(t * ε))) Filter.atTop (𝓝 0) := by
apply tendsto_exp_neg_atTop_nhds_zero.comp
exact Filter.Tendsto.atTop_mul_const (ε.cast_pos.2 hε) (fun _ a ↦ a)
apply le_antisymm
· exact ge_of_tendsto hl (Filter.eventually_atTop.2 ⟨0, hm⟩)
· exact measureReal_nonneg
/- `ν`-almost everywhere, `{ω | 0 < X ω}` is a countable union of `κ ω'`-null sets. -/
filter_upwards [ae_all_iff.2 hb] with ω' hn
simp only [hs, measure_iUnion_null_iff, Subtype.forall]
exact fun _ ↦ hn _ | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | measure_pos_eq_zero_of_hasSubGaussianMGF_zero | null |
ae_eq_zero_of_hasSubgaussianMGF_zero (h : HasSubgaussianMGF X 0 κ ν) :
∀ᵐ ω' ∂ν, X =ᵐ[κ ω'] 0 := by
filter_upwards [(h.neg).measure_pos_eq_zero_of_hasSubGaussianMGF_zero,
h.measure_pos_eq_zero_of_hasSubGaussianMGF_zero]
intro ω' h1 h2
simp_rw [Pi.neg_apply, Left.neg_pos_iff] at h1
apply nonpos_iff_eq_zero.1
calc (κ ω') {ω | X ω ≠ 0}
_ = (κ ω') {ω | X ω < 0 ∨ 0 < X ω} := by simp_rw [ne_iff_lt_or_gt]
_ ≤ (κ ω') {ω | X ω < 0} + (κ ω') {ω | 0 < X ω} := measure_union_le _ _
_ = 0 := by simp [h1, h2] | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | ae_eq_zero_of_hasSubgaussianMGF_zero | null |
ae_eq_zero_of_hasSubgaussianMGF_zero_of_measurable
(hX : Measurable X) (h : HasSubgaussianMGF X 0 κ ν) :
X =ᵐ[κ ∘ₘ ν] 0 := by
rw [Filter.EventuallyEq, Measure.ae_comp_iff (measurableSet_eq_fun hX (by fun_prop))]
exact h.ae_eq_zero_of_hasSubgaussianMGF_zero | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | ae_eq_zero_of_hasSubgaussianMGF_zero_of_measurable | Auxiliary lemma for `ae_eq_zero_of_hasSubgaussianMGF_zero'`. |
ae_eq_zero_of_hasSubgaussianMGF_zero' (h : HasSubgaussianMGF X 0 κ ν) :
X =ᵐ[κ ∘ₘ ν] 0 := by
have hX := h.aestronglyMeasurable
have h' : HasSubgaussianMGF (hX.mk X) 0 κ ν := h.congr hX.ae_eq_mk
exact hX.ae_eq_mk.trans (ae_eq_zero_of_hasSubgaussianMGF_zero_of_measurable hX.measurable_mk h') | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | ae_eq_zero_of_hasSubgaussianMGF_zero' | null |
add {Y : Ω → ℝ} {cX cY : ℝ≥0} (hX : HasSubgaussianMGF X cX κ ν)
(hY : HasSubgaussianMGF Y cY κ ν) :
HasSubgaussianMGF (fun ω ↦ X ω + Y ω) ((cX.sqrt + cY.sqrt) ^ 2) κ ν := by
by_cases hX0 : cX = 0
· simp only [hX0, NNReal.sqrt_zero, zero_add, NNReal.sq_sqrt] at hX ⊢
refine hY.congr ?_
filter_upwards [ae_eq_zero_of_hasSubgaussianMGF_zero' hX] with ω hX0 using by simp [hX0]
by_cases hY0 : cY = 0
· simp only [hY0, NNReal.sqrt_zero, add_zero, NNReal.sq_sqrt] at hY ⊢
refine hX.congr ?_
filter_upwards [ae_eq_zero_of_hasSubgaussianMGF_zero' hY] with ω hY0 using by simp [hY0]
exact
{ integrable_exp_mul t := by
simp_rw [mul_add, exp_add]
convert MemLp.integrable_mul (hX.memLp_exp_mul t 2) (hY.memLp_exp_mul t 2)
norm_cast
infer_instance
mgf_le := by
let p := (cX.sqrt + cY.sqrt) / cX.sqrt
let q := (cX.sqrt + cY.sqrt) / cY.sqrt
filter_upwards [hX.mgf_le, hY.mgf_le, hX.ae_forall_memLp_exp_mul p,
hY.ae_forall_memLp_exp_mul q] with ω' hmX hmY hlX hlY t
calc (κ ω')[fun ω ↦ exp (t * (X ω + Y ω))]
_ ≤ (κ ω')[fun ω ↦ exp (t * X ω) ^ (p : ℝ)] ^ (1 / (p : ℝ)) *
(κ ω')[fun ω ↦ exp (t * Y ω) ^ (q : ℝ)] ^ (1 / (q : ℝ)) := by
simp_rw [mul_add, exp_add]
apply integral_mul_le_Lp_mul_Lq_of_nonneg
· exact ⟨by simp [field, p, q], by positivity, by positivity⟩
· exact ae_of_all _ fun _ ↦ exp_nonneg _
· exact ae_of_all _ fun _ ↦ exp_nonneg _
· simpa using (hlX t)
· simpa using (hlY t)
_ ≤ exp (cX * (t * p) ^ 2 / 2) ^ (1 / (p : ℝ)) *
exp (cY * (t * q) ^ 2 / 2) ^ (1 / (q : ℝ)) := by
simp_rw [← exp_mul _ p, ← exp_mul _ q, mul_right_comm t _ p, mul_right_comm t _ q]
gcongr
· exact hmX (t * p)
· exact hmY (t * q)
_ = exp ((cX.sqrt + cY.sqrt) ^ 2 * t ^ 2 / 2) := by
simp_rw [← exp_mul, ← exp_add]
simp only [NNReal.coe_div, NNReal.coe_add, coe_sqrt, one_div, inv_div, exp_eq_exp, p, q]
field_simp
linear_combination t ^ 2 * (-√↑cY * Real.sq_sqrt cX.coe_nonneg
-√↑cX * Real.sq_sqrt cY.coe_nonneg) }
variable {Ω'' : Type*} {mΩ'' : MeasurableSpace Ω''} {Y : Ω'' → ℝ} {cY : ℝ≥0} | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | add | null |
prodMkLeft_compProd {η : Kernel Ω Ω''} (h : HasSubgaussianMGF Y cY η (κ ∘ₘ ν)) :
HasSubgaussianMGF Y cY (prodMkLeft Ω' η) (ν ⊗ₘ κ) := by
by_cases hν : SFinite ν
swap; · simp [hν]
by_cases hκ : IsSFiniteKernel κ
swap; · simp [hκ]
constructor
· simpa using h.integrable_exp_mul
· have h2 := h.mgf_le
rw [← Measure.snd_compProd, Measure.snd] at h2
exact ae_of_ae_map (by fun_prop) h2
variable [SFinite ν] | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | prodMkLeft_compProd | null |
integrable_exp_add_compProd {η : Kernel (Ω' × Ω) Ω''} [IsZeroOrMarkovKernel η]
(hX : HasSubgaussianMGF X c κ ν) (hY : HasSubgaussianMGF Y cY η (ν ⊗ₘ κ)) (t : ℝ) :
Integrable (fun ω ↦ exp (t * (X ω.1 + Y ω.2))) ((κ ⊗ₖ η) ∘ₘ ν) := by
by_cases hκ : IsSFiniteKernel κ
swap; · simp [hκ]
rcases eq_zero_or_isMarkovKernel η with rfl | hη
· simp
simp_rw [mul_add, exp_add]
refine MemLp.integrable_mul (p := 2) (q := 2) ?_ ?_
· have h := hX.memLp_exp_mul t 2
simp only [ENNReal.coe_ofNat] at h
have : κ ∘ₘ ν = ((κ ⊗ₖ η) ∘ₘ ν).map Prod.fst := by
rw [Measure.map_comp _ _ measurable_fst, ← fst_eq, fst_compProd]
rwa [this, memLp_map_measure_iff h.1 measurable_fst.aemeasurable] at h
· have h := hY.memLp_exp_mul t 2
rwa [ENNReal.coe_ofNat, Measure.comp_compProd_comm, Measure.snd,
memLp_map_measure_iff h.1 measurable_snd.aemeasurable] at h | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | integrable_exp_add_compProd | null |
add_compProd {η : Kernel (Ω' × Ω) Ω''} [IsZeroOrMarkovKernel η]
(hX : HasSubgaussianMGF X c κ ν) (hY : HasSubgaussianMGF Y cY η (ν ⊗ₘ κ)) :
HasSubgaussianMGF (fun p ↦ X p.1 + Y p.2) (c + cY) (κ ⊗ₖ η) ν := by
by_cases hκ : IsSFiniteKernel κ
swap; · simp [hκ]
refine .of_rat (integrable_exp_add_compProd hX hY) fun q ↦ ?_
filter_upwards [hX.mgf_le, hX.ae_integrable_exp_mul q, Measure.ae_ae_of_ae_compProd hY.mgf_le,
Measure.ae_integrable_of_integrable_comp <| integrable_exp_add_compProd hX hY q]
with ω' hX_mgf hX_int hY_mgf h_int_mul
calc mgf (fun p ↦ X p.1 + Y p.2) ((κ ⊗ₖ η) ω') q
_ = ∫ x, exp (q * X x) * ∫ y, exp (q * Y y) ∂(η (ω', x)) ∂(κ ω') := by
simp_rw [mgf, mul_add, exp_add] at h_int_mul ⊢
simp_rw [integral_compProd h_int_mul, integral_const_mul]
_ ≤ ∫ x, exp (q * X x) * exp (cY * q ^ 2 / 2) ∂(κ ω') := by
refine integral_mono_of_nonneg ?_ (hX_int.mul_const _) ?_
· exact ae_of_all _ fun ω ↦ mul_nonneg (by positivity)
(integral_nonneg (fun _ ↦ by positivity))
· filter_upwards [all_ae_of hY_mgf q] with ω hY_mgf
gcongr
exact hY_mgf
_ ≤ exp (↑(c + cY) * q ^ 2 / 2) := by
rw [integral_mul_const, NNReal.coe_add, add_mul, add_div, exp_add]
gcongr
exact hX_mgf q | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | add_compProd | For `ν : Measure Ω'`, `κ : Kernel Ω' Ω` and `η : (Ω' × Ω) Ω''`, if a random variable `X : Ω → ℝ`
has a sub-Gaussian mgf with respect to `κ` and `ν` and another random variable `Y : Ω'' → ℝ` has
a sub-Gaussian mgf with respect to `η` and `ν ⊗ₘ κ : Measure (Ω' × Ω)`, then `X + Y` (random
variable on the measurable space `Ω × Ω''`) has a sub-Gaussian mgf with respect to
`κ ⊗ₖ η : Kernel Ω' (Ω × Ω'')` and `ν`. |
add_comp {η : Kernel Ω Ω''} [IsZeroOrMarkovKernel η]
(hX : HasSubgaussianMGF X c κ ν) (hY : HasSubgaussianMGF Y cY η (κ ∘ₘ ν)) :
HasSubgaussianMGF (fun p ↦ X p.1 + Y p.2) (c + cY) (κ ⊗ₖ prodMkLeft Ω' η) ν :=
hX.add_compProd hY.prodMkLeft_compProd | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | add_comp | For `ν : Measure Ω'`, `κ : Kernel Ω' Ω` and `η : Ω Ω''`, if a random variable `X : Ω → ℝ`
has a sub-Gaussian mgf with respect to `κ` and `ν` and another random variable `Y : Ω'' → ℝ` has
a sub-Gaussian mgf with respect to `η` and `κ ∘ₘ ν : Measure Ω`, then `X + Y` (random
variable on the measurable space `Ω × Ω''`) has a sub-Gaussian mgf with respect to
`κ ⊗ₖ prodMkLeft Ω' η : Kernel Ω' (Ω × Ω'')` and `ν`. |
HasCondSubgaussianMGF (X : Ω → ℝ) (c : ℝ≥0)
(μ : Measure Ω := by volume_tac) [IsFiniteMeasure μ] : Prop :=
Kernel.HasSubgaussianMGF X c (condExpKernel μ m) (μ.trim hm) | def | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | HasCondSubgaussianMGF | A random variable `X` has a conditionally sub-Gaussian moment-generating function
with parameter `c` with respect to a sigma-algebra `m` and a measure `μ` if for all `t : ℝ`,
`exp (t * X)` is `μ`-integrable and the moment-generating function of `X` conditioned on `m` is
almost surely bounded by `exp (c * t ^ 2 / 2)` for all `t : ℝ`.
This implies in particular that `X` has expectation 0.
The actual definition uses `Kernel.HasSubgaussianMGF`: `HasCondSubgaussianMGF` is defined as
sub-Gaussian with respect to the conditional expectation kernel for `m` and the restriction of `μ`
to the sigma-algebra `m`. |
mgf_le (h : HasCondSubgaussianMGF m hm X c μ) :
∀ᵐ ω' ∂(μ.trim hm), ∀ t, mgf X (condExpKernel μ m ω') t ≤ exp (c * t ^ 2 / 2) :=
Kernel.HasSubgaussianMGF.mgf_le h | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | mgf_le | null |
cgf_le (h : HasCondSubgaussianMGF m hm X c μ) :
∀ᵐ ω' ∂(μ.trim hm), ∀ t, cgf X (condExpKernel μ m ω') t ≤ c * t ^ 2 / 2 :=
Kernel.HasSubgaussianMGF.cgf_le h | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | cgf_le | null |
ae_trim_condExp_le (h : HasCondSubgaussianMGF m hm X c μ) (t : ℝ) :
∀ᵐ ω' ∂(μ.trim hm), (μ[fun ω ↦ exp (t * X ω) | m]) ω' ≤ exp (c * t ^ 2 / 2) := by
have h_eq := condExp_ae_eq_trim_integral_condExpKernel hm (h.integrable_exp_mul t)
simp_rw [condExpKernel_comp_trim] at h_eq
filter_upwards [h.mgf_le, h_eq] with ω' h_mgf h_eq
rw [h_eq]
exact h_mgf t | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | ae_trim_condExp_le | null |
ae_condExp_le (h : HasCondSubgaussianMGF m hm X c μ) (t : ℝ) :
∀ᵐ ω' ∂μ, (μ[fun ω ↦ exp (t * X ω) | m]) ω' ≤ exp (c * t ^ 2 / 2) :=
ae_of_ae_trim hm (h.ae_trim_condExp_le t)
@[simp] | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | ae_condExp_le | null |
fun_zero : HasCondSubgaussianMGF m hm (fun _ ↦ 0) 0 μ := Kernel.HasSubgaussianMGF.fun_zero
@[simp] | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | fun_zero | null |
zero : HasCondSubgaussianMGF m hm 0 0 μ := Kernel.HasSubgaussianMGF.zero | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | zero | null |
memLp_exp_mul (h : HasCondSubgaussianMGF m hm X c μ) (t : ℝ) (p : ℝ≥0) :
MemLp (fun ω ↦ exp (t * X ω)) p μ :=
condExpKernel_comp_trim (μ := μ) hm ▸ Kernel.HasSubgaussianMGF.memLp_exp_mul h t p | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | memLp_exp_mul | null |
integrable_exp_mul (h : HasCondSubgaussianMGF m hm X c μ) (t : ℝ) :
Integrable (fun ω ↦ exp (t * X ω)) μ :=
condExpKernel_comp_trim (μ := μ) hm ▸ Kernel.HasSubgaussianMGF.integrable_exp_mul h t | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | integrable_exp_mul | null |
HasSubgaussianMGF (X : Ω → ℝ) (c : ℝ≥0) (μ : Measure Ω := by volume_tac) : Prop where
integrable_exp_mul : ∀ t : ℝ, Integrable (fun ω ↦ exp (t * X ω)) μ
mgf_le : ∀ t : ℝ, mgf X μ t ≤ exp (c * t ^ 2 / 2) | structure | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | HasSubgaussianMGF | A random variable `X` has a sub-Gaussian moment-generating function with parameter `c`
with respect to a measure `μ` if for all `t : ℝ`, `exp (t * X)` is `μ`-integrable and
the moment-generating function of `X` is bounded by `exp (c * t ^ 2 / 2)` for all `t : ℝ`.
This implies in particular that `X` has expectation 0.
This is equivalent to `Kernel.HasSubgaussianMGF X c (Kernel.const Unit μ) (Measure.dirac ())`,
as proved in `HasSubgaussianMGF_iff_kernel`.
Properties about sub-Gaussian moment-generating functions should be proved first for
`Kernel.HasSubgaussianMGF` when possible. |
HasSubgaussianMGF_iff_kernel :
HasSubgaussianMGF X c μ
↔ Kernel.HasSubgaussianMGF X c (Kernel.const Unit μ) (Measure.dirac ()) :=
⟨fun ⟨h1, h2⟩ ↦ ⟨by simpa, by simpa⟩, fun ⟨h1, h2⟩ ↦ ⟨by simpa using h1, by simpa using h2⟩⟩ | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | HasSubgaussianMGF_iff_kernel | null |
aestronglyMeasurable (h : HasSubgaussianMGF X c μ) : AEStronglyMeasurable X μ := by
have h_int := h.integrable_exp_mul 1
simpa using (aemeasurable_of_aemeasurable_exp h_int.1.aemeasurable).aestronglyMeasurable | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | aestronglyMeasurable | null |
aemeasurable (h : HasSubgaussianMGF X c μ) : AEMeasurable X μ :=
h.aestronglyMeasurable.aemeasurable | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | aemeasurable | null |
congr (h : HasSubgaussianMGF X c μ) {Y : Ω → ℝ} (h' : X =ᵐ[μ] Y) :
HasSubgaussianMGF Y c μ := by
rw [HasSubgaussianMGF_iff_kernel] at h ⊢
apply h.congr
simpa | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | congr | null |
memLp_exp_mul (h : HasSubgaussianMGF X c μ) (t : ℝ) (p : ℝ≥0) :
MemLp (fun ω ↦ exp (t * X ω)) p μ := by
rw [HasSubgaussianMGF_iff_kernel] at h
simpa using h.memLp_exp_mul t p | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | memLp_exp_mul | null |
cgf_le (h : HasSubgaussianMGF X c μ) (t : ℝ) : cgf X μ t ≤ c * t ^ 2 / 2 := by
rw [HasSubgaussianMGF_iff_kernel] at h
simpa using (all_ae_of h.cgf_le t)
@[simp] | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | cgf_le | null |
fun_zero [IsZeroOrProbabilityMeasure μ] : HasSubgaussianMGF (fun _ ↦ 0) 0 μ := by
simp [HasSubgaussianMGF_iff_kernel]
@[simp] | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | fun_zero | null |
zero [IsZeroOrProbabilityMeasure μ] : HasSubgaussianMGF 0 0 μ := fun_zero | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | zero | null |
neg {c : ℝ≥0} (h : HasSubgaussianMGF X c μ) : HasSubgaussianMGF (-X) c μ := by
simpa [HasSubgaussianMGF_iff_kernel] using (HasSubgaussianMGF_iff_kernel.1 h).neg | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | neg | null |
of_map {Ω' : Type*} {mΩ' : MeasurableSpace Ω'} {μ : Measure Ω'}
{Y : Ω' → Ω} {X : Ω → ℝ} (hY : AEMeasurable Y μ) (h : HasSubgaussianMGF X c (μ.map Y)) :
HasSubgaussianMGF (X ∘ Y) c μ where
integrable_exp_mul t := by
have h1 := h.integrable_exp_mul t
rwa [integrable_map_measure h1.aestronglyMeasurable (by fun_prop)] at h1
mgf_le t := by
convert h.mgf_le t using 1
rw [mgf_map hY (h.integrable_exp_mul t).1] | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | of_map | null |
trim (hm : m ≤ mΩ) (hXm : Measurable[m] X) (hX : HasSubgaussianMGF X c μ) :
HasSubgaussianMGF X c (μ.trim hm) where
integrable_exp_mul t := by
refine (hX.integrable_exp_mul t).trim hm ?_
exact Measurable.stronglyMeasurable <| by fun_prop
mgf_le t := by
rw [mgf, ← integral_trim]
· exact hX.mgf_le t
· exact Measurable.stronglyMeasurable <| by fun_prop | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | trim | null |
measure_ge_le (h : HasSubgaussianMGF X c μ) {ε : ℝ} (hε : 0 ≤ ε) :
μ.real {ω | ε ≤ X ω} ≤ exp (- ε ^ 2 / (2 * c)) := by
rw [HasSubgaussianMGF_iff_kernel] at h
simpa using h.measure_ge_le hε | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | measure_ge_le | Chernoff bound on the right tail of a sub-Gaussian random variable. |
ae_eq_zero_of_hasSubgaussianMGF_zero (h : HasSubgaussianMGF X 0 μ) : X =ᵐ[μ] 0 := by
simpa using (HasSubgaussianMGF_iff_kernel.1 h).ae_eq_zero_of_hasSubgaussianMGF_zero | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | ae_eq_zero_of_hasSubgaussianMGF_zero | null |
add {Y : Ω → ℝ} {cX cY : ℝ≥0} (hX : HasSubgaussianMGF X cX μ)
(hY : HasSubgaussianMGF Y cY μ) :
HasSubgaussianMGF (fun ω ↦ X ω + Y ω) ((cX.sqrt + cY.sqrt) ^ 2) μ := by
have := (HasSubgaussianMGF_iff_kernel.1 hX).add (HasSubgaussianMGF_iff_kernel.1 hY)
simpa [HasSubgaussianMGF_iff_kernel] using this | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | add | null |
add_of_indepFun {Y : Ω → ℝ} {cX cY : ℝ≥0} (hX : HasSubgaussianMGF X cX μ)
(hY : HasSubgaussianMGF Y cY μ) (hindep : IndepFun X Y μ) :
HasSubgaussianMGF (fun ω ↦ X ω + Y ω) (cX + cY) μ where
integrable_exp_mul t := by
simp_rw [mul_add, exp_add]
convert MemLp.integrable_mul (hX.memLp_exp_mul t 2) (hY.memLp_exp_mul t 2)
norm_cast
infer_instance
mgf_le t := by
calc mgf (X + Y) μ t
_ = mgf X μ t * mgf Y μ t :=
hindep.mgf_add (hX.integrable_exp_mul t).1 (hY.integrable_exp_mul t).1
_ ≤ exp (cX * t ^ 2 / 2) * exp (cY * t ^ 2 / 2) := by
gcongr
· exact mgf_nonneg
· exact hX.mgf_le t
· exact hY.mgf_le t
_ = exp ((cX + cY) * t ^ 2 / 2) := by rw [← exp_add]; congr; ring | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | add_of_indepFun | null |
private sum_of_iIndepFun_of_forall_aemeasurable
{ι : Type*} {X : ι → Ω → ℝ} (h_indep : iIndepFun X μ) {c : ι → ℝ≥0}
(h_meas : ∀ i, AEMeasurable (X i) μ)
{s : Finset ι} (h_subG : ∀ i ∈ s, HasSubgaussianMGF (X i) (c i) μ) :
HasSubgaussianMGF (fun ω ↦ ∑ i ∈ s, X i ω) (∑ i ∈ s, c i) μ := by
have : IsProbabilityMeasure μ := h_indep.isProbabilityMeasure
classical
induction s using Finset.induction_on with
| empty => simp
| insert i s his h =>
simp_rw [← Finset.sum_apply, Finset.sum_insert his, Pi.add_apply, Finset.sum_apply]
have h_indep' := (h_indep.indepFun_finset_sum_of_notMem₀ h_meas his).symm
refine add_of_indepFun (h_subG _ (Finset.mem_insert_self _ _)) (h ?_) ?_
· exact fun i hi ↦ h_subG _ (Finset.mem_insert_of_mem hi)
· convert h_indep'
rw [Finset.sum_apply] | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | sum_of_iIndepFun_of_forall_aemeasurable | null |
sum_of_iIndepFun {ι : Type*} {X : ι → Ω → ℝ} (h_indep : iIndepFun X μ) {c : ι → ℝ≥0}
{s : Finset ι} (h_subG : ∀ i ∈ s, HasSubgaussianMGF (X i) (c i) μ) :
HasSubgaussianMGF (fun ω ↦ ∑ i ∈ s, X i ω) (∑ i ∈ s, c i) μ := by
have : HasSubgaussianMGF (fun ω ↦ ∑ (i : s), X i ω) (∑ (i : s), c i) μ := by
apply sum_of_iIndepFun_of_forall_aemeasurable
· exact h_indep.precomp Subtype.val_injective
· exact fun i ↦ (h_subG i i.2).aemeasurable
· exact fun i _ ↦ h_subG i i.2
rw [Finset.sum_coe_sort] at this
exact this.congr (ae_of_all _ fun ω ↦ Finset.sum_attach s (fun i ↦ X i ω)) | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | sum_of_iIndepFun | null |
measure_sum_ge_le_of_iIndepFun {ι : Type*} {X : ι → Ω → ℝ} (h_indep : iIndepFun X μ)
{c : ι → ℝ≥0}
{s : Finset ι} (h_subG : ∀ i ∈ s, HasSubgaussianMGF (X i) (c i) μ) {ε : ℝ} (hε : 0 ≤ ε) :
μ.real {ω | ε ≤ ∑ i ∈ s, X i ω} ≤ exp (- ε ^ 2 / (2 * ∑ i ∈ s, c i)) :=
(sum_of_iIndepFun h_indep h_subG).measure_ge_le hε | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | measure_sum_ge_le_of_iIndepFun | **Hoeffding inequality** for sub-Gaussian random variables. |
measure_sum_range_ge_le_of_iIndepFun {X : ℕ → Ω → ℝ} (h_indep : iIndepFun X μ) {c : ℝ≥0}
{n : ℕ} (h_subG : ∀ i < n, HasSubgaussianMGF (X i) c μ) {ε : ℝ} (hε : 0 ≤ ε) :
μ.real {ω | ε ≤ ∑ i ∈ Finset.range n, X i ω} ≤ exp (- ε ^ 2 / (2 * n * c)) := by
have h := (sum_of_iIndepFun h_indep (c := fun _ ↦ c)
(s := Finset.range n) (by simpa)).measure_ge_le hε
simpa [← mul_assoc] using h | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | measure_sum_range_ge_le_of_iIndepFun | **Hoeffding inequality** for sub-Gaussian random variables. |
protected mgf_le_of_mem_Icc_of_integral_eq_zero [IsProbabilityMeasure μ] {a b t : ℝ}
(hm : AEMeasurable X μ) (hb : ∀ᵐ ω ∂μ, X ω ∈ Set.Icc a b) (hc : μ[X] = 0) (ht : 0 < t) :
mgf X μ t ≤ exp ((‖b - a‖₊ / 2) ^ 2 * t ^ 2 / 2) := by
have hi (u : ℝ) : Integrable (fun ω ↦ exp (u * X ω)) μ := integrable_exp_mul_of_mem_Icc hm hb
have hs : Set.Icc 0 t ⊆ interior (integrableExpSet X μ) := by simp [hi, integrableExpSet]
obtain ⟨u, h1, h2⟩ := exists_cgf_eq_iteratedDeriv_two_cgf_mul ht hc hs
rw [← exp_cgf (hi t), exp_le_exp, h2]
gcongr
calc
_ = Var[X; μ.tilted (u * X ·)] := by
rw [← variance_tilted_mul (hs (Set.mem_Icc_of_Ioo h1))]
_ ≤ ((b - a) / 2) ^ 2 := by
convert variance_le_sq_of_bounded ((tilted_absolutelyContinuous μ (u * X ·)) hb) _
· exact isProbabilityMeasure_tilted (hi u)
· exact hm.mono_ac (tilted_absolutelyContinuous μ (u * X ·))
_ = (‖b - a‖₊ / 2) ^ 2 := by simp [field] | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | mgf_le_of_mem_Icc_of_integral_eq_zero | null |
hasSubgaussianMGF_of_mem_Icc_of_integral_eq_zero [IsProbabilityMeasure μ] {a b : ℝ}
(hm : AEMeasurable X μ) (hb : ∀ᵐ ω ∂μ, X ω ∈ Set.Icc a b) (hc : μ[X] = 0) :
HasSubgaussianMGF X ((‖b - a‖₊ / 2) ^ 2) μ where
integrable_exp_mul t := integrable_exp_mul_of_mem_Icc hm hb
mgf_le t := by
obtain ht | ht | ht := lt_trichotomy 0 t
· exact ProbabilityTheory.mgf_le_of_mem_Icc_of_integral_eq_zero hm hb hc ht
· simp [← ht]
calc
_ = mgf (-X) μ (-t) := by simp [mgf]
_ ≤ exp ((‖-a - -b‖₊ / 2) ^ 2 * (-t) ^ 2 / 2) := by
apply ProbabilityTheory.mgf_le_of_mem_Icc_of_integral_eq_zero (hm.neg)
· filter_upwards [hb] with ω ⟨hl, hr⟩ using ⟨neg_le_neg_iff.2 hr, neg_le_neg_iff.2 hl⟩
· rw [integral_neg, hc, neg_zero]
· rwa [Left.neg_pos_iff]
_ = exp (((‖b - a‖₊ / 2) ^ 2) * t ^ 2 / 2) := by ring_nf | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | hasSubgaussianMGF_of_mem_Icc_of_integral_eq_zero | **Hoeffding's lemma**: with respect to a probability measure `μ`, if `X` is a random variable
that has expectation zero and is almost surely in `Set.Icc a b` for some `a ≤ b`, then `X` has a
sub-Gaussian moment-generating function with parameter `((b - a) / 2) ^ 2`. |
hasSubgaussianMGF_of_mem_Icc [IsProbabilityMeasure μ] {a b : ℝ} (hm : AEMeasurable X μ)
(hb : ∀ᵐ ω ∂μ, X ω ∈ Set.Icc a b) :
HasSubgaussianMGF (fun ω ↦ X ω - μ[X]) ((‖b - a‖₊ / 2) ^ 2) μ := by
rw [← sub_sub_sub_cancel_right b a μ[X]]
apply hasSubgaussianMGF_of_mem_Icc_of_integral_eq_zero (hm.sub_const _)
· filter_upwards [hb] with ω hab using by simpa using hab
· simp [integral_sub (Integrable.of_mem_Icc a b hm hb) (integrable_const _)] | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | hasSubgaussianMGF_of_mem_Icc | A corollary of Hoeffding's lemma for bounded random variables. |
HasSubgaussianMGF_add_of_HasCondSubgaussianMGF [IsFiniteMeasure μ]
{Y : Ω → ℝ} {cX cY : ℝ≥0} (hm : m ≤ mΩ)
(hX : HasSubgaussianMGF X cX (μ.trim hm)) (hY : HasCondSubgaussianMGF m hm Y cY μ) :
HasSubgaussianMGF (X + Y) (cX + cY) μ := by
suffices HasSubgaussianMGF (fun p ↦ X p.1 + Y p.2) (cX + cY)
(@Measure.map Ω (Ω × Ω) mΩ (m.prod mΩ) (fun ω ↦ (id ω, id ω)) μ) by
have h_eq : X + Y = (fun p ↦ X p.1 + Y p.2) ∘ (fun ω ↦ (id ω, id ω)) := rfl
rw [h_eq]
refine HasSubgaussianMGF.of_map ?_ this
exact @Measurable.aemeasurable _ _ _ (m.prod mΩ) _ _
((measurable_id'' hm).prodMk measurable_id)
rw [HasSubgaussianMGF_iff_kernel] at hX ⊢
have hY' : Kernel.HasSubgaussianMGF Y cY (condExpKernel μ m)
(Kernel.const Unit (μ.trim hm) ∘ₘ Measure.dirac ()) := by simpa
convert hX.add_comp hY'
ext
rw [Kernel.const_apply, ← Measure.compProd, compProd_trim_condExpKernel]
variable {Y : ℕ → Ω → ℝ} {cY : ℕ → ℝ≥0} {ℱ : Filtration ℕ mΩ} | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | HasSubgaussianMGF_add_of_HasCondSubgaussianMGF | If `X` is sub-Gaussian with parameter `cX` with respect to the restriction of `μ` to
a sub-sigma-algebra `m` and `Y` is conditionally sub-Gaussian with parameter `cY` with respect to
`m` and `μ` then `X + Y` is sub-Gaussian with parameter `cX + cY` with respect to `μ`.
`HasSubgaussianMGF X cX (μ.trim hm)` can be obtained from `HasSubgaussianMGF X cX μ` if `X` is
`m`-measurable. See `HasSubgaussianMGF.trim`. |
HasSubgaussianMGF_sum_of_HasCondSubgaussianMGF [IsZeroOrProbabilityMeasure μ]
(h_adapted : Adapted ℱ Y) (h0 : HasSubgaussianMGF (Y 0) (cY 0) μ) (n : ℕ)
(h_subG : ∀ i < n - 1, HasCondSubgaussianMGF (ℱ i) (ℱ.le i) (Y (i + 1)) (cY (i + 1)) μ) :
HasSubgaussianMGF (fun ω ↦ ∑ i ∈ Finset.range n, Y i ω) (∑ i ∈ Finset.range n, cY i) μ := by
induction n with
| zero => simp
| succ n hn =>
induction n with
| zero => simp [h0]
| succ n =>
specialize hn fun i hi ↦ h_subG i (by cutsat)
simp_rw [Finset.sum_range_succ _ (n + 1)]
refine HasSubgaussianMGF_add_of_HasCondSubgaussianMGF (ℱ.le n) ?_ (h_subG n (by cutsat))
refine HasSubgaussianMGF.trim (ℱ.le n) ?_ hn
refine Finset.measurable_fun_sum (Finset.range (n + 1)) fun m hm ↦
((h_adapted m).mono (ℱ.mono ?_)).measurable
simp only [Finset.mem_range] at hm
cutsat | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | HasSubgaussianMGF_sum_of_HasCondSubgaussianMGF | Let `Y` be a random process adapted to a filtration `ℱ`, such that for all `i : ℕ`, `Y i` is
conditionally sub-Gaussian with parameter `cY i` with respect to `ℱ (i - 1)`.
In particular, `n ↦ ∑ i ∈ range n, Y i` is a martingale.
Then the sum `∑ i ∈ range n, Y i` is sub-Gaussian with parameter `∑ i ∈ range n, cY i`. |
measure_sum_ge_le_of_HasCondSubgaussianMGF [IsZeroOrProbabilityMeasure μ]
(h_adapted : Adapted ℱ Y) (h0 : HasSubgaussianMGF (Y 0) (cY 0) μ) (n : ℕ)
(h_subG : ∀ i < n - 1, HasCondSubgaussianMGF (ℱ i) (ℱ.le i) (Y (i + 1)) (cY (i + 1)) μ)
{ε : ℝ} (hε : 0 ≤ ε) :
μ.real {ω | ε ≤ ∑ i ∈ Finset.range n, Y i ω}
≤ exp (- ε ^ 2 / (2 * ∑ i ∈ Finset.range n, cY i)) :=
(HasSubgaussianMGF_sum_of_HasCondSubgaussianMGF h_adapted h0 n h_subG).measure_ge_le hε | lemma | Probability | [
"Mathlib.Probability.Kernel.Condexp",
"Mathlib.Probability.Moments.MGFAnalytic",
"Mathlib.Probability.Moments.Tilted"
] | Mathlib/Probability/Moments/SubGaussian.lean | measure_sum_ge_le_of_HasCondSubgaussianMGF | **Azuma-Hoeffding inequality** for sub-Gaussian random variables. |
tilted_mul_apply_mgf' {s : Set Ω} (hs : MeasurableSet s) :
μ.tilted (t * X ·) s = ∫⁻ a in s, ENNReal.ofReal (exp (t * X a) / mgf X μ t) ∂μ := by
rw [tilted_apply' _ _ hs, mgf] | lemma | Probability | [
"Mathlib.MeasureTheory.Measure.Tilted",
"Mathlib.Probability.Moments.MGFAnalytic"
] | Mathlib/Probability/Moments/Tilted.lean | tilted_mul_apply_mgf' | null |
tilted_mul_apply_mgf [SFinite μ] (s : Set Ω) :
μ.tilted (t * X ·) s = ∫⁻ a in s, ENNReal.ofReal (exp (t * X a) / mgf X μ t) ∂μ := by
rw [tilted_apply, mgf] | lemma | Probability | [
"Mathlib.MeasureTheory.Measure.Tilted",
"Mathlib.Probability.Moments.MGFAnalytic"
] | Mathlib/Probability/Moments/Tilted.lean | tilted_mul_apply_mgf | null |
tilted_mul_apply_cgf' {s : Set Ω} (hs : MeasurableSet s)
(ht : Integrable (fun ω ↦ exp (t * X ω)) μ) :
μ.tilted (t * X ·) s = ∫⁻ a in s, ENNReal.ofReal (exp (t * X a - cgf X μ t)) ∂μ := by
rcases eq_zero_or_neZero μ with rfl | hμ
· simp
· simp_rw [tilted_mul_apply_mgf' hs, exp_sub, exp_cgf ht] | lemma | Probability | [
"Mathlib.MeasureTheory.Measure.Tilted",
"Mathlib.Probability.Moments.MGFAnalytic"
] | Mathlib/Probability/Moments/Tilted.lean | tilted_mul_apply_cgf' | null |
tilted_mul_apply_cgf [SFinite μ] (s : Set Ω) (ht : Integrable (fun ω ↦ exp (t * X ω)) μ) :
μ.tilted (t * X ·) s = ∫⁻ a in s, ENNReal.ofReal (exp (t * X a - cgf X μ t)) ∂μ := by
rcases eq_zero_or_neZero μ with rfl | hμ
· simp
· simp_rw [tilted_mul_apply_mgf s, exp_sub, exp_cgf ht] | lemma | Probability | [
"Mathlib.MeasureTheory.Measure.Tilted",
"Mathlib.Probability.Moments.MGFAnalytic"
] | Mathlib/Probability/Moments/Tilted.lean | tilted_mul_apply_cgf | null |
tilted_mul_apply_eq_ofReal_integral_mgf' {s : Set Ω} (hs : MeasurableSet s) :
μ.tilted (t * X ·) s = ENNReal.ofReal (∫ a in s, exp (t * X a) / mgf X μ t ∂μ) := by
rw [tilted_apply_eq_ofReal_integral' _ hs, mgf] | lemma | Probability | [
"Mathlib.MeasureTheory.Measure.Tilted",
"Mathlib.Probability.Moments.MGFAnalytic"
] | Mathlib/Probability/Moments/Tilted.lean | tilted_mul_apply_eq_ofReal_integral_mgf' | null |
tilted_mul_apply_eq_ofReal_integral_mgf [SFinite μ] (s : Set Ω) :
μ.tilted (t * X ·) s = ENNReal.ofReal (∫ a in s, exp (t * X a) / mgf X μ t ∂μ) := by
rw [tilted_apply_eq_ofReal_integral _ s, mgf] | lemma | Probability | [
"Mathlib.MeasureTheory.Measure.Tilted",
"Mathlib.Probability.Moments.MGFAnalytic"
] | Mathlib/Probability/Moments/Tilted.lean | tilted_mul_apply_eq_ofReal_integral_mgf | null |
tilted_mul_apply_eq_ofReal_integral_cgf' {s : Set Ω} (hs : MeasurableSet s)
(ht : Integrable (fun ω ↦ exp (t * X ω)) μ) :
μ.tilted (t * X ·) s = ENNReal.ofReal (∫ a in s, exp (t * X a - cgf X μ t) ∂μ) := by
rcases eq_zero_or_neZero μ with rfl | hμ
· simp
· simp_rw [tilted_mul_apply_eq_ofReal_integral_mgf' hs, exp_sub]
rwa [exp_cgf] | lemma | Probability | [
"Mathlib.MeasureTheory.Measure.Tilted",
"Mathlib.Probability.Moments.MGFAnalytic"
] | Mathlib/Probability/Moments/Tilted.lean | tilted_mul_apply_eq_ofReal_integral_cgf' | null |
tilted_mul_apply_eq_ofReal_integral_cgf [SFinite μ] (s : Set Ω)
(ht : Integrable (fun ω ↦ exp (t * X ω)) μ) :
μ.tilted (t * X ·) s = ENNReal.ofReal (∫ a in s, exp (t * X a - cgf X μ t) ∂μ) := by
rcases eq_zero_or_neZero μ with rfl | hμ
· simp
· simp_rw [tilted_mul_apply_eq_ofReal_integral_mgf s, exp_sub]
rwa [exp_cgf] | lemma | Probability | [
"Mathlib.MeasureTheory.Measure.Tilted",
"Mathlib.Probability.Moments.MGFAnalytic"
] | Mathlib/Probability/Moments/Tilted.lean | tilted_mul_apply_eq_ofReal_integral_cgf | null |
setIntegral_tilted_mul_eq_mgf' (g : Ω → E) {s : Set Ω} (hs : MeasurableSet s) :
∫ x in s, g x ∂(μ.tilted (t * X ·)) = ∫ x in s, (exp (t * X x) / mgf X μ t) • (g x) ∂μ := by
rw [setIntegral_tilted' _ _ hs, mgf] | lemma | Probability | [
"Mathlib.MeasureTheory.Measure.Tilted",
"Mathlib.Probability.Moments.MGFAnalytic"
] | Mathlib/Probability/Moments/Tilted.lean | setIntegral_tilted_mul_eq_mgf' | null |
setIntegral_tilted_mul_eq_mgf [SFinite μ] (g : Ω → E) (s : Set Ω) :
∫ x in s, g x ∂(μ.tilted (t * X ·)) = ∫ x in s, (exp (t * X x) / mgf X μ t) • (g x) ∂μ := by
rw [setIntegral_tilted, mgf] | lemma | Probability | [
"Mathlib.MeasureTheory.Measure.Tilted",
"Mathlib.Probability.Moments.MGFAnalytic"
] | Mathlib/Probability/Moments/Tilted.lean | setIntegral_tilted_mul_eq_mgf | null |
setIntegral_tilted_mul_eq_cgf' (g : Ω → E) {s : Set Ω}
(hs : MeasurableSet s) (ht : Integrable (fun ω ↦ exp (t * X ω)) μ) :
∫ x in s, g x ∂(μ.tilted (t * X ·)) = ∫ x in s, exp (t * X x - cgf X μ t) • (g x) ∂μ := by
rcases eq_zero_or_neZero μ with rfl | hμ
· simp
· simp_rw [setIntegral_tilted_mul_eq_mgf' _ hs, exp_sub, exp_cgf ht] | lemma | Probability | [
"Mathlib.MeasureTheory.Measure.Tilted",
"Mathlib.Probability.Moments.MGFAnalytic"
] | Mathlib/Probability/Moments/Tilted.lean | setIntegral_tilted_mul_eq_cgf' | null |
setIntegral_tilted_mul_eq_cgf [SFinite μ] (g : Ω → E) (s : Set Ω)
(ht : Integrable (fun ω ↦ exp (t * X ω)) μ) :
∫ x in s, g x ∂(μ.tilted (t * X ·)) = ∫ x in s, exp (t * X x - cgf X μ t) • (g x) ∂μ := by
rcases eq_zero_or_neZero μ with rfl | hμ
· simp
· simp_rw [setIntegral_tilted_mul_eq_mgf, exp_sub, exp_cgf ht] | lemma | Probability | [
"Mathlib.MeasureTheory.Measure.Tilted",
"Mathlib.Probability.Moments.MGFAnalytic"
] | Mathlib/Probability/Moments/Tilted.lean | setIntegral_tilted_mul_eq_cgf | null |
integral_tilted_mul_eq_mgf (g : Ω → E) :
∫ ω, g ω ∂(μ.tilted (t * X ·)) = ∫ ω, (exp (t * X ω) / mgf X μ t) • (g ω) ∂μ := by
rw [integral_tilted, mgf] | lemma | Probability | [
"Mathlib.MeasureTheory.Measure.Tilted",
"Mathlib.Probability.Moments.MGFAnalytic"
] | Mathlib/Probability/Moments/Tilted.lean | integral_tilted_mul_eq_mgf | null |
integral_tilted_mul_eq_cgf (g : Ω → E) (ht : Integrable (fun ω ↦ exp (t * X ω)) μ) :
∫ ω, g ω ∂(μ.tilted (t * X ·)) = ∫ ω, exp (t * X ω - cgf X μ t) • (g ω) ∂μ := by
rcases eq_zero_or_neZero μ with rfl | hμ
· simp
· simp_rw [integral_tilted_mul_eq_mgf, exp_sub]
rwa [exp_cgf] | lemma | Probability | [
"Mathlib.MeasureTheory.Measure.Tilted",
"Mathlib.Probability.Moments.MGFAnalytic"
] | Mathlib/Probability/Moments/Tilted.lean | integral_tilted_mul_eq_cgf | null |
integral_tilted_mul_self (ht : t ∈ interior (integrableExpSet X μ)) :
(μ.tilted (t * X ·))[X] = deriv (cgf X μ) t := by
simp_rw [integral_tilted_mul_eq_mgf, deriv_cgf ht, ← integral_div, smul_eq_mul]
congr with ω
ring | lemma | Probability | [
"Mathlib.MeasureTheory.Measure.Tilted",
"Mathlib.Probability.Moments.MGFAnalytic"
] | Mathlib/Probability/Moments/Tilted.lean | integral_tilted_mul_self | The integral of `X` against the tilted measure `μ.tilted (t * X ·)` is the first derivative of
the cumulant-generating function of `X` at `t`. |
memLp_tilted_mul (ht : t ∈ interior (integrableExpSet X μ)) (p : ℝ≥0) :
MemLp X p (μ.tilted (t * X ·)) := by
have hX : AEMeasurable X μ := aemeasurable_of_mem_interior_integrableExpSet ht
by_cases hp : p = 0
· simpa [hp] using hX.aestronglyMeasurable.mono_ac (tilted_absolutelyContinuous _ _)
refine ⟨hX.aestronglyMeasurable.mono_ac (tilted_absolutelyContinuous _ _), ?_⟩
rw [eLpNorm_lt_top_iff_lintegral_rpow_enorm_lt_top]
rotate_left
· simp [hp]
· simp
simp_rw [ENNReal.coe_toReal, ← ofReal_norm_eq_enorm, norm_eq_abs,
ENNReal.ofReal_rpow_of_nonneg (x := |X _|) (p := p) (abs_nonneg (X _)) p.2]
refine Integrable.lintegral_lt_top ?_
simp_rw [integrable_tilted_iff (interior_subset (s := integrableExpSet X μ) ht),
smul_eq_mul, mul_comm]
exact integrable_rpow_abs_mul_exp_of_mem_interior_integrableExpSet ht p.2 | lemma | Probability | [
"Mathlib.MeasureTheory.Measure.Tilted",
"Mathlib.Probability.Moments.MGFAnalytic"
] | Mathlib/Probability/Moments/Tilted.lean | memLp_tilted_mul | null |
variance_tilted_mul (ht : t ∈ interior (integrableExpSet X μ)) :
Var[X; μ.tilted (t * X ·)] = iteratedDeriv 2 (cgf X μ) t := by
rw [variance_eq_integral]
swap; · exact (memLp_tilted_mul ht 1).aestronglyMeasurable.aemeasurable
rw [integral_tilted_mul_self ht, iteratedDeriv_two_cgf_eq_integral ht, integral_tilted_mul_eq_mgf,
← integral_div]
simp only [smul_eq_mul]
congr with ω
ring | lemma | Probability | [
"Mathlib.MeasureTheory.Measure.Tilted",
"Mathlib.Probability.Moments.MGFAnalytic"
] | Mathlib/Probability/Moments/Tilted.lean | variance_tilted_mul | The variance of `X` under the tilted measure `μ.tilted (t * X ·)` is the second derivative of
the cumulant-generating function of `X` at `t`. |
evariance : ℝ≥0∞ := ∫⁻ ω, ‖X ω - μ[X]‖ₑ ^ 2 ∂μ
variable (X μ) in | def | Probability | [
"Mathlib.Probability.Moments.Covariance"
] | Mathlib/Probability/Moments/Variance.lean | evariance | The `ℝ≥0∞`-valued variance of a real-valued random variable defined as the Lebesgue integral of
`‖X - 𝔼[X]‖^2`. |
variance : ℝ := (evariance X μ).toReal | def | Probability | [
"Mathlib.Probability.Moments.Covariance"
] | Mathlib/Probability/Moments/Variance.lean | variance | The `ℝ`-valued variance of a real-valued random variable defined by applying `ENNReal.toReal`
to `evariance`. |
meas_ge_le_evariance_div_sq {X : Ω → ℝ} (hX : AEStronglyMeasurable X μ) {c : ℝ≥0}
(hc : c ≠ 0) : μ {ω | ↑c ≤ |X ω - μ[X]|} ≤ evariance X μ / c ^ 2 := by
have A : (c : ℝ≥0∞) ≠ 0 := by rwa [Ne, ENNReal.coe_eq_zero]
have B : AEStronglyMeasurable (fun _ : Ω => μ[X]) μ := aestronglyMeasurable_const
convert meas_ge_le_mul_pow_eLpNorm μ two_ne_zero ENNReal.ofNat_ne_top (hX.sub B) A using 1
· congr
simp only [Pi.sub_apply, ENNReal.coe_le_coe, ← Real.norm_eq_abs, ← coe_nnnorm,
NNReal.coe_le_coe]
· rw [eLpNorm_eq_lintegral_rpow_enorm two_ne_zero ENNReal.ofNat_ne_top]
simp only [ENNReal.toReal_ofNat, one_div, Pi.sub_apply]
rw [div_eq_mul_inv, ENNReal.inv_pow, mul_comm, ENNReal.rpow_two]
congr
simp_rw [← ENNReal.rpow_mul, inv_mul_cancel₀ (two_ne_zero : (2 : ℝ) ≠ 0), ENNReal.rpow_two,
ENNReal.rpow_one, evariance] | theorem | Probability | [
"Mathlib.Probability.Moments.Covariance"
] | Mathlib/Probability/Moments/Variance.lean | meas_ge_le_evariance_div_sq | 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`. -/
scoped notation "eVar[" X "; " μ "]" => ProbabilityTheory.evariance X μ
/-- 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`. -/
scoped notation "eVar[" X "]" => eVar[X; MeasureTheory.MeasureSpace.volume]
/-- The `ℝ`-valued variance of the real-valued random variable `X` according to the measure `μ`.
It is set to `0` if `X` has infinite variance. -/
scoped notation "Var[" X "; " μ "]" => ProbabilityTheory.variance X μ
/-- 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. -/
scoped notation "Var[" X "]" => Var[X; MeasureTheory.MeasureSpace.volume]
theorem evariance_congr (h : X =ᵐ[μ] Y) : eVar[X; μ] = eVar[Y; μ] := by
simp_rw [evariance, integral_congr_ae h]
apply lintegral_congr_ae
filter_upwards [h] with ω hω using by simp [hω]
theorem variance_congr (h : X =ᵐ[μ] Y) : Var[X; μ] = Var[Y; μ] := by
simp_rw [variance, evariance_congr h]
theorem evariance_lt_top [IsFiniteMeasure μ] (hX : MemLp X 2 μ) : evariance X μ < ∞ := by
have := ENNReal.pow_lt_top (hX.sub <| memLp_const <| μ[X]).2 (n := 2)
rw [eLpNorm_eq_lintegral_rpow_enorm two_ne_zero ENNReal.ofNat_ne_top, ← ENNReal.rpow_two] at this
simp only [ENNReal.toReal_ofNat, Pi.sub_apply, one_div] at this
rw [← ENNReal.rpow_mul, inv_mul_cancel₀ (two_ne_zero : (2 : ℝ) ≠ 0), ENNReal.rpow_one] at this
simp_rw [ENNReal.rpow_two] at this
exact this
lemma evariance_ne_top [IsFiniteMeasure μ] (hX : MemLp X 2 μ) : evariance X μ ≠ ∞ :=
(evariance_lt_top hX).ne
theorem evariance_eq_top [IsFiniteMeasure μ] (hXm : AEStronglyMeasurable X μ) (hX : ¬MemLp X 2 μ) :
evariance X μ = ∞ := by
by_contra h
rw [← Ne, ← lt_top_iff_ne_top] at h
have : MemLp (fun ω => X ω - μ[X]) 2 μ := by
refine ⟨by fun_prop, ?_⟩
rw [eLpNorm_eq_lintegral_rpow_enorm two_ne_zero ENNReal.ofNat_ne_top]
simp only [ENNReal.toReal_ofNat, ENNReal.rpow_two]
exact ENNReal.rpow_lt_top_of_nonneg (by linarith) h.ne
refine hX ?_
convert this.add (memLp_const μ[X])
ext ω
rw [Pi.add_apply, sub_add_cancel]
theorem evariance_lt_top_iff_memLp [IsFiniteMeasure μ] (hX : AEStronglyMeasurable X μ) :
evariance X μ < ∞ ↔ MemLp X 2 μ where
mp := by contrapose!; rw [top_le_iff]; exact evariance_eq_top hX
mpr := evariance_lt_top
lemma evariance_eq_top_iff [IsFiniteMeasure μ] (hX : AEStronglyMeasurable X μ) :
evariance X μ = ∞ ↔ ¬ MemLp X 2 μ := by simp [← evariance_lt_top_iff_memLp hX]
lemma variance_of_not_memLp [IsFiniteMeasure μ] (hX : AEStronglyMeasurable X μ)
(hX_not : ¬ MemLp X 2 μ) :
variance X μ = 0 := by simp [variance, (evariance_eq_top_iff hX).mpr hX_not]
theorem ofReal_variance [IsFiniteMeasure μ] (hX : MemLp X 2 μ) :
.ofReal (variance X μ) = evariance X μ := by
rw [variance, ENNReal.ofReal_toReal]
exact evariance_ne_top hX
protected alias _root_.MeasureTheory.MemLp.evariance_lt_top := evariance_lt_top
protected alias _root_.MeasureTheory.MemLp.evariance_ne_top := evariance_ne_top
protected alias _root_.MeasureTheory.MemLp.ofReal_variance_eq := ofReal_variance
variable (X μ) in
theorem evariance_eq_lintegral_ofReal :
evariance X μ = ∫⁻ ω, ENNReal.ofReal ((X ω - μ[X]) ^ 2) ∂μ := by
simp [evariance, ← enorm_pow, Real.enorm_of_nonneg (sq_nonneg _)]
lemma variance_eq_integral (hX : AEMeasurable X μ) : Var[X; μ] = ∫ ω, (X ω - μ[X]) ^ 2 ∂μ := by
simp [variance, evariance, toReal_enorm, ← integral_toReal ((hX.sub_const _).enorm.pow_const _) <|
.of_forall fun _ ↦ ENNReal.pow_lt_top enorm_lt_top]
lemma variance_of_integral_eq_zero (hX : AEMeasurable X μ) (hXint : μ[X] = 0) :
variance X μ = ∫ ω, X ω ^ 2 ∂μ := by
simp [variance_eq_integral hX, hXint]
@[simp]
theorem evariance_zero : evariance 0 μ = 0 := by simp [evariance]
theorem evariance_eq_zero_iff (hX : AEMeasurable X μ) :
evariance X μ = 0 ↔ X =ᵐ[μ] fun _ => μ[X] := by
simp [evariance, lintegral_eq_zero_iff' ((hX.sub_const _).enorm.pow_const _), EventuallyEq,
sub_eq_zero]
theorem evariance_mul (c : ℝ) (X : Ω → ℝ) (μ : Measure Ω) :
evariance (fun ω => c * X ω) μ = ENNReal.ofReal (c ^ 2) * evariance X μ := by
rw [evariance, evariance, ← lintegral_const_mul' _ _ ENNReal.ofReal_lt_top.ne]
congr with ω
rw [integral_const_mul, ← mul_sub, enorm_mul, mul_pow, ← enorm_pow,
Real.enorm_of_nonneg (sq_nonneg _)]
@[simp]
theorem variance_zero (μ : Measure Ω) : variance 0 μ = 0 := by
simp only [variance, evariance_zero, ENNReal.toReal_zero]
lemma covariance_self {X : Ω → ℝ} (hX : AEMeasurable X μ) :
cov[X, X; μ] = Var[X; μ] := by
rw [covariance, variance_eq_integral hX]
congr with x
ring
@[deprecated (since := "2025-06-25")] alias covariance_same := covariance_self
theorem variance_nonneg (X : Ω → ℝ) (μ : Measure Ω) : 0 ≤ variance X μ :=
ENNReal.toReal_nonneg
theorem variance_mul (c : ℝ) (X : Ω → ℝ) (μ : Measure Ω) :
variance (fun ω => c * X ω) μ = c ^ 2 * variance X μ := by
rw [variance, evariance_mul, ENNReal.toReal_mul, ENNReal.toReal_ofReal (sq_nonneg _)]
rfl
theorem variance_smul (c : ℝ) (X : Ω → ℝ) (μ : Measure Ω) :
variance (c • X) μ = c ^ 2 * variance X μ :=
variance_mul c X μ
theorem variance_smul' {A : Type*} [CommSemiring A] [Algebra A ℝ] (c : A) (X : Ω → ℝ)
(μ : Measure Ω) : variance (c • X) μ = c ^ 2 • variance X μ := by
convert variance_smul (algebraMap A ℝ c) X μ using 1
· simp only [algebraMap_smul]
· simp only [Algebra.smul_def, map_pow]
theorem variance_eq_sub [IsProbabilityMeasure μ] {X : Ω → ℝ} (hX : MemLp X 2 μ) :
variance X μ = μ[X ^ 2] - μ[X] ^ 2 := by
rw [← covariance_self hX.aemeasurable, covariance_eq_sub hX hX, pow_two, pow_two]
@[deprecated (since := "2025-08-07")] alias variance_def' := variance_eq_sub
lemma variance_add_const [IsProbabilityMeasure μ] (hX : AEStronglyMeasurable X μ) (c : ℝ) :
Var[fun ω ↦ X ω + c; μ] = Var[X; μ] := by
by_cases hX_Lp : MemLp X 2 μ
· have hX_int : Integrable X μ := hX_Lp.integrable one_le_two
rw [variance_eq_integral (hX.add_const _).aemeasurable,
integral_add hX_int (by fun_prop), integral_const, variance_eq_integral hX.aemeasurable]
simp
· rw [variance_of_not_memLp (hX.add_const _), variance_of_not_memLp hX hX_Lp]
refine fun h_memLp ↦ hX_Lp ?_
have : X = fun ω ↦ X ω + c - c := by ext; ring
rw [this]
exact h_memLp.sub (memLp_const c)
lemma variance_const_add [IsProbabilityMeasure μ] (hX : AEStronglyMeasurable X μ) (c : ℝ) :
Var[fun ω ↦ c + X ω; μ] = Var[X; μ] := by
simp_rw [add_comm c, variance_add_const hX c]
lemma variance_fun_neg : Var[fun ω ↦ -X ω; μ] = Var[X; μ] := by
convert variance_mul (-1) X μ
· ext; ring
· simp
lemma variance_neg : Var[-X; μ] = Var[X; μ] := variance_fun_neg
lemma variance_sub_const [IsProbabilityMeasure μ] (hX : AEStronglyMeasurable X μ) (c : ℝ) :
Var[fun ω ↦ X ω - c; μ] = Var[X; μ] := by
simp_rw [sub_eq_add_neg, variance_add_const hX (-c)]
lemma variance_const_sub [IsProbabilityMeasure μ] (hX : AEStronglyMeasurable X μ) (c : ℝ) :
Var[fun ω ↦ c - X ω; μ] = Var[X; μ] := by
simp_rw [sub_eq_add_neg]
rw [variance_const_add (by fun_prop) c, variance_fun_neg]
lemma variance_add [IsFiniteMeasure μ] (hX : MemLp X 2 μ) (hY : MemLp Y 2 μ) :
Var[X + Y; μ] = Var[X; μ] + 2 * cov[X, Y; μ] + Var[Y; μ] := by
rw [← covariance_self, covariance_add_left hX hY (hX.add hY), covariance_add_right hX hX hY,
covariance_add_right hY hX hY, covariance_self, covariance_self, covariance_comm]
· ring
· exact hY.aemeasurable
· exact hX.aemeasurable
· exact hX.aemeasurable.add hY.aemeasurable
lemma variance_fun_add [IsFiniteMeasure μ] (hX : MemLp X 2 μ) (hY : MemLp Y 2 μ) :
Var[fun ω ↦ X ω + Y ω; μ] = Var[X; μ] + 2 * cov[X, Y; μ] + Var[Y; μ] :=
variance_add hX hY
lemma variance_sub [IsFiniteMeasure μ] (hX : MemLp X 2 μ) (hY : MemLp Y 2 μ) :
Var[X - Y; μ] = Var[X; μ] - 2 * cov[X, Y; μ] + Var[Y; μ] := by
rw [sub_eq_add_neg, variance_add hX hY.neg, variance_neg, covariance_neg_right]
ring
lemma variance_fun_sub [IsFiniteMeasure μ] (hX : MemLp X 2 μ) (hY : MemLp Y 2 μ) :
Var[fun ω ↦ X ω - Y ω; μ] = Var[X; μ] - 2 * cov[X, Y; μ] + Var[Y; μ] :=
variance_sub hX hY
variable {ι : Type*} {s : Finset ι} {X : (i : ι) → Ω → ℝ}
lemma variance_sum' [IsFiniteMeasure μ] (hX : ∀ i ∈ s, MemLp (X i) 2 μ) :
Var[∑ i ∈ s, X i; μ] = ∑ i ∈ s, ∑ j ∈ s, cov[X i, X j; μ] := by
rw [← covariance_self, covariance_sum_left' (by simpa)]
· refine Finset.sum_congr rfl fun i hi ↦ ?_
rw [covariance_sum_right' (by simpa) (hX i hi)]
· exact memLp_finset_sum' _ (by simpa)
· exact (memLp_finset_sum' _ (by simpa)).aemeasurable
lemma variance_sum [IsFiniteMeasure μ] [Fintype ι] (hX : ∀ i, MemLp (X i) 2 μ) :
Var[∑ i, X i; μ] = ∑ i, ∑ j, cov[X i, X j; μ] :=
variance_sum' (fun _ _ ↦ hX _)
lemma variance_fun_sum' [IsFiniteMeasure μ] (hX : ∀ i ∈ s, MemLp (X i) 2 μ) :
Var[fun ω ↦ ∑ i ∈ s, X i ω; μ] = ∑ i ∈ s, ∑ j ∈ s, cov[X i, X j; μ] := by
convert variance_sum' hX
simp
lemma variance_fun_sum [IsFiniteMeasure μ] [Fintype ι] (hX : ∀ i, MemLp (X i) 2 μ) :
Var[fun ω ↦ ∑ i, X i ω; μ] = ∑ i, ∑ j, cov[X i, X j; μ] := by
convert variance_sum hX
simp
variable {X : Ω → ℝ}
@[simp]
lemma variance_dirac [MeasurableSingletonClass Ω] (x : Ω) : Var[X; Measure.dirac x] = 0 := by
rw [variance_eq_integral]
· simp
· exact aemeasurable_dirac
lemma variance_map {Ω' : Type*} {mΩ' : MeasurableSpace Ω'} {μ : Measure Ω'}
{Y : Ω' → Ω} (hX : AEMeasurable X (μ.map Y)) (hY : AEMeasurable Y μ) :
Var[X; μ.map Y] = Var[X ∘ Y; μ] := by
rw [variance_eq_integral hX, integral_map hY, variance_eq_integral (hX.comp_aemeasurable hY),
integral_map hY]
· congr
· exact hX.aestronglyMeasurable
· refine AEStronglyMeasurable.pow ?_ _
exact AEMeasurable.aestronglyMeasurable (by fun_prop)
lemma _root_.MeasureTheory.MeasurePreserving.variance_fun_comp {Ω' : Type*}
{mΩ' : MeasurableSpace Ω'} {ν : Measure Ω'} {X : Ω → Ω'}
(hX : MeasurePreserving X μ ν) {f : Ω' → ℝ} (hf : AEMeasurable f ν) :
Var[fun ω ↦ f (X ω); μ] = Var[f; ν] := by
rw [← hX.map_eq, variance_map (hX.map_eq ▸ hf) hX.aemeasurable, Function.comp_def]
lemma variance_map_equiv {Ω' : Type*} {mΩ' : MeasurableSpace Ω'} {μ : Measure Ω'}
(X : Ω → ℝ) (Y : Ω' ≃ᵐ Ω) :
Var[X; μ.map Y] = Var[X ∘ Y; μ] := by
simp_rw [variance, evariance, lintegral_map_equiv, integral_map_equiv, Function.comp_apply]
lemma variance_id_map (hX : AEMeasurable X μ) : Var[id; μ.map X] = Var[X; μ] := by
simp [variance_map measurable_id.aemeasurable hX]
theorem variance_le_expectation_sq [IsProbabilityMeasure μ] {X : Ω → ℝ}
(hm : AEStronglyMeasurable X μ) : variance X μ ≤ μ[X ^ 2] := by
by_cases hX : MemLp X 2 μ
· rw [variance_eq_sub hX]
simp only [sq_nonneg, sub_le_self_iff]
rw [variance, evariance_eq_lintegral_ofReal, ← integral_eq_lintegral_of_nonneg_ae]
· by_cases hint : Integrable X μ; swap
· simp only [integral_undef hint, Pi.pow_apply, sub_zero]
exact le_rfl
· rw [integral_undef]
· exact integral_nonneg fun a => sq_nonneg _
intro h
have A : MemLp (X - fun ω : Ω => μ[X]) 2 μ :=
(memLp_two_iff_integrable_sq (by fun_prop)).2 h
have B : MemLp (fun _ : Ω => μ[X]) 2 μ := memLp_const _
apply hX
convert A.add B
simp
· exact Eventually.of_forall fun x => sq_nonneg _
· exact (AEMeasurable.pow_const (hm.aemeasurable.sub_const _) _).aestronglyMeasurable
theorem evariance_def' [IsProbabilityMeasure μ] {X : Ω → ℝ} (hX : AEStronglyMeasurable X μ) :
evariance X μ = (∫⁻ ω, ‖X ω‖ₑ ^ 2 ∂μ) - ENNReal.ofReal (μ[X] ^ 2) := by
by_cases hℒ : MemLp X 2 μ
· rw [← ofReal_variance hℒ, variance_eq_sub hℒ, ENNReal.ofReal_sub _ (sq_nonneg _)]
congr
simp_rw [← enorm_pow, enorm]
rw [lintegral_coe_eq_integral]
· simp
· simpa using hℒ.abs.integrable_sq
· symm
rw [evariance_eq_top hX hℒ, ENNReal.sub_eq_top_iff]
refine ⟨?_, ENNReal.ofReal_ne_top⟩
rw [MemLp, not_and] at hℒ
specialize hℒ hX
simp only [eLpNorm_eq_lintegral_rpow_enorm two_ne_zero ENNReal.ofNat_ne_top, not_lt, top_le_iff,
ENNReal.toReal_ofNat, one_div, ENNReal.rpow_eq_top_iff, inv_lt_zero, inv_pos, and_true,
or_iff_not_imp_left, not_and_or, zero_lt_two] at hℒ
exact mod_cast hℒ fun _ => zero_le_two
set_option linter.deprecated false in
/-- **Chebyshev's inequality** for `ℝ≥0∞`-valued variance. |
meas_ge_le_variance_div_sq [IsFiniteMeasure μ] {X : Ω → ℝ} (hX : MemLp X 2 μ) {c : ℝ}
(hc : 0 < c) : μ {ω | c ≤ |X ω - μ[X]|} ≤ ENNReal.ofReal (variance X μ / c ^ 2) := by
rw [ENNReal.ofReal_div_of_pos (sq_pos_of_ne_zero hc.ne.symm), hX.ofReal_variance_eq]
convert @meas_ge_le_evariance_div_sq _ _ _ _ hX.1 c.toNNReal (by simp [hc]) using 1
· simp only [Real.coe_toNNReal', max_le_iff, abs_nonneg, and_true]
· rw [ENNReal.ofReal_pow hc.le]
rfl | theorem | Probability | [
"Mathlib.Probability.Moments.Covariance"
] | Mathlib/Probability/Moments/Variance.lean | meas_ge_le_variance_div_sq | **Chebyshev's inequality**: one can control the deviation probability of a real random variable
from its expectation in terms of the variance. |
IndepFun.variance_fun_add {X Y : Ω → ℝ} (hX : MemLp X 2 μ)
(hY : MemLp Y 2 μ) (h : IndepFun X Y μ) : Var[fun ω ↦ X ω + Y ω; μ] = Var[X; μ] + Var[Y; μ] :=
h.variance_add hX hY | lemma | Probability | [
"Mathlib.Probability.Moments.Covariance"
] | Mathlib/Probability/Moments/Variance.lean | IndepFun.variance_fun_add | The variance of the sum of two independent random variables is the sum of the variances. -/
nonrec theorem IndepFun.variance_add {X Y : Ω → ℝ} (hX : MemLp X 2 μ)
(hY : MemLp Y 2 μ) (h : IndepFun X Y μ) : Var[X + Y; μ] = Var[X; μ] + Var[Y; μ] := by
by_cases h' : X =ᵐ[μ] 0
· rw [variance_congr h', variance_congr h'.add_right]
simp
have := hX.isProbabilityMeasure_of_indepFun X Y (by simp) (by simp) h' h
rw [variance_add hX hY, h.covariance_eq_zero hX hY]
simp
/-- The variance of the sum of two independent random variables is the sum of the variances. |
variance_le_sub_mul_sub [IsProbabilityMeasure μ] {a b : ℝ} {X : Ω → ℝ}
(h : ∀ᵐ ω ∂μ, X ω ∈ Set.Icc a b) (hX : AEMeasurable X μ) :
variance X μ ≤ (b - μ[X]) * (μ[X] - a) := by
have ha : ∀ᵐ ω ∂μ, a ≤ X ω := h.mono fun ω h => h.1
have hb : ∀ᵐ ω ∂μ, X ω ≤ b := h.mono fun ω h => h.2
have hX_int₂ : Integrable (fun ω ↦ -X ω ^ 2) μ :=
(memLp_of_bounded h hX.aestronglyMeasurable 2).integrable_sq.neg
have hX_int₁ : Integrable (fun ω ↦ (a + b) * X ω) μ :=
((integrable_const (max |a| |b|)).mono' hX.aestronglyMeasurable
(by filter_upwards [ha, hb] with ω using abs_le_max_abs_abs)).const_mul (a + b)
have h0 : 0 ≤ -μ[X ^ 2] + (a + b) * μ[X] - a * b :=
calc
_ ≤ ∫ ω, (b - X ω) * (X ω - a) ∂μ := by
apply integral_nonneg_of_ae
filter_upwards [ha, hb] with ω ha' hb'
exact mul_nonneg (by linarith : 0 ≤ b - X ω) (by linarith : 0 ≤ X ω - a)
_ = ∫ ω, -X ω ^ 2 + (a + b) * X ω - a * b ∂μ :=
integral_congr_ae <| ae_of_all μ fun ω ↦ by ring
_ = ∫ ω, - X ω ^ 2 + (a + b) * X ω ∂μ - ∫ _, a * b ∂μ :=
integral_sub (by fun_prop) (integrable_const (a * b))
_ = ∫ ω, - X ω ^ 2 + (a + b) * X ω ∂μ - a * b := by simp
_ = - μ[X ^ 2] + (a + b) * μ[X] - a * b := by
simp [← integral_neg, ← integral_const_mul, integral_add hX_int₂ hX_int₁]
calc
_ ≤ (a + b) * μ[X] - a * b - μ[X] ^ 2 := by
rw [variance_eq_sub (memLp_of_bounded h hX.aestronglyMeasurable 2)]
linarith
_ = (b - μ[X]) * (μ[X] - a) := by ring | lemma | Probability | [
"Mathlib.Probability.Moments.Covariance"
] | Mathlib/Probability/Moments/Variance.lean | variance_le_sub_mul_sub | The variance of a finite sum of pairwise independent random variables is the sum of the
variances. -/
nonrec theorem IndepFun.variance_sum {ι : Type*} {X : ι → Ω → ℝ} {s : Finset ι}
(hs : ∀ i ∈ s, MemLp (X i) 2 μ)
(h : Set.Pairwise ↑s fun i j => IndepFun (X i) (X j) μ) :
variance (∑ i ∈ s, X i) μ = ∑ i ∈ s, variance (X i) μ := by
by_cases h'' : ∀ i ∈ s, X i =ᵐ[μ] 0
· rw [variance_congr (Y := 0), variance_zero]
· symm
refine Finset.sum_eq_zero fun i hi ↦ ?_
simp [variance_congr (h'' i hi)]
· have := fun (i : s) ↦ h'' i.1 i.2
filter_upwards [ae_all_iff.2 this] with ω hω
simp only [sum_apply, Pi.zero_apply]
exact Finset.sum_eq_zero fun i hi ↦ hω ⟨i, hi⟩
obtain ⟨j, hj1, hj2⟩ := not_forall₂.1 h''
obtain rfl | h' := s.eq_singleton_or_nontrivial hj1
· simp
obtain ⟨k, hk1, hk2⟩ := h'.exists_ne j
have := (hs j hj1).isProbabilityMeasure_of_indepFun (X j) (X k) (by simp) (by simp) hj2
(h hj1 hk1 hk2.symm)
rw [variance_sum' hs]
refine Finset.sum_congr rfl (fun i hi ↦ ?_)
rw [← covariance_self (hs i hi).aemeasurable]
refine Finset.sum_eq_single_of_mem i hi fun j hj1 hj2 ↦ ?_
exact (h hi hj1 hj2.symm).covariance_eq_zero (hs i hi) (hs j hj1)
/-- **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)`. |
variance_le_sq_of_bounded [IsProbabilityMeasure μ] {a b : ℝ} {X : Ω → ℝ}
(h : ∀ᵐ ω ∂μ, X ω ∈ Set.Icc a b) (hX : AEMeasurable X μ) :
variance X μ ≤ ((b - a) / 2) ^ 2 :=
calc
_ ≤ (b - μ[X]) * (μ[X] - a) := variance_le_sub_mul_sub h hX
_ = ((b - a) / 2) ^ 2 - (μ[X] - (b + a) / 2) ^ 2 := by ring
_ ≤ ((b - a) / 2) ^ 2 := sub_le_self _ (sq_nonneg _) | lemma | Probability | [
"Mathlib.Probability.Moments.Covariance"
] | Mathlib/Probability/Moments/Variance.lean | variance_le_sq_of_bounded | **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`. |
variance_add_prod (hfμ : MemLp X 2 μ) (hgν : MemLp Y 2 ν) :
Var[fun p ↦ X p.1 + Y p.2; μ.prod ν] = Var[X; μ] + Var[Y; ν] := by
refine (IndepFun.variance_fun_add (hfμ.comp_fst ν) (hgν.comp_snd μ) ?_).trans ?_
· exact indepFun_prod₀ hfμ.aemeasurable hgν.aemeasurable
· rw [measurePreserving_fst.variance_fun_comp hfμ.aemeasurable,
measurePreserving_snd.variance_fun_comp hgν.aemeasurable] | lemma | Probability | [
"Mathlib.Probability.Moments.Covariance"
] | Mathlib/Probability/Moments/Variance.lean | variance_add_prod | null |
variance_dual_prod' {L : StrongDual ℝ (E × F)}
(hLμ : MemLp (L.comp (.inl ℝ E F)) 2 μ) (hLν : MemLp (L.comp (.inr ℝ E F)) 2 ν) :
Var[L; μ.prod ν] = Var[L.comp (.inl ℝ E F); μ] + Var[L.comp (.inr ℝ E F); ν] := by
have : L = fun x : E × F ↦ L.comp (.inl ℝ E F) x.1 + L.comp (.inr ℝ E F) x.2 := by
ext; rw [L.comp_inl_add_comp_inr]
rw [this, variance_add_prod hLμ hLν] | lemma | Probability | [
"Mathlib.Probability.Moments.Covariance"
] | Mathlib/Probability/Moments/Variance.lean | variance_dual_prod' | null |
variance_dual_prod {L : StrongDual ℝ (E × F)} (hLμ : MemLp id 2 μ) (hLν : MemLp id 2 ν) :
Var[L; μ.prod ν] = Var[L.comp (.inl ℝ E F); μ] + Var[L.comp (.inr ℝ E F); ν] :=
variance_dual_prod' (ContinuousLinearMap.comp_memLp' _ hLμ)
(ContinuousLinearMap.comp_memLp' _ hLν) | lemma | Probability | [
"Mathlib.Probability.Moments.Covariance"
] | Mathlib/Probability/Moments/Variance.lean | variance_dual_prod | null |
PMF.{u} (α : Type u) : Type u :=
{ f : α → ℝ≥0∞ // HasSum f 1 } | def | Probability | [
"Mathlib.Topology.Instances.ENNReal.Lemmas",
"Mathlib.MeasureTheory.Measure.Dirac"
] | Mathlib/Probability/ProbabilityMassFunction/Basic.lean | PMF. | A probability mass function, or discrete probability measures is a function `α → ℝ≥0∞` such
that the values have (infinite) sum `1`. |
instFunLike : FunLike (PMF α) α ℝ≥0∞ where
coe p a := p.1 a
coe_injective' _ _ h := Subtype.eq h
@[ext] | instance | Probability | [
"Mathlib.Topology.Instances.ENNReal.Lemmas",
"Mathlib.MeasureTheory.Measure.Dirac"
] | Mathlib/Probability/ProbabilityMassFunction/Basic.lean | instFunLike | null |
protected ext {p q : PMF α} (h : ∀ x, p x = q x) : p = q :=
DFunLike.ext p q h | theorem | Probability | [
"Mathlib.Topology.Instances.ENNReal.Lemmas",
"Mathlib.MeasureTheory.Measure.Dirac"
] | Mathlib/Probability/ProbabilityMassFunction/Basic.lean | ext | null |
hasSum_coe_one (p : PMF α) : HasSum p 1 :=
p.2
@[simp] | theorem | Probability | [
"Mathlib.Topology.Instances.ENNReal.Lemmas",
"Mathlib.MeasureTheory.Measure.Dirac"
] | Mathlib/Probability/ProbabilityMassFunction/Basic.lean | hasSum_coe_one | null |
tsum_coe (p : PMF α) : ∑' a, p a = 1 :=
p.hasSum_coe_one.tsum_eq | theorem | Probability | [
"Mathlib.Topology.Instances.ENNReal.Lemmas",
"Mathlib.MeasureTheory.Measure.Dirac"
] | Mathlib/Probability/ProbabilityMassFunction/Basic.lean | tsum_coe | null |
tsum_coe_ne_top (p : PMF α) : ∑' a, p a ≠ ∞ :=
p.tsum_coe.symm ▸ ENNReal.one_ne_top | theorem | Probability | [
"Mathlib.Topology.Instances.ENNReal.Lemmas",
"Mathlib.MeasureTheory.Measure.Dirac"
] | Mathlib/Probability/ProbabilityMassFunction/Basic.lean | tsum_coe_ne_top | null |
tsum_coe_indicator_ne_top (p : PMF α) (s : Set α) : ∑' a, s.indicator p a ≠ ∞ :=
ne_of_lt (lt_of_le_of_lt
(ENNReal.tsum_le_tsum (fun _ => Set.indicator_apply_le fun _ => le_rfl))
(lt_of_le_of_ne le_top p.tsum_coe_ne_top))
@[simp] | theorem | Probability | [
"Mathlib.Topology.Instances.ENNReal.Lemmas",
"Mathlib.MeasureTheory.Measure.Dirac"
] | Mathlib/Probability/ProbabilityMassFunction/Basic.lean | tsum_coe_indicator_ne_top | null |
coe_ne_zero (p : PMF α) : ⇑p ≠ 0 := fun hp =>
zero_ne_one ((tsum_zero.symm.trans (tsum_congr fun x => symm (congr_fun hp x))).trans p.tsum_coe) | theorem | Probability | [
"Mathlib.Topology.Instances.ENNReal.Lemmas",
"Mathlib.MeasureTheory.Measure.Dirac"
] | Mathlib/Probability/ProbabilityMassFunction/Basic.lean | coe_ne_zero | null |
support (p : PMF α) : Set α :=
Function.support p
@[simp] | def | Probability | [
"Mathlib.Topology.Instances.ENNReal.Lemmas",
"Mathlib.MeasureTheory.Measure.Dirac"
] | Mathlib/Probability/ProbabilityMassFunction/Basic.lean | support | The support of a `PMF` is the set where it is nonzero. |
mem_support_iff (p : PMF α) (a : α) : a ∈ p.support ↔ p a ≠ 0 := Iff.rfl
@[simp] | theorem | Probability | [
"Mathlib.Topology.Instances.ENNReal.Lemmas",
"Mathlib.MeasureTheory.Measure.Dirac"
] | Mathlib/Probability/ProbabilityMassFunction/Basic.lean | mem_support_iff | null |
support_nonempty (p : PMF α) : p.support.Nonempty :=
Function.support_nonempty_iff.2 p.coe_ne_zero
@[simp] | theorem | Probability | [
"Mathlib.Topology.Instances.ENNReal.Lemmas",
"Mathlib.MeasureTheory.Measure.Dirac"
] | Mathlib/Probability/ProbabilityMassFunction/Basic.lean | support_nonempty | null |
support_countable (p : PMF α) : p.support.Countable :=
Summable.countable_support_ennreal (tsum_coe_ne_top p) | theorem | Probability | [
"Mathlib.Topology.Instances.ENNReal.Lemmas",
"Mathlib.MeasureTheory.Measure.Dirac"
] | Mathlib/Probability/ProbabilityMassFunction/Basic.lean | support_countable | null |
apply_eq_zero_iff (p : PMF α) (a : α) : p a = 0 ↔ a ∉ p.support := by
rw [mem_support_iff, Classical.not_not] | theorem | Probability | [
"Mathlib.Topology.Instances.ENNReal.Lemmas",
"Mathlib.MeasureTheory.Measure.Dirac"
] | Mathlib/Probability/ProbabilityMassFunction/Basic.lean | apply_eq_zero_iff | null |
apply_pos_iff (p : PMF α) (a : α) : 0 < p a ↔ a ∈ p.support :=
pos_iff_ne_zero.trans (p.mem_support_iff a).symm | theorem | Probability | [
"Mathlib.Topology.Instances.ENNReal.Lemmas",
"Mathlib.MeasureTheory.Measure.Dirac"
] | Mathlib/Probability/ProbabilityMassFunction/Basic.lean | apply_pos_iff | null |
apply_eq_one_iff (p : PMF α) (a : α) : p a = 1 ↔ p.support = {a} := by
refine ⟨fun h => Set.Subset.antisymm (fun a' ha' => by_contra fun ha => ?_)
fun a' ha' => ha'.symm ▸ (p.mem_support_iff a).2 fun ha => zero_ne_one <| ha.symm.trans h,
fun h => _root_.trans (symm <| tsum_eq_single a
fun a' ha' => (p.apply_eq_zero_iff a').2 (h.symm ▸ ha')) p.tsum_coe⟩
suffices 1 < ∑' a, p a from ne_of_lt this p.tsum_coe.symm
classical
have : 0 < ∑' b, ite (b = a) 0 (p b) := lt_of_le_of_ne' zero_le'
(ENNReal.summable.tsum_ne_zero_iff.2
⟨a', ite_ne_left_iff.2 ⟨ha, Ne.symm <| (p.mem_support_iff a').2 ha'⟩⟩)
calc
1 = 1 + 0 := (add_zero 1).symm
_ < p a + ∑' b, ite (b = a) 0 (p b) :=
(ENNReal.add_lt_add_of_le_of_lt ENNReal.one_ne_top (le_of_eq h.symm) this)
_ = ite (a = a) (p a) 0 + ∑' b, ite (b = a) 0 (p b) := by rw [eq_self_iff_true, if_true]
_ = (∑' b, ite (b = a) (p b) 0) + ∑' b, ite (b = a) 0 (p b) := by
congr
exact symm (tsum_eq_single a fun b hb => if_neg hb)
_ = ∑' b, (ite (b = a) (p b) 0 + ite (b = a) 0 (p b)) := ENNReal.tsum_add.symm
_ = ∑' b, p b := tsum_congr fun b => by split_ifs <;> simp only [zero_add, add_zero] | theorem | Probability | [
"Mathlib.Topology.Instances.ENNReal.Lemmas",
"Mathlib.MeasureTheory.Measure.Dirac"
] | Mathlib/Probability/ProbabilityMassFunction/Basic.lean | apply_eq_one_iff | null |
coe_le_one (p : PMF α) (a : α) : p a ≤ 1 := by
classical
refine hasSum_le (fun b => ?_) (hasSum_ite_eq a (p a)) (hasSum_coe_one p)
split_ifs with h <;> simp only [h, zero_le', le_rfl] | theorem | Probability | [
"Mathlib.Topology.Instances.ENNReal.Lemmas",
"Mathlib.MeasureTheory.Measure.Dirac"
] | Mathlib/Probability/ProbabilityMassFunction/Basic.lean | coe_le_one | null |
apply_ne_top (p : PMF α) (a : α) : p a ≠ ∞ :=
ne_of_lt (lt_of_le_of_lt (p.coe_le_one a) ENNReal.one_lt_top) | theorem | Probability | [
"Mathlib.Topology.Instances.ENNReal.Lemmas",
"Mathlib.MeasureTheory.Measure.Dirac"
] | Mathlib/Probability/ProbabilityMassFunction/Basic.lean | apply_ne_top | null |
apply_lt_top (p : PMF α) (a : α) : p a < ∞ :=
lt_of_le_of_ne le_top (p.apply_ne_top a) | theorem | Probability | [
"Mathlib.Topology.Instances.ENNReal.Lemmas",
"Mathlib.MeasureTheory.Measure.Dirac"
] | Mathlib/Probability/ProbabilityMassFunction/Basic.lean | apply_lt_top | null |
toOuterMeasure (p : PMF α) : OuterMeasure α :=
OuterMeasure.sum fun x : α => p x • dirac x
variable (p : PMF α) (s : Set α) | def | Probability | [
"Mathlib.Topology.Instances.ENNReal.Lemmas",
"Mathlib.MeasureTheory.Measure.Dirac"
] | Mathlib/Probability/ProbabilityMassFunction/Basic.lean | toOuterMeasure | Construct an `OuterMeasure` from a `PMF`, by assigning measure to each set `s : Set α` equal
to the sum of `p x` for each `x ∈ α`. |
toOuterMeasure_apply : p.toOuterMeasure s = ∑' x, s.indicator p x :=
tsum_congr fun x => smul_dirac_apply (p x) x s
@[simp] | theorem | Probability | [
"Mathlib.Topology.Instances.ENNReal.Lemmas",
"Mathlib.MeasureTheory.Measure.Dirac"
] | Mathlib/Probability/ProbabilityMassFunction/Basic.lean | toOuterMeasure_apply | null |
toOuterMeasure_caratheodory : p.toOuterMeasure.caratheodory = ⊤ := by
refine eq_top_iff.2 <| le_trans (le_sInf fun x hx => ?_) (le_sum_caratheodory _)
have ⟨y, hy⟩ := hx
exact
((le_of_eq (dirac_caratheodory y).symm).trans (le_smul_caratheodory _ _)).trans (le_of_eq hy)
@[simp] | theorem | Probability | [
"Mathlib.Topology.Instances.ENNReal.Lemmas",
"Mathlib.MeasureTheory.Measure.Dirac"
] | Mathlib/Probability/ProbabilityMassFunction/Basic.lean | toOuterMeasure_caratheodory | null |
toOuterMeasure_apply_finset (s : Finset α) : p.toOuterMeasure s = ∑ x ∈ s, p x := by
refine (toOuterMeasure_apply p s).trans ((tsum_eq_sum (s := s) ?_).trans ?_)
· exact fun x hx => Set.indicator_of_notMem (Finset.mem_coe.not.2 hx) _
· exact Finset.sum_congr rfl fun x hx => Set.indicator_of_mem (Finset.mem_coe.2 hx) _ | theorem | Probability | [
"Mathlib.Topology.Instances.ENNReal.Lemmas",
"Mathlib.MeasureTheory.Measure.Dirac"
] | Mathlib/Probability/ProbabilityMassFunction/Basic.lean | toOuterMeasure_apply_finset | null |
toOuterMeasure_apply_singleton (a : α) : p.toOuterMeasure {a} = p a := by
refine (p.toOuterMeasure_apply {a}).trans ((tsum_eq_single a fun b hb => ?_).trans ?_)
· classical exact ite_eq_right_iff.2 fun hb' => False.elim <| hb hb'
· classical exact ite_eq_left_iff.2 fun ha' => False.elim <| ha' rfl | theorem | Probability | [
"Mathlib.Topology.Instances.ENNReal.Lemmas",
"Mathlib.MeasureTheory.Measure.Dirac"
] | Mathlib/Probability/ProbabilityMassFunction/Basic.lean | toOuterMeasure_apply_singleton | null |
toOuterMeasure_injective : (toOuterMeasure : PMF α → OuterMeasure α).Injective :=
fun p q h => PMF.ext fun x => (p.toOuterMeasure_apply_singleton x).symm.trans
((congr_fun (congr_arg _ h) _).trans <| q.toOuterMeasure_apply_singleton x)
@[simp] | theorem | Probability | [
"Mathlib.Topology.Instances.ENNReal.Lemmas",
"Mathlib.MeasureTheory.Measure.Dirac"
] | Mathlib/Probability/ProbabilityMassFunction/Basic.lean | toOuterMeasure_injective | null |
toOuterMeasure_inj {p q : PMF α} : p.toOuterMeasure = q.toOuterMeasure ↔ p = q :=
toOuterMeasure_injective.eq_iff | theorem | Probability | [
"Mathlib.Topology.Instances.ENNReal.Lemmas",
"Mathlib.MeasureTheory.Measure.Dirac"
] | Mathlib/Probability/ProbabilityMassFunction/Basic.lean | toOuterMeasure_inj | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.