P ( A ∣ B ) = P ( A B ) P ( B ) P(A|B)=\frac{P(AB)}{P(B)} P(A∣B)=P(B)P(AB)
P ( B ∣ A ) = P ( A B ) P ( A ) P(B|A)=\frac{P(AB)}{P(A)} P(B∣A)=P(A)P(AB)
P ( A B ) = P ( B ) ∗ P ( A ∣ B ) = P ( A ) ∗ P ( B ∣ A ) P(AB)=P(B)*P(A|B)=P(A)*P(B|A) P(AB)=P(B)∗P(A∣B)=P(A)∗P(B∣A)
同理多变量也满足该公式
P ( A B C ) = P ( B C ) ∗ P ( A ∣ B C ) = P ( C ) ∗ P ( B ∣ C ) ∗ P ( A ∣ B C ) P(ABC)=P(BC)*P(A|BC)=P(C)*P(B|C)*P(A|BC) P(ABC)=P(BC)∗P(A∣BC)=P(C)∗P(B∣C)∗P(A∣BC)
多层迭代
P ( A B 1 B 2 . . . B n ) = P ( B n ) ∗ P ( B n − 1 ∣ B n ) ∗ P ( B n − 2 ∣ B n B n − 1 ) . . . P ( A ∣ B n B n − 1 . . . B 1 ) P(AB_1B_2...B_n)=P(B_n)*P(B_{n-1}|B_n)*P(B_{n-2}|B_nB_{n-1})...P(A|B_n B_{n-1}...B_1) P(AB1B2...Bn)=P(Bn)∗P(Bn−1∣Bn)∗P(Bn−2∣BnBn−1)...P(A∣BnBn−1...B1)
P ( A B 1 B 2 . . . B n ) = P ( A ) ∗ P ( B 1 ∣ A ) ∗ P ( B 2 ∣ A B 1 ) . . . ∗ P ( B n ∣ A 1 B 1 B 2 . . B n − 1 ) P(AB_1B_2...B_n)=P(A)*P(B_1|A)*P(B_2|AB_1)...*P(B_n|A_1B_1B_2..B_{n-1}) P(AB1B2...Bn)=P(A)∗P(B1∣A)∗P(B2∣AB1)...∗P(Bn∣A1B1B2..Bn−1)
假设 A 1 , A 2 . . . A n A_1,A_2...A_n A1,A2...An为完备事件组, U i = 1 n A i = S U_{i=1}^{n}A_i=S Ui=1nAi=S(S为全集), A i A j = ∅ AiAj=\empty AiAj=∅(即i与j事件不会同时发生), P i > 0 P_i>0 Pi>0(任意事件发生的概率大于0), B ⊆ S B\subseteq S B⊆S,求 P ( A i ∣ B ) P(A_i|B) P(Ai∣B)的概率:
P ( A i ∣ B ) = P ( A i B ) P ( B ) P(A_i|B)=\displaystyle\frac{P(A_iB)}{P(B)} P(Ai∣B)=P(B)P(AiB)
由于 P ( A i B ) = P ( A i ) ∗ P ( B ∣ A i ) P(A_iB)=P(A_i)*P(B|A_i) P(AiB)=P(Ai)∗P(B∣Ai)
P ( B ) = ∑ P ( B A i ) = ∑ P ( A i ) ∗ P ( B ∣ A i ) P(B)=\sum P(BA_i)=\sum P(A_i)*P(B|A_i) P(B)=∑P(BAi)=∑P(Ai)∗P(B∣Ai)
故:
P ( A i ∣ B ) = P ( A i ) ∗ P ( B ∣ A i ) ∑ P ( A i ) ∗ P ( B ∣ A i ) P(A_i|B)=\displaystyle\frac{P(A_i)*P(B|A_i)}{\sum P(A_i)*P(B|A_i)} P(Ai∣B)=∑P(Ai)∗P(B∣Ai)P(Ai)∗P(B∣Ai)
某工厂有四条流水线生产同一产品,四条流水线的产量分别占总产量的15%,20%,30%,35%,又知这四条流水线的不合格品率依次为0.05,0.04,0.03,0.02。现从出厂产品中任取一件,求恰好取到不合格品的概率。
设抽到某条流水线事件为Ai,则:
P ( A 1 ) = 0.15 , P ( A 2 ) = 0.2 , P ( A 3 ) = 0.3 , P ( A 4 ) = 0.35 P(A_1)=0.15, P(A_2)=0.2, P(A_3)=0.3, P(A_4)=0.35 P(A1)=0.15,P(A2)=0.2,P(A3)=0.3,P(A4)=0.35
抽到不合格品的概率为B,且该合格品属于Ai的概率为 P ( B ∣ A i ) P(B|A_i) P(B∣Ai),则:
P ( B ∣ A 1 ) = 0.05 , P ( B ∣ A 2 ) = 0.04 , P ( B ∣ A 3 ) = 0.03 , P ( B ∣ A 4 ) = 0.02 P(B|A_1)=0.05, P(B|A_2)=0.04,P(B|A_3)=0.03, P(B|A_4)=0.02 P(B∣A1)=0.05,P(B∣A2)=0.04,P(B∣A3)=0.03,P(B∣A4)=0.02
求P(B)
P ( B ) = ∑ P ( A i B ) = ∑ P ( A i ) ∗ P ( B ∣ A i ) = 0.15 ∗ 0.05 + 0.2 ∗ 0.04 + 0.3 ∗ 0.03 + 0.35 ∗ 0.02 = 0.0315 P(B)=\sum P(A_iB)=\sum P(A_i)*P(B|A_i)=0.15*0.05+0.2*0.04+0.3*0.03+0.35*0.02=0.0315 P(B)=∑P(AiB)=∑P(Ai)∗P(B∣Ai)=0.15∗0.05+0.2∗0.04+0.3∗0.03+0.35∗0.02=0.0315
两个一摸一样的碗,1号碗里30个巧克力和10个水果糖,2号碗里20个巧克力和20个水果糖。然后把碗盖住,随机选择一个碗,从里面摸出一个巧克力。
问题:这颗巧克力来自1号碗的概率是多少?
解:设1号碗摸出巧克力的事件为事件A,P(A)=3/4,设2号碗摸出巧克力的概率为事件B,P(B)=1/2
摸中1号碗与2号碗的概率均为1/2。
设摸到巧克力的事件定义为C,P©= 1 2 ∗ 3 4 + 1 2 ∗ 1 2 = 5 8 \displaystyle\frac{1}{2}*\frac{3}{4}+\frac{1}{2}*\frac{1}{2}=\frac{5}{8} 21∗43+21∗21=85
摸到巧克力,且来自1号碗,该概率为:
P(B|C) = ( 1 2 ∗ 3 4 ) / ( 5 8 ) \displaystyle(\frac{1}{2}*\frac{3}{4})/(\frac{5}{8}) (21∗43)/(85)= 3 5 \displaystyle\frac{3}{5} 53
解法2:
设从i号碗摸的事件为Ai,,显然:
P ( A 1 ) = P ( A 2 ) = 1 2 P(A_1)=P(A_2)=\displaystyle\frac{1}{2} P(A1)=P(A2)=21
设摸出巧克力的事件为B,显然:
P ( B ∣ A 1 ) = 3 4 , P ( B ∣ A 2 ) = 1 2 P(B|A_1)=\displaystyle\frac{3}{4}, P(B|A_2)=\displaystyle\frac{1}{2} P(B∣A1)=43,P(B∣A2)=21
根据全概率公式,求P(B),
P ( B ) = ∑ P ( B ∣ A i ) ∗ P ( A i ) = 1 2 ∗ 3 4 + 1 2 ∗ 1 2 = 5 8 P(B)=\sum P(B|A_i)*P(A_i)=\displaystyle\frac{1}{2}*\frac{3}{4}+\frac{1}{2}*\frac{1}{2}=\frac{5}{8} P(B)=∑P(B∣Ai)∗P(Ai)=21∗43+21∗21=85
根据贝叶斯公式,求P(A1|B)
P ( A 1 ∣ B ) = P ( B ∣ A 1 ) ∗ P ( A 1 ) P ( A 1 ) = ( 1 2 ∗ 3 4 ) / ( 5 8 ) = 5 8 P(A_1|B)=\displaystyle\frac{P(B|A_1)*P(A_1)}{P(A1)}=\displaystyle(\frac{1}{2}*\frac{3}{4})/(\frac{5}{8})=\frac{5}{8} P(A1∣B)=P(A1)P(B∣A1)∗P(A1)=(21∗43)/(85)=85