File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -479,19 +479,18 @@ section Expectation
479479
480480variable {n : ℕ} {P : Findist n}
481481variable {k : ℕ} {X : FinRV n ℚ} {B : FinRV n Bool} {L : FinRV n (Fin k)}
482- variable (g : Fin k → ℚ)
482+ variable (g : Fin k → ℚ)
483483
484484/-- LOTUS: The law of the unconscious statistician (or similar) -/
485485theorem LOTUS : 𝔼[g ∘ L // P ] = ∑ i, ℙ[L =ᵣ i // P] * (g i) :=
486486 by rewrite [exp_decompose (X := g ∘ L) (L := L) ]
487487 apply Fintype.sum_congr
488488 intro i
489- rewrite [←indi_eq_indr]
490- rewrite [←exp_cond_eq_def (X := g ∘ L) ]
489+ rewrite [←indi_eq_indr, ←exp_cond_eq_def (X := g ∘ L) ]
491490 by_cases! h : ℙ[L =ᵣ i // P] = 0
492491 · rw [h]; simp
493492 · rw [exp_cond_const i h ]
494- ring
493+ ring
495494
496495theorem law_total_exp : 𝔼[𝔼[X |ᵣ L // P] // P] = 𝔼[X // P] :=
497496 let g i := 𝔼[X | L =ᵣ i // P]
@@ -502,6 +501,12 @@ theorem law_total_exp : 𝔼[𝔼[X |ᵣ L // P] // P] = 𝔼[X // P] :=
502501 _ = ∑ i : Fin k, 𝔼[X * (L =ᵢ i) // P] := by apply Fintype.sum_congr; intro i; apply exp_congr; rw[indi_eq_indr]
503502 _ = 𝔼[X // P] := by rw [←exp_decompose]
504503
504+
505+ /-- Shows that our definition of expectation is correct -/
506+ theorem expect_def_correct : 𝔼[ X // P] = ∑ y ∈ (Finset.univ.image X), (ℙ[ X =ᵣ y // P] * y) := by
507+ -- TODO: Can we use FinEnum and Quotient to reduce it to LOTUS
508+ sorry
509+
505510end Expectation
506511
507512section Probability
Original file line number Diff line number Diff line change @@ -408,8 +408,7 @@ variable {k : ℕ} {g : Fin k → ℚ} {L : FinRV n (Fin k)}
408408
409409theorem exp_decompose : 𝔼[X // P] = ∑ i, 𝔼[X * (L =ᵢ i) // P] :=
410410 by nth_rewrite 1 [rv_decompose X L]
411- rewrite [exp_additive]
412- simp
411+ rw [exp_additive]
413412
414413/-- Expectation of a conditional constant. Only when probability is positive. -/
415414theorem exp_cond_const : ∀ i, ℙ[L =ᵣ i // P] ≠ 0 → 𝔼[g ∘ L | L =ᵣ i // P] = g i :=
You can’t perform that action at this time.
0 commit comments