roseking's picture
Add lean source and binary files (part 91)
caec230 verified
Raw History Blame Contribute Delete
3.7 kB
16
def normal (n : ℕ) (X : Coord n) : ℝ := ∏ i : Fin n, gaussianPDFReal 0 1 (X i)
18
theorem normal_nonneg (n : ℕ) (X : Coord n) : 0 ≤ normal n X :=
proof · 1 line
  Finset.prod_nonneg (fun _ _ => gaussianPDFReal_nonneg _ _ _)
21
theorem integrable_normal (n : ℕ) : Integrable (normal n) :=
proof · 1 line
  Integrable.fintype_prod (fun _ : Fin n => integrable_gaussianPDFReal 0 1)
24
@[simp] theorem integral_normal (n : ℕ) : ∫ X, normal n X = 1 := by
proof · 3 lines
  simp only [normal]
  rw [integral_fintype_prod_volume_eq_prod]
  simp [integral_gaussianPDFReal_eq_one 0 one_ne_zero]
29
theorem normal_two (X : Coord 2) :
    normal 2 X = (2 * Real.pi)⁻¹ * Real.exp (-(X 0 ^ 2 + X 1 ^ 2) / 2) := by
proof · 12 lines
  simp only [normal, Fin.prod_univ_two, gaussianPDFReal, NNReal.coe_one, mul_one, sub_zero]
  calc
    (Real.sqrt (2 * Real.pi))⁻¹ * Real.exp (-(X 0) ^ 2 / 2) *
        ((Real.sqrt (2 * Real.pi))⁻¹ * Real.exp (-(X 1) ^ 2 / 2)) =
        ((Real.sqrt (2 * Real.pi)) ^ 2)⁻¹ *
          Real.exp (-(X 0) ^ 2 / 2 + -(X 1) ^ 2 / 2) := by
      rw [← inv_pow, Real.exp_add]
      ring
    _ = _ := by
      rw [Real.sq_sqrt (by positivity)]
      congr 2
      ring
44
def rescale {n : ℕ} (k : Coord n → ℝ) (r : ℝ) (X : Coord n) : ℝ :=
body · 1 line
  (r ^ n)⁻¹ * k (r⁻¹ • X)
47
theorem integrable_rescale {n : ℕ} {k : Coord n → ℝ} (hk : Integrable k)
    {r : ℝ} (hr : 0 < r) : Integrable (rescale k r) :=
proof · 1 line
  (hk.comp_smul (inv_ne_zero hr.ne')).const_mul _
51
theorem integral_rescale {n : ℕ} (k : Coord n → ℝ) {r : ℝ} (hr : 0 < r) :
    ∫ X, rescale k r X = ∫ X, k X := by
proof · 5 lines
  simp only [rescale]
  rw [integral_const_mul,
    Measure.integral_comp_inv_smul_of_nonneg volume k hr.le]
  simp only [Coord, Module.finrank_pi, Fintype.card_fin, smul_eq_mul]
  rw [← mul_assoc, inv_mul_cancel₀ (pow_ne_zero _ hr.ne'), one_mul]
59
theorem rescale_nonneg {n : ℕ} {k : Coord n → ℝ} (hk : ∀ X, 0 ≤ k X)
    {r : ℝ} (hr : 0 < r) (X : Coord n) : 0 ≤ rescale k r X :=
proof · 1 line
  mul_nonneg (by positivity) (hk _)
63
def kernel (ν t : ℝ) (X : Coord 2) : ℝ :=
body · 1 line
  (4 * Real.pi * ν * t)⁻¹ * Real.exp (-(X 0 ^ 2 + X 1 ^ 2) / (4 * ν * t))
66
theorem kernel_eq_rescale {ν t : ℝ} (hν : 0 < ν) (ht : 0 < t) :
    kernel ν t = rescale (normal 2) (Real.sqrt (2 * ν * t)) := by
proof · 10 lines
  funext X
  have hs : Real.sqrt (2 * ν * t) ^ 2 = 2 * ν * t := Real.sq_sqrt (by positivity)
  simp only [kernel, rescale, normal_two, Pi.smul_apply, smul_eq_mul, mul_pow, inv_pow, hs]
  rw [← mul_assoc]
  congr 1
  · field_simp [Real.pi_ne_zero, hν.ne', ht.ne']
    ring
  · congr 1
    field_simp [hν.ne', ht.ne']
    ring
79
theorem integrable_kernel {ν t : ℝ} (hν : 0 < ν) (ht : 0 < t) :
    Integrable (kernel ν t) := by
proof · 2 lines
  rw [kernel_eq_rescale hν ht]
  exact integrable_rescale (integrable_normal 2) (Real.sqrt_pos.mpr (by positivity))
84
@[simp] theorem integral_kernel {ν t : ℝ} (hν : 0 < ν) (ht : 0 < t) :
    ∫ X, kernel ν t X = 1 := by
proof · 2 lines
  rw [kernel_eq_rescale hν ht, integral_rescale _ (Real.sqrt_pos.mpr (by positivity)),
    integral_normal]
89
theorem kernel_nonneg {ν t : ℝ} (hν : 0 < ν) (ht : 0 < t) (X : Coord 2) :
    0 ≤ kernel ν t X := by
proof · 2 lines
  unfold kernel
  positivity