Download data/lean/OAI/Probability/SKGap/Localization/ConditionalEmpiricalLaw.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 5.41 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/SKGap/Localization/ConditionalEmpiricalLaw.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/SKGap/Localization/ConditionalEmpiricalLaw.lean
-
curl -L -o ConditionalEmpiricalLaw.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/SKGap/Localization/ConditionalEmpiricalLaw.lean
5.41 kB
| import Mathlib | |
| import OAI.Probability.SKGap.Posterior.GOEPointwisePosterior | |
| import OAI.Probability.SKGap.Posterior.ConditionalObservationData | |
| import OAI.Probability.SKGap.Stability.ConditionalMeanScalar | |
| namespace OAI | |
| section | |
| noncomputable section | |
| namespace SKGap | |
| open Matrix Real Set MeasureTheory ProbabilityTheory | |
| open scoped BigOperators Matrix.Norms.Frobenius | |
| def empiricalObservation {n : β} [NeZero n] (j t Ο : β) (y : Fin n β β) : Fin n β β := | |
| fun i=>y i-scalarD j (empiricalLaw y,t,Ο)+j*scalarBMoment (empiricalLaw y)*tanh (y i) | |
| def empiricalConditionalGoe {n : β} [NeZero n] (j t Ο : β) (y : Fin n β β) | |
| (g : MatrixCoordinates (Fin n) β β) : Matrix (Fin n) (Fin n) β := | |
| let p : ScalarPoint := (empiricalLaw y,t,Ο) | |
| let q := scalarQMoment p.1 | |
| let s := scalarS j p | |
| conditionalBlockMatrix (j/(n:β)) j q s (s+j*q) (scalarA j p) | |
| (j*scalarBMoment p.1) (conditionalKappa j p) (conditionalEll j p) | |
| (empiricalUnit y q).ofLp (sqrt s β’ (empiricalGramColumns y (scalarD j p) s 2).ofLp) g | |
| lemma empirical_observation_covariance {n : β} [NeZero n] (j t Ο : β) (y : Fin n β β) | |
| (hq : 0 β€ scalarQMoment (empiricalLaw y)) : | |
| (j/(n:β))*sqrt ((n:β)*scalarQMoment (empiricalLaw y))^2+(t+Ο^2)= | |
| scalarS j (empiricalLaw y,t,Ο) β§ | |
| (t+Ο^2)+2*(j/(n:β))*sqrt ((n:β)*scalarQMoment (empiricalLaw y))^2= | |
| scalarS j (empiricalLaw y,t,Ο)+j*scalarQMoment (empiricalLaw y) := by | |
| have hn : (n:β) β 0 := by exact_mod_cast NeZero.ne n | |
| rw [sq_sqrt (mul_nonneg (Nat.cast_nonneg n) hq)] | |
| dsimp [scalarS] | |
| constructor <;> field_simp <;> ring | |
| lemma empirical_conditional_mean {n : β} [NeZero n] {j t Ο : β} | |
| (hj : 0 β€ j) (ht : 0 < t) (y : Fin n β β) | |
| (hq : 0 < scalarQMoment (empiricalLaw y)) : | |
| let p : ScalarPoint := (empiricalLaw y,t,Ο) | |
| let q := scalarQMoment p.1 | |
| let s := scalarS j p | |
| let u := (empiricalUnit y q).ofLp | |
| let Z := sqrt s β’ (empiricalGramColumns y (scalarD j p) s 2).ofLp | |
| (fun i k=>(goeRegressionCoefficient (j/(n:β)) (t+Ο^2) (fun l=>tanh (y l))*α΅₯ | |
| empiricalObservation j t Ο y) (i,k))= | |
| vecMulVec u ((j*sqrt (q/s)) β’ Z-(j*scalarA j p/s) β’ u)+ | |
| vecMulVec ((j*sqrt (q/s)) β’ Z-(j*scalarA j p/s) β’ u) u+ | |
| (2*j*(scalarA j p+j*scalarBMoment p.1*q)/(s+j*q)) β’ vecMulVec u u := by | |
| dsimp only | |
| let p : ScalarPoint := (empiricalLaw y,t,Ο) | |
| let q := scalarQMoment p.1 | |
| let s := scalarS j p | |
| let B := j*scalarBMoment p.1 | |
| let c := sqrt ((n:β)*q) | |
| let u := (empiricalUnit y q).ofLp | |
| let Z := sqrt s β’ (empiricalGramColumns y (scalarD j p) s 2).ofLp | |
| have hn : 0 < (n:β) := by exact_mod_cast NeZero.pos n | |
| have hv : 0 < t+Ο^2 := add_pos_of_pos_of_nonneg ht (sq_nonneg _) | |
| have hs : 0 < s := add_pos_of_pos_of_nonneg hv (mul_nonneg hj hq.le) | |
| have hu : uβ¬α΅₯u=1 := empiricalUnit_unit y hq | |
| have hscale : c β’ u=(fun i=>tanh (y i)) := empirical_unit_scale y hq | |
| have hc := empirical_observation_covariance j t Ο y hq.le | |
| have hdot : uβ¬α΅₯empiricalObservation j t Ο y=(n:β)*(scalarA j p+B*q)/c := | |
| empirical_unit_observation_dot j t Ο B y hq | |
| have hmean := goeRegressionCoefficient_block_mean (c := c) (div_nonneg hj hn.le) hv hu | |
| (empiricalObservation j t Ο y) | |
| rw [hscale] at hmean | |
| rw [hc.1,hc.2,hdot] at hmean | |
| have hperp : ((j/(n:β))*c/s) β’ (empiricalObservation j t Ο y- | |
| ((n:β)*(scalarA j p+B*q)/c) β’ u)= | |
| (j*sqrt (q/s)) β’ Z-(j*scalarA j p/s) β’ u := by | |
| ext i | |
| have hzi := congrFun (empirical_Z_formula y (scalarD j p) hs) i | |
| change Z i=(y i-scalarD j p)/(sqrt (n:β)*sqrt s) at hzi | |
| have hmi := congrFun hscale i | |
| change c*u i=tanh (y i) at hmi | |
| change (j/(n:β)*c/s)*(y i-scalarD j p+B*tanh (y i)- | |
| ((n:β)*(scalarA j p+B*q)/c)*u i)= | |
| j*sqrt (q/s)*Z i-j*scalarA j p/s*u i | |
| rw [β hmi,hzi] | |
| convert conditional_perp_mean_scalar hn hq hs j (scalarA j p) B | |
| (y i-scalarD j p) (u i) using 1 | |
| ring | |
| rw [hperp] at hmean | |
| have hparallel := conditional_parallel_mean_scalar (S := s+j*q) hn hq j (scalarA j p) B | |
| rw [hparallel] at hmean | |
| exact hmean | |
| theorem empirical_conditional_law {n : β} [NeZero n] {j t Ο : β} | |
| (hj : 0 β€ j) (ht : 0 < t) (y : Fin n β β) | |
| (hq : 0 < scalarQMoment (empiricalLaw y)) : | |
| conditionalGoeLaw (j/(n:β)) (t+Ο^2) (fun i=>tanh (y i)) (empiricalObservation j t Ο y)= | |
| (gaussianCoordinates (MatrixCoordinates (Fin n))).map | |
| (fun g p=>empiricalConditionalGoe j t Ο y g p.1 p.2) := by | |
| let q := scalarQMoment (empiricalLaw y) | |
| have hn : 0 < (n:β) := by exact_mod_cast NeZero.pos n | |
| have hv : 0 < t+Ο^2 := add_pos_of_pos_of_nonneg ht (sq_nonneg _) | |
| have hh := conditionalGoeLaw_block (c := sqrt ((n:β)*q)) (div_nonneg hj hn.le) hv | |
| (empiricalUnit_unit y hq) (empiricalObservation j t Ο y) | |
| rw [empirical_unit_scale y hq] at hh | |
| rw [(empirical_observation_covariance j t Ο y hq.le).1, | |
| (empirical_observation_covariance j t Ο y hq.le).2] at hh | |
| rw [hh] | |
| congr 1 | |
| funext g p | |
| have hmean := congrArg (fun M : Matrix (Fin n) (Fin n) β=>M p.1 p.2) | |
| (empirical_conditional_mean (Ο := Ο) hj ht y hq) | |
| change _+_=empiricalConditionalGoe j t Ο y g p.1 p.2 | |
| dsimp only [empiricalConditionalGoe,conditionalBlockMatrix] | |
| dsimp only at hmean | |
| rw [hmean] | |
| simp only [Matrix.add_apply,conditionalKappa,conditionalEll] | |
| ring | |
| end SKGap | |
| end | |
| end | |
| end OAI | |