equal
deleted
inserted
replaced
1783 fixes A :: "'a set" and f :: "'a \<Rightarrow> 'b pmf" |
1783 fixes A :: "'a set" and f :: "'a \<Rightarrow> 'b pmf" |
1784 and h :: "'b \<Rightarrow> 'c::{banach, second_countable_topology}" |
1784 and h :: "'b \<Rightarrow> 'c::{banach, second_countable_topology}" |
1785 assumes "A \<noteq> {}" "finite A" "\<And>x. x \<in> A \<Longrightarrow> finite (set_pmf (f x))" |
1785 assumes "A \<noteq> {}" "finite A" "\<And>x. x \<in> A \<Longrightarrow> finite (set_pmf (f x))" |
1786 shows "measure_pmf.expectation (pmf_of_set A \<bind> f) h = |
1786 shows "measure_pmf.expectation (pmf_of_set A \<bind> f) h = |
1787 (\<Sum>a\<in>A. measure_pmf.expectation (f a) h /\<^sub>R real (card A))" |
1787 (\<Sum>a\<in>A. measure_pmf.expectation (f a) h /\<^sub>R real (card A))" |
1788 using assms by (subst pmf_expectation_bind[of A]) (auto simp: divide_simps) |
1788 using assms by (subst pmf_expectation_bind[of A]) (auto simp: field_split_simps) |
1789 |
1789 |
1790 lemma map_pmf_of_set: |
1790 lemma map_pmf_of_set: |
1791 assumes "finite A" "A \<noteq> {}" |
1791 assumes "finite A" "A \<noteq> {}" |
1792 shows "map_pmf f (pmf_of_set A) = pmf_of_multiset (image_mset f (mset_set A))" |
1792 shows "map_pmf f (pmf_of_set A) = pmf_of_multiset (image_mset f (mset_set A))" |
1793 (is "?lhs = ?rhs") |
1793 (is "?lhs = ?rhs") |
1993 fix k |
1993 fix k |
1994 have A: "indicator {Suc a} (Suc b) = indicator {a} b" for a b |
1994 have A: "indicator {Suc a} (Suc b) = indicator {a} b" for a b |
1995 by (simp add: indicator_def) |
1995 by (simp add: indicator_def) |
1996 show "pmf (binomial_pmf (Suc n) p) k = pmf ?rhs k" |
1996 show "pmf (binomial_pmf (Suc n) p) k = pmf ?rhs k" |
1997 by (cases k; cases "k > n") |
1997 by (cases k; cases "k > n") |
1998 (insert assms, auto simp: pmf_bind measure_pmf_single A divide_simps algebra_simps |
1998 (insert assms, auto simp: pmf_bind measure_pmf_single A field_split_simps algebra_simps |
1999 not_less less_eq_Suc_le [symmetric] power_diff') |
1999 not_less less_eq_Suc_le [symmetric] power_diff') |
2000 qed |
2000 qed |
2001 |
2001 |
2002 lemma binomial_pmf_0: "p \<in> {0..1} \<Longrightarrow> binomial_pmf 0 p = return_pmf 0" |
2002 lemma binomial_pmf_0: "p \<in> {0..1} \<Longrightarrow> binomial_pmf 0 p = return_pmf 0" |
2003 by (rule pmf_eqI) (simp_all add: indicator_def) |
2003 by (rule pmf_eqI) (simp_all add: indicator_def) |