theoremwordWeight_square_sum (S : System α) (f : α →ℝ)
(hf : ∑ a, S.weight a*f a=0) (n : ℕ) :
(∑w : Fin n → α, S.wordWeight w*(∑ j, f (w j))^2)=
(n : ℝ)*∑ a, S.weight a*(f a)^2:=by
proof · 31
lines
classical
induction n with
| zero => simp
| succ n ih =>have hmean :=S.wordWeight_expect_sum f n
rw [hf,mul_zero] at hmean
rw [sum_words_cons]
simp only [wordWeight_cons,Fin.sum_univ_succ,Fin.cons_zero,Fin.cons_succ,add_sq]
simp_rw [mul_add]
haveha : (∑ a, ∑w : Fin n → α, S.weight a*S.wordWeight w*(f a)^2)=
∑ a, S.weight a*(f a)^2:=by
apply Finset.sum_congr rfl
intro a _
simp_rw [mul_right_comm (S.weight a)]
rw [←Finset.mul_sum,S.wordWeight_sum,mul_one]
havehb : (∑ a, ∑w : Fin n → α,
S.weight a*S.wordWeight w*(2*f a*∑ j, f (w j)))=0:=by
apply Finset.sum_eq_zero
intro a _
have he (w : Fin n → α) :
S.weight a*S.wordWeight w*(2*f a*∑ j, f (w j))=
(2*S.weight a*f a)*(S.wordWeight w*∑ j, f (w j)) :=by ring
simp only [he,←Finset.mul_sum,hmean,mul_zero]
havehc : (∑ a, ∑w : Fin n → α,
S.weight a*S.wordWeight w*(∑ j, f (w j))^2)=
(n : ℝ)*∑ a, S.weight a*(f a)^2:=by
simp only [mul_assoc,←Finset.mul_sum,ih,←Finset.sum_mul,S.weight_sum,one_mul]
simp_rw [Finset.sum_add_distrib]
rw [ha,hb,hc]
push_cast
ring
theoremwordDepth_centered_square (S : System α) (n : ℕ) :
(∑w : Fin n → α, S.wordWeight w*(S.wordDepth w-n*S.lyapunov)^2)=
(n : ℝ)*S.depthVariance :=by
proof · 6
lines
havehf : ∑ a, S.weight a*(S.letterDepth a-S.lyapunov)=0:=by
simp only [mul_sub,Finset.sum_sub_distrib,←Finset.sum_mul,S.weight_sum,one_mul,S.letterDepth_mean,sub_self]
have he (w : Fin n → α) : (∑ j, (S.letterDepth (w j)-S.lyapunov))=
S.wordDepth w-n*S.lyapunov :=by
simp only [Finset.sum_sub_distrib,Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul,S.wordDepth_sum]
simpa only [he,depthVariance] usingS.wordWeight_square_sum (fun a =>S.letterDepth a-S.lyapunov) hf n