@@ -5552,6 +5552,127 @@ Proof
55525552 >> simp [Abbr ‘g’]
55535553QED
55545554
5555+
5556+ (* ------------------------------------------------------------------------- *)
5557+ (* Moment generating function *)
5558+ (* ------------------------------------------------------------------------- *)
5559+
5560+ Definition mgf_def :
5561+ mgf p X s = expectation p (\x. exp (Normal s * X x))
5562+ End
5563+
5564+ Theorem mgf_0 :
5565+ !p X. prob_space p ==> mgf p X 0 = 1
5566+ Proof
5567+ RW_TAC std_ss [mgf_def, mul_lzero, exp_0, normal_0]
5568+ >> MATCH_MP_TAC expectation_const >> art[]
5569+ QED
5570+
5571+ Theorem mgf_linear :
5572+ ∀p X a b s. prob_space p ∧ real_random_variable X p ∧
5573+ integrable p (λx. exp (Normal (a * s) * X x)) ⇒
5574+ mgf p (λx.( Normal a * X x) + Normal b) s =
5575+ (exp (Normal s * Normal b)) * mgf p X (a * s)
5576+ Proof
5577+ rw [mgf_def, real_random_variable_def]
5578+ >> Know ‘ expectation p (λx. exp (Normal s * ((Normal a * X x) + Normal b)))
5579+ = expectation p (λx. exp ((Normal s * (Normal a * X x)) + Normal s * Normal b))’
5580+ >- (MATCH_MP_TAC expectation_cong >> rw[] >> AP_TERM_TAC
5581+ >> ‘∃c. X x = Normal c’ by METIS_TAC [extreal_cases] >> rw[]
5582+ >> ‘∃d. Normal a * Normal c = Normal d’ by METIS_TAC [extreal_mul_eq]
5583+ >> rw[add_ldistrib_normal2]) >> Rewr'
5584+ >> Know ‘expectation p
5585+ (λx. exp (Normal s * (Normal a * X x) + Normal s * Normal b)) =
5586+ expectation p (λx. (exp (Normal s * (Normal a * X x))) * exp (Normal s * Normal b))’
5587+ >- (MATCH_MP_TAC expectation_cong
5588+ >> rw[exp_add]
5589+ >> ‘∃c. X x = Normal c’ by METIS_TAC [extreal_cases]>> rw[]
5590+ >> ‘∃d. Normal a * Normal c = Normal d’ by METIS_TAC [extreal_mul_eq] >> rw[]
5591+ >> ‘∃e. Normal s * Normal d = Normal e’ by METIS_TAC [extreal_mul_eq] >> rw[]
5592+ >> ‘∃f. Normal s * Normal b = Normal f’ by METIS_TAC [extreal_mul_eq] >> rw[exp_add])
5593+ >> Rewr'
5594+ >> ‘∃g. exp (Normal s * Normal b) = Normal g’ by METIS_TAC [extreal_mul_eq, normal_exp]
5595+ >> rw[]
5596+ >> GEN_REWRITE_TAC (RATOR_CONV o ONCE_DEPTH_CONV) empty_rewrites [mul_comm]
5597+ >> rw [mul_assoc, extreal_mul_eq]
5598+ >> HO_MATCH_MP_TAC expectation_cmul
5599+ >> ASM_REWRITE_TAC []
5600+ QED
5601+
5602+ Theorem mgf_sum :
5603+ !p X Y s . prob_space p ∧ real_random_variable X p ∧
5604+ real_random_variable Y p ∧
5605+ indep_vars p X Y Borel Borel ∧
5606+ mgf p (\x. X x + Y x) s ≠ PosInf ∧
5607+ mgf p X s ≠ PosInf ∧
5608+ mgf p Y s ≠ PosInf ==>
5609+ mgf p (\x. X x + Y x) s = mgf p X s * mgf p Y s
5610+ Proof
5611+ rw [mgf_def, real_random_variable_def]
5612+ >> Know ‘expectation p (\x. exp (Normal s * (X x + Y x))) =
5613+ expectation p (\x. exp ((Normal s * X x) + (Normal s * Y x)))’
5614+ >-(MATCH_MP_TAC expectation_cong >> rw[] >> AP_TERM_TAC
5615+ >> MATCH_MP_TAC add_ldistrib_normal >> rw[])
5616+ >> Rewr'
5617+ >> Know ‘expectation p (λx. exp (Normal s * X x + Normal s * Y x)) =
5618+ expectation p (λx. exp (Normal s * X x) * exp (Normal s * Y x))’
5619+ >- (MATCH_MP_TAC expectation_cong >> rw[] >> MATCH_MP_TAC exp_add >> DISJ2_TAC
5620+ >> ‘∃a. X x = Normal a’ by METIS_TAC [extreal_cases]
5621+ >> ‘∃b. Y x = Normal b’ by METIS_TAC [extreal_cases]
5622+ >> rw[extreal_mul_eq]) >> Rewr'
5623+ >> HO_MATCH_MP_TAC indep_vars_expectation
5624+ >> simp[]
5625+ >> CONJ_TAC
5626+ (* real_random_variable (λx. exp (Normal s * X x)) p *)
5627+ >- (MATCH_MP_TAC real_random_variable_exp_normal
5628+ >> fs[real_random_variable, random_variable_def])
5629+ >> CONJ_TAC
5630+ (* real_random_variable (λx. exp (Normal s * X x)) p *)
5631+ >- (MATCH_MP_TAC real_random_variable_exp_normal
5632+ >> fs[real_random_variable, random_variable_def])
5633+ >> CONJ_TAC
5634+ (* indep_vars p (λx. exp (Normal s * X x)) (λx. exp (Normal s * Y x)) Borel Borel *)
5635+ >- (Q.ABBREV_TAC ‘f = λx. exp (Normal s * x)’
5636+ >> simp[]
5637+ >> MATCH_MP_TAC (REWRITE_RULE [o_DEF] indep_rv_cong) >> csimp[]
5638+ >> Q.UNABBREV_TAC ‘f’
5639+ >> MATCH_MP_TAC IN_MEASURABLE_BOREL_EXP
5640+ >> simp[] >> Q.EXISTS_TAC ‘λx. Normal s * x’ >> simp[SIGMA_ALGEBRA_BOREL]
5641+ >> MATCH_MP_TAC IN_MEASURABLE_BOREL_CMUL
5642+ >> qexistsl [‘λx. x’, ‘s’]
5643+ >> simp[SIGMA_ALGEBRA_BOREL, IN_MEASURABLE_BOREL_BOREL_I])
5644+ >> Know ‘(λx. exp (Normal s * X x)) ∈ Borel_measurable (measurable_space p)’
5645+ >- (MATCH_MP_TAC IN_MEASURABLE_BOREL_EXP
5646+ >> Q.EXISTS_TAC ‘λx. Normal s * X x’
5647+ >> fs [prob_space_def, measure_space_def]
5648+ >> MATCH_MP_TAC IN_MEASURABLE_BOREL_CMUL
5649+ >> qexistsl [‘X’, ‘s’] >> simp[random_variable_def]
5650+ >> fs [random_variable_def, p_space_def, events_def])
5651+ >> DISCH_TAC
5652+ >> Know ‘(λx. exp (Normal s * Y x)) ∈ Borel_measurable (measurable_space p)’
5653+ >- (MATCH_MP_TAC IN_MEASURABLE_BOREL_EXP
5654+ >> Q.EXISTS_TAC ‘λx. Normal s * Y x’
5655+ >> fs [prob_space_def, measure_space_def]
5656+ >> MATCH_MP_TAC IN_MEASURABLE_BOREL_CMUL
5657+ >> qexistsl [‘Y’, ‘s’] >> simp[random_variable_def]
5658+ >> fs [random_variable_def, p_space_def, events_def])
5659+ >> DISCH_TAC
5660+ >> Q.ABBREV_TAC ‘f = λx. exp (Normal s * X x)’ >> simp[]
5661+ >> ‘∀x. x ∈ p_space p ⇒ 0 ≤ f x’ by METIS_TAC [exp_pos]
5662+ >> Q.ABBREV_TAC ‘g = λx. exp (Normal s * Y x)’ >> simp[]
5663+ >> ‘∀x. x ∈ p_space p ⇒ 0 ≤ g x’ by METIS_TAC [exp_pos]
5664+ >> CONJ_TAC (* integrable p f *)
5665+ >- (Suff ‘ pos_fn_integral p f <> PosInf’
5666+ >- FULL_SIMP_TAC std_ss [prob_space_def, p_space_def, integrable_pos, expectation_def]
5667+ >> ‘∫ p f = ∫⁺ p f ’ by METIS_TAC[integral_pos_fn, prob_space_def, p_space_def]
5668+ >> METIS_TAC [expectation_def]
5669+ >> simp[])
5670+ >- (Suff ‘ pos_fn_integral p g <> PosInf’
5671+ >- FULL_SIMP_TAC std_ss [prob_space_def, p_space_def, integrable_pos, expectation_def]
5672+ >> ‘∫ p g = ∫⁺ p g ’ by METIS_TAC[integral_pos_fn, prob_space_def, p_space_def]
5673+ >> METIS_TAC [expectation_def])
5674+ QED
5675+
55555676val _ = html_theory "distribution";
55565677
55575678(* References:
0 commit comments