Skip to content

Commit ae6ea95

Browse files
committed
feat: add a predicate HasGaussianLaw (leanprover-community#32144)
Define a predicate `HasGaussianLaw X P`, which states that under the measure `P`, the random variable `X` has a Gaussian distribution, i.e. `IsGaussian (P.map X)`.
1 parent 35578db commit ae6ea95

3 files changed

Lines changed: 281 additions & 0 deletions

File tree

Mathlib.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5734,6 +5734,8 @@ public import Mathlib.Probability.Distributions.Gamma
57345734
public import Mathlib.Probability.Distributions.Gaussian.Basic
57355735
public import Mathlib.Probability.Distributions.Gaussian.CharFun
57365736
public import Mathlib.Probability.Distributions.Gaussian.Fernique
5737+
public import Mathlib.Probability.Distributions.Gaussian.HasGaussianLaw.Basic
5738+
public import Mathlib.Probability.Distributions.Gaussian.HasGaussianLaw.Def
57375739
public import Mathlib.Probability.Distributions.Gaussian.Real
57385740
public import Mathlib.Probability.Distributions.Geometric
57395741
public import Mathlib.Probability.Distributions.Pareto
Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
/-
2+
Copyright (c) 2025 Etienne Marion. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Etienne Marion
5+
-/
6+
module
7+
8+
public import Mathlib.Probability.Distributions.Gaussian.HasGaussianLaw.Def
9+
public import Mathlib.Probability.HasLaw
10+
11+
import Mathlib.Probability.Distributions.Gaussian.Fernique
12+
13+
/-!
14+
# Gaussian random variables
15+
16+
In this file we prove basic properties of Gaussian random variables.
17+
18+
# Implementation note
19+
20+
Many lemmas are duplicated with an expanded form of some function. For instance there is
21+
`HasGaussianLaw.add` and `HasGaussianLaw.fun_add`. The reason is that if someone wants for instance
22+
to rewrite using `HasGaussianLaw.charFunDual_map_eq` and provide the proof of `HasGaussianLaw`
23+
directly through dot notation, the lemma used must syntactically correspond to the random variable.
24+
25+
## Tags
26+
27+
Gaussian random variable
28+
-/
29+
30+
public section
31+
32+
open MeasureTheory ENNReal WithLp Complex
33+
open scoped RealInnerProductSpace
34+
35+
namespace ProbabilityTheory
36+
37+
variable {Ω E F ι : Type*} {mΩ : MeasurableSpace Ω} {P : Measure Ω}
38+
39+
section Basic
40+
41+
variable [TopologicalSpace E] [AddCommMonoid E] [Module ℝ E] [mE : MeasurableSpace E]
42+
{X Y : Ω → E}
43+
44+
lemma HasGaussianLaw.congr {Y : Ω → E} (hX : HasGaussianLaw X P) (h : X =ᵐ[P] Y) :
45+
HasGaussianLaw Y P where
46+
isGaussian_map := by
47+
rw [← Measure.map_congr h]
48+
exact hX.isGaussian_map
49+
50+
lemma IsGaussian.hasGaussianLaw [IsGaussian (P.map X)] : HasGaussianLaw X P where
51+
isGaussian_map := inferInstance
52+
53+
variable {mE} in
54+
lemma IsGaussian.hasGaussianLaw_id {μ : Measure E} [IsGaussian μ] : HasGaussianLaw id μ where
55+
isGaussian_map := by rwa [Measure.map_id]
56+
57+
@[fun_prop, measurability]
58+
lemma HasGaussianLaw.aemeasurable (hX : HasGaussianLaw X P) : AEMeasurable X P :=
59+
AEMeasurable.of_map_ne_zero hX.isGaussian_map.toIsProbabilityMeasure.ne_zero
60+
61+
lemma HasGaussianLaw.isProbabilityMeasure (hX : HasGaussianLaw X P) : IsProbabilityMeasure P :=
62+
haveI := hX.isGaussian_map
63+
P.isProbabilityMeasure_of_map X
64+
65+
variable {mE} in
66+
lemma HasLaw.hasGaussianLaw {μ : Measure E} (hX : HasLaw X μ P) [IsGaussian μ] :
67+
HasGaussianLaw X P where
68+
isGaussian_map := by rwa [hX.map_eq]
69+
70+
lemma HasGaussianLaw.map_of_measurable {F : Type*} [TopologicalSpace F] [AddCommMonoid F]
71+
[Module ℝ F] [MeasurableSpace F] [OpensMeasurableSpace F]
72+
(L : E →L[ℝ] F) (hX : HasGaussianLaw X P) (hL : Measurable L) :
73+
HasGaussianLaw (L ∘ X) P where
74+
isGaussian_map := by
75+
have := hX.isGaussian_map
76+
rw [← AEMeasurable.map_map_of_aemeasurable]
77+
· exact isGaussian_map_of_measurable hL
78+
all_goals fun_prop
79+
80+
end Basic
81+
82+
namespace HasGaussianLaw
83+
84+
variable [NormedAddCommGroup E] [MeasurableSpace E] [BorelSpace E] {X : Ω → E}
85+
86+
lemma charFun_map_eq [InnerProductSpace ℝ E] (t : E) (hX : HasGaussianLaw X P) :
87+
charFun (P.map X) t = exp ((P[fun ω ↦ ⟪t, X ω⟫] : ℝ) * I - Var[fun ω ↦ ⟪t, X ω⟫; P] / 2) := by
88+
rw [hX.isGaussian_map.charFun_eq, integral_map hX.aemeasurable (by fun_prop),
89+
variance_map (by fun_prop) hX.aemeasurable, integral_complex_ofReal]
90+
rfl
91+
92+
lemma _root_.ProbabilityTheory.hasGaussianLaw_iff_charFun_map_eq [CompleteSpace E]
93+
[InnerProductSpace ℝ E] [IsFiniteMeasure P] (hX : AEMeasurable X P) :
94+
HasGaussianLaw X P ↔ ∀ t,
95+
charFun (P.map X) t = exp ((P[fun ω ↦ ⟪t, X ω⟫] : ℝ) * I - Var[fun ω ↦ ⟪t, X ω⟫; P] / 2) where
96+
mp h := h.charFun_map_eq
97+
mpr h := by
98+
refine ⟨isGaussian_iff_charFun_eq.2 fun t ↦ ?_⟩
99+
rw [h, integral_map, variance_map, integral_complex_ofReal]
100+
· rfl
101+
all_goals fun_prop
102+
103+
variable [NormedSpace ℝ E]
104+
105+
lemma charFunDual_map_eq (L : StrongDual ℝ E) (hX : HasGaussianLaw X P) :
106+
charFunDual (P.map X) L = exp ((P[L ∘ X] : ℝ) * I - Var[L ∘ X; P] / 2) := by
107+
rw [hX.isGaussian_map.charFunDual_eq, integral_map hX.aemeasurable (by fun_prop),
108+
variance_map (by fun_prop) hX.aemeasurable, integral_complex_ofReal]
109+
rfl
110+
111+
lemma _root_.ProbabilityTheory.hasGaussianLaw_iff_charFunDual_map_eq
112+
[IsFiniteMeasure P] (hX : AEMeasurable X P) :
113+
HasGaussianLaw X P ↔ ∀ L,
114+
charFunDual (P.map X) L = exp ((P[L ∘ X] : ℝ) * I - Var[L ∘ X; P] / 2) where
115+
mp h := h.charFunDual_map_eq
116+
mpr h := by
117+
refine ⟨isGaussian_iff_charFunDual_eq.2 fun t ↦ ?_⟩
118+
rw [h, integral_map, variance_map, integral_complex_ofReal]
119+
· rfl
120+
all_goals fun_prop
121+
122+
lemma charFunDual_map_eq_fun (L : StrongDual ℝ E) (hX : HasGaussianLaw X P) :
123+
charFunDual (P.map X) L = exp ((∫ ω, L (X ω) ∂P) * I - Var[fun ω ↦ L (X ω); P] / 2) := by
124+
rw [hX.charFunDual_map_eq]
125+
rfl
126+
127+
/-- A Gaussian random variable has moments of all orders. -/
128+
lemma memLp [CompleteSpace E] [SecondCountableTopology E] (hX : HasGaussianLaw X P)
129+
{p : ℝ≥0∞} (hp : p ≠ ∞) :
130+
MemLp X p P := by
131+
rw [← Function.id_comp X, ← memLp_map_measure_iff]
132+
· exact hX.isGaussian_map.memLp_id _ p hp
133+
all_goals fun_prop
134+
135+
lemma memLp_two [CompleteSpace E] [SecondCountableTopology E] (hX : HasGaussianLaw X P) :
136+
MemLp X 2 P := hX.memLp (by norm_num)
137+
138+
lemma integrable [CompleteSpace E] [SecondCountableTopology E] (hX : HasGaussianLaw X P) :
139+
Integrable X P :=
140+
memLp_one_iff_integrable.1 <| hX.memLp (by norm_num)
141+
142+
variable [NormedAddCommGroup F] [NormedSpace ℝ F] [MeasurableSpace F] [BorelSpace F]
143+
144+
lemma map (hX : HasGaussianLaw X P) (L : E →L[ℝ] F) : HasGaussianLaw (L ∘ X) P :=
145+
hX.map_of_measurable L (by fun_prop)
146+
147+
lemma map_fun (hX : HasGaussianLaw X P) (L : E →L[ℝ] F) : HasGaussianLaw (fun ω ↦ L (X ω)) P :=
148+
hX.map L
149+
150+
lemma map_equiv (hX : HasGaussianLaw X P) (L : E ≃L[ℝ] F) : HasGaussianLaw (L ∘ X) P :=
151+
hX.map L.toContinuousLinearMap
152+
153+
lemma map_equiv_fun (hX : HasGaussianLaw X P) (L : E ≃L[ℝ] F) :
154+
HasGaussianLaw (fun ω ↦ L (X ω)) P := hX.map_equiv L
155+
156+
section SpecificMaps
157+
158+
lemma smul (c : ℝ) (hX : HasGaussianLaw X P) : HasGaussianLaw (c • X) P :=
159+
hX.map (.lsmul ℝ ℝ c)
160+
161+
lemma fun_smul (c : ℝ) (hX : HasGaussianLaw X P) : HasGaussianLaw (fun ω ↦ c • (X ω)) P :=
162+
hX.smul c
163+
164+
lemma neg (hX : HasGaussianLaw X P) : HasGaussianLaw (-X) P := by simpa using hX.smul (-1)
165+
166+
lemma fun_neg (hX : HasGaussianLaw X P) : HasGaussianLaw (fun ω ↦ -(X ω)) P :=
167+
hX.neg
168+
169+
section Prod
170+
171+
variable {Y : Ω → F}
172+
173+
lemma toLp_prodMk [SecondCountableTopologyEither E F] (p : ℝ≥0∞) [Fact (1 ≤ p)]
174+
(hXY : HasGaussianLaw (fun ω ↦ (X ω, Y ω)) P) :
175+
HasGaussianLaw (fun ω ↦ toLp p (X ω, Y ω)) P :=
176+
hXY.map_equiv (WithLp.prodContinuousLinearEquiv p ℝ E F).symm
177+
178+
omit [BorelSpace F] in
179+
lemma fst (hXY : HasGaussianLaw (fun ω ↦ (X ω, Y ω)) P) : HasGaussianLaw X P :=
180+
hXY.map_of_measurable (.fst ℝ E F) measurable_fst
181+
182+
omit [BorelSpace E] in
183+
lemma snd (hXY : HasGaussianLaw (fun ω ↦ (X ω, Y ω)) P) : HasGaussianLaw Y P :=
184+
hXY.map_of_measurable (.snd ℝ E F) measurable_snd
185+
186+
variable [SecondCountableTopology E] {Y : Ω → E}
187+
188+
lemma add (hXY : HasGaussianLaw (fun ω ↦ (X ω, Y ω)) P) : HasGaussianLaw (X + Y) P :=
189+
hXY.map (ContinuousLinearMap.fst ℝ E E + ContinuousLinearMap.snd ℝ E E)
190+
191+
lemma fun_add (hXY : HasGaussianLaw (fun ω ↦ (X ω, Y ω)) P) :
192+
HasGaussianLaw (fun ω ↦ X ω + Y ω) P :=
193+
hXY.add
194+
195+
lemma sub (hXY : HasGaussianLaw (fun ω ↦ (X ω, Y ω)) P) : HasGaussianLaw (X - Y) P :=
196+
hXY.map (ContinuousLinearMap.fst ℝ E E - ContinuousLinearMap.snd ℝ E E)
197+
198+
lemma fun_sub (hXY : HasGaussianLaw (fun ω ↦ (X ω, Y ω)) P) :
199+
HasGaussianLaw (fun ω ↦ X ω - Y ω) P :=
200+
hXY.sub
201+
202+
end Prod
203+
204+
section Pi
205+
206+
variable {E : ι → Type*} [∀ i, NormedAddCommGroup (E i)]
207+
[∀ i, NormedSpace ℝ (E i)] [∀ i, MeasurableSpace (E i)] [∀ i, BorelSpace (E i)]
208+
{X : (i : ι) → Ω → E i}
209+
210+
lemma eval (hX : HasGaussianLaw (fun ω ↦ (X · ω)) P) (i : ι) :
211+
HasGaussianLaw (X i) P := hX.map_of_measurable (.proj i) (measurable_pi_apply i)
212+
213+
variable [∀ i, SecondCountableTopology (E i)]
214+
215+
lemma prodMk [Finite ι] (hX : HasGaussianLaw (fun ω ↦ (X · ω)) P) (i j : ι) :
216+
HasGaussianLaw (fun ω ↦ (X i ω, X j ω)) P :=
217+
letI := Fintype.ofFinite ι
218+
hX.map (.prod (.proj i) (.proj j))
219+
220+
variable [Fintype ι]
221+
222+
lemma toLp_pi (p : ℝ≥0∞) [Fact (1 ≤ p)] (hX : HasGaussianLaw (fun ω ↦ (X · ω)) P) :
223+
HasGaussianLaw (fun ω ↦ toLp p (X · ω)) P :=
224+
hX.map_equiv (PiLp.continuousLinearEquiv p ℝ E).symm
225+
226+
lemma sum {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [MeasurableSpace E]
227+
[BorelSpace E] [SecondCountableTopology E]
228+
{X : ι → Ω → E} (hX : HasGaussianLaw (fun ω ↦ (X · ω)) P) :
229+
HasGaussianLaw (∑ i, X i) P := by
230+
convert hX.map (∑ i, .proj i)
231+
ext; simp
232+
233+
lemma fun_sum {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [MeasurableSpace E]
234+
[BorelSpace E] [SecondCountableTopology E]
235+
{X : ι → Ω → E} (hX : HasGaussianLaw (fun ω ↦ (X · ω)) P) :
236+
HasGaussianLaw (fun ω ↦ ∑ i, X i ω) P := by
237+
convert hX.sum
238+
simp
239+
240+
end Pi
241+
242+
end SpecificMaps
243+
244+
end HasGaussianLaw
245+
246+
end ProbabilityTheory
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/-
2+
Copyright (c) 2025 Etienne Marion. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Etienne Marion
5+
-/
6+
module
7+
8+
public import Mathlib.Probability.Distributions.Gaussian.Basic
9+
10+
/-!
11+
# Gaussian random variables
12+
13+
In this file we define a predicate `HasGaussianLaw X P`, which states that under the probability
14+
measure `P`, the random variable `X` has a Gaussian distribution, i.e. `IsGaussian (P.map X)`.
15+
16+
## Main definition
17+
18+
* `HasGaussianLaw X P`: The random variable `X` has a Gaussian distribution under the measure `P`.
19+
20+
## Tags
21+
22+
Gaussian random variable
23+
-/
24+
25+
open MeasureTheory
26+
27+
/-- The predicate `HasGaussianLaw X P` means that under the measure `P`,
28+
`X` has a Gaussian distribution. -/
29+
@[fun_prop]
30+
public structure ProbabilityTheory.HasGaussianLaw {Ω E : Type*} {mΩ : MeasurableSpace Ω}
31+
[TopologicalSpace E] [AddCommMonoid E] [Module ℝ E] [mE : MeasurableSpace E]
32+
(X : Ω → E) (P : Measure Ω) : Prop where
33+
protected isGaussian_map : IsGaussian (P.map X)

0 commit comments

Comments
 (0)