Buckets:
| import OAI.Probability.PosteriorReplicas.Regression.GramFactorization | |
| namespace OAI | |
| open MeasureTheory ProbabilityTheory Set Filter | |
| open scoped ENNReal NNReal RealInnerProductSpace | |
| noncomputable section | |
| universe u | |
| namespace PosteriorRegression | |
| open scoped Topology | |
| open InnerProductSpace | |
| section GaussianDomination | |
| variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] | |
| [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] | |
| lemma orthonormal_gaussian_map {n : ℕ} {u : Fin n → E} (hu : Orthonormal ℝ u) : | |
| (stdGaussian E).map (fun x => fun i => ⟪u i, x⟫) = | |
| Measure.pi (fun _ : Fin n => gaussianReal 0 1) := by | |
| let f : E → EuclideanSpace ℝ (Fin n) := fun x => WithLp.toLp 2 (fun i => ⟪u i, x⟫) | |
| have hf : Measurable f := by dsimp [f]; fun_prop | |
| have he : (stdGaussian E).map f = stdGaussian (EuclideanSpace ℝ (Fin n)) := by | |
| apply Measure.ext_of_charFun | |
| ext t | |
| have hi (x : E) : ⟪f x, t⟫ = ⟪x, ∑ i, t i • u i⟫ := by | |
| simp [f, PiLp.inner_apply, inner_sum, inner_smul_right, real_inner_comm x] | |
| have hn : ‖∑ i, t i • u i‖ ^ 2 = ‖t‖ ^ 2 := by | |
| rw [← real_inner_self_eq_norm_sq, hu.inner_sum, EuclideanSpace.real_norm_sq_eq] | |
| simp [pow_two] | |
| rw [charFun_apply, integral_map hf.aemeasurable (by fun_prop)] | |
| simp_rw [hi] | |
| change charFun (stdGaussian E) (∑ i, t i • u i) = _ | |
| rw [charFun_stdGaussian, charFun_stdGaussian] | |
| congr 2 | |
| exact_mod_cast congrArg Neg.neg hn | |
| have h := congrArg (Measure.map (WithLp.ofLp : EuclideanSpace ℝ (Fin n) → (Fin n → ℝ))) he | |
| rw [← map_pi_eq_stdGaussian] at h | |
| simpa [Measure.map_map (WithLp.measurable_ofLp _ _) hf, | |
| Measure.map_map (WithLp.measurable_ofLp _ _) (WithLp.measurable_toLp _ _), | |
| Function.comp_def, f, WithLp.ofLp_toLp, Measure.map_id] using h | |
| lemma gaussianReal_le_volume : gaussianReal 0 1 ≤ (volume : Measure ℝ) := by | |
| rw [gaussianReal_of_var_ne_zero _ (by norm_num)] | |
| conv_rhs => rw [← withDensity_one (μ := (volume : Measure ℝ))] | |
| apply withDensity_mono | |
| filter_upwards [] with x | |
| change ENNReal.ofReal (gaussianPDFReal 0 1 x) ≤ 1 | |
| rw [← ENNReal.ofReal_one] | |
| apply ENNReal.ofReal_le_ofReal | |
| unfold gaussianPDFReal | |
| have hs : 1 ≤ Real.sqrt (2 * Real.pi * (1 : ℝ≥0)) := by | |
| norm_num only [NNReal.coe_one, mul_one] | |
| apply (Real.le_sqrt (by norm_num) (by positivity)).mpr | |
| nlinarith [Real.pi_gt_three] | |
| have he : Real.exp (-(x - 0)^2 / (2 * (1 : ℝ≥0))) ≤ 1 := by | |
| apply Real.exp_le_one_iff.mpr | |
| exact div_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr (sq_nonneg _)) (by positivity) | |
| exact (mul_le_of_le_one_left (by positivity) (inv_le_one_of_one_le₀ hs)).trans he | |
| lemma measure_pi_mono {ι : Type*} [Fintype ι] {X : ι → Type*} | |
| [∀ i, MeasurableSpace (X i)] {μ ν : ∀ i, Measure (X i)} | |
| (h : ∀ i, μ i ≤ ν i) : Measure.pi μ ≤ Measure.pi ν := by | |
| have ho : OuterMeasure.pi (fun i => (μ i).toOuterMeasure) ≤ | |
| OuterMeasure.pi (fun i => (ν i).toOuterMeasure) := by | |
| apply OuterMeasure.le_pi.mpr | |
| intro s _ | |
| exact (OuterMeasure.pi_pi_le _ s).trans (Finset.prod_le_prod fun i _ => h i (s i)) | |
| apply Measure.le_iff.mpr | |
| intro s hs | |
| rw [Measure.pi_def, Measure.pi_def, toMeasure_apply _ _ hs, toMeasure_apply _ _ hs] | |
| exact ho s | |
| lemma pi_gaussianReal_le_volume (n : ℕ) : | |
| Measure.pi (fun _ : Fin n => gaussianReal 0 1) ≤ (volume : Measure (Fin n → ℝ)) := | |
| measure_pi_mono (fun _ => gaussianReal_le_volume) | |
| lemma gaussian_pairings_le {n : ℕ} (v : Fin n → E) (hv : LinearIndependent ℝ v) : | |
| (stdGaussian E).map (fun x => fun i => ⟪v i, x⟫) ≤ | |
| ENNReal.ofReal ((∏ i, ‖gramSchmidt ℝ v i‖)⁻¹) • | |
| (volume : Measure (Fin n → ℝ)) := by | |
| let u := gramSchmidtNormed ℝ v | |
| let R : Matrix (Fin n) (Fin n) ℝ := | |
| Matrix.diagonal (fun i => ‖gramSchmidt ℝ v i‖) * gsUpper n v | |
| have hu : Orthonormal ℝ u := gramSchmidtNormed_orthonormal hv | |
| have hn (i : Fin n) : ‖gramSchmidt ℝ v i‖ ≠ 0 := | |
| norm_ne_zero_iff.mpr (gramSchmidt_ne_zero i hv) | |
| have hexp (j : Fin n) : ∑ i, R i j • u i = v j := by | |
| rw [← gsUpper_expansion n v j] | |
| apply Finset.sum_congr rfl | |
| intro i _ | |
| simp only [R, u, Matrix.diagonal_mul, gramSchmidtNormed, smul_smul] | |
| congr 1 | |
| simp [hn i, mul_comm] | |
| have hdet : R.transpose.det = ∏ i, ‖gramSchmidt ℝ v i‖ := by | |
| dsimp only [R] | |
| rw [Matrix.det_transpose, Matrix.det_mul, Matrix.det_diagonal, gsUpper_det, mul_one] | |
| have hd : R.transpose.det ≠ 0 := by | |
| rw [hdet] | |
| exact Finset.prod_ne_zero_iff.mpr (fun i _ => hn i) | |
| have hpos : 0 ≤ R.transpose.det := by rw [hdet]; positivity | |
| have hf : Measurable (Matrix.toLin' R.transpose) := | |
| (Matrix.toLin' R.transpose).continuous_of_finiteDimensional.measurable | |
| have heq : (fun x : E => fun j => ⟪v j, x⟫) = | |
| (Matrix.toLin' R.transpose) ∘ (fun x => fun i => ⟪u i, x⟫) := by | |
| funext x j | |
| rw [← hexp j] | |
| simp [Matrix.toLin'_apply, Matrix.mulVec, dotProduct, sum_inner, | |
| inner_smul_left] | |
| rw [heq, ← Measure.map_map hf (by fun_prop), orthonormal_gaussian_map hu] | |
| calc | |
| _ ≤ (volume : Measure (Fin n → ℝ)).map (Matrix.toLin' R.transpose) := | |
| Measure.map_mono (pi_gaussianReal_le_volume n) hf | |
| _ = _ := by | |
| rw [Real.map_matrix_volume_pi_eq_smul_volume_pi hd, | |
| abs_of_nonneg (inv_nonneg.mpr hpos), hdet] | |
| lemma measure_pi_smul {ι : Type*} [Fintype ι] {X : ι → Type*} | |
| [∀ i, MeasurableSpace (X i)] (μ : ∀ i, Measure (X i)) [∀ i, SigmaFinite (μ i)] | |
| (c : ℝ≥0∞) (hc : c ≠ ∞) : | |
| Measure.pi (fun i => c • μ i) = c ^ Fintype.card ι • Measure.pi μ := by | |
| lift c to ℝ≥0 using hc | |
| simp_rw [Measure.coe_nnreal_smul] | |
| apply Measure.pi_eq | |
| intro s _ | |
| simp only [Measure.smul_apply, Measure.pi_pi, ENNReal.smul_def, smul_eq_mul, Finset.prod_mul_distrib, | |
| Finset.prod_const, Finset.card_univ] | |
| lemma gaussian_rows_pairings_le {n : ℕ} (v : Fin n → E) (hv : LinearIndependent ℝ v) | |
| (m : ℕ) : | |
| (Measure.pi (fun _ : Fin m => stdGaussian E)).map | |
| (fun A => fun j i => ⟪v i, A j⟫) ≤ | |
| ENNReal.ofReal ((∏ i, ‖gramSchmidt ℝ v i‖)⁻¹ ^ m) • | |
| (volume : Measure (Fin m → Fin n → ℝ)) := by | |
| rw [Measure.pi_map_pi (fun _ => (by fun_prop : Measurable | |
| (fun x : E => fun i => ⟪v i, x⟫)).aemeasurable)] | |
| have h := measure_pi_mono (fun _ : Fin m => gaussian_pairings_le v hv) | |
| rw [measure_pi_smul _ _ ENNReal.ofReal_ne_top] at h | |
| rw [ENNReal.ofReal_pow (by positivity)] | |
| simpa only [Fintype.card_fin, volume_pi] using h | |
| end GaussianDomination | |
| end PosteriorRegression | |
| end | |
| end OAI | |
Xet Storage Details
- Size:
- 6.69 kB
- Xet hash:
- a405c83fa4c5eadbf7373293db92315216a230860e1d5faacc8db1313b40c873
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.