貝士定理(1)
Author: 藍邦偉老師

$ 貝氏定理 $ 

$ P(B)= P(S∩B)$
$\;\;\;\;\;\;\;\;\;=P((A∪A')∩B)$
$\;\;\;\;\;\;\;\;\;=P(A∩B)+P(A'∩B)$
$\;\;\;\;\;\;\;\;\;=P(A)\cdot P(B|A)+P(A')\cdot P(B|A')$

A_1 = (3, -2)
A_2: A_1 + (12, 0)
A_4: A_1 + (0, 8)
A_3: A_2 + A_4 - A_1
a = PolyLine(A_1, A_2, A_3, A_4, A_1)
B = Point(a)
F: (x(B), y(A_4))
P1, a_1, e, f, d = Polygon(A_1, B, F, A_4)
P2, b, e_1, f_1, c = Polygon(A_2, B, F, A_3)
C_3 = PointIn(P2)
C_1 = PointIn(P1)
C_2: (x(C_3), y(C_1))
C_4: (x(C_1), y(C_3))
R: (x(B), y(C_1))
S: (x(B), y(C_4))
P3, k, g, r, s = Polygon(C_4, C_1, R, S)
P4, s_1, r_1, j, h = Polygon(S, R, C_2, C_3)
t_A: "$ P(A)=" + (LaTeX[FractionText[P1 / (P1 + P2)]]) + " $"
t_{A'}: "$P(A')=" + (LaTeX[FractionText[P2 / (P1 + P2)]]) + "$"
t_B: "$ P(B)=" + (LaTeX[FractionText[(P3 + P4) / (P1 + P2)]]) + " $"
t_{A_int_B}: "$ P(A∩B)=" + (LaTeX[FractionText[P3 / (P1 + P2)]]) + " $"
t_{A'_int_B}: "$ P(A'∩B)=" + (LaTeX[FractionText[P4 / (P1 + P2)]]) + " $"
PP1 = 0
t_{B|A}: "$ P(B|A)=\frac{P(B∩A)}{P(A)}=\frac{" + (LaTeX[FractionText[P3 / (P1 + P2)]]) + "}{" + (LaTeX[FractionText[P1 / (P1 + P2)]]) + "}=" + (LaTeX[FractionText[P3 / P1]]) + " $"
PP2 = 0
t_{B|A'}: "$ P(B|A')=\frac{P(B∩A')}{P(A')}=\frac{" + (LaTeX[FractionText[P4 / (P1 + P2)]]) + "}{" + (LaTeX[FractionText[P2 / (P1 + P2)]]) + "}=" + (LaTeX[FractionText[P4 / P2]]) + " $"
t_{conclusio}: "$ P(A)\cdot P(B|A)+P(A')\cdot P(B|A') =" + (LaTeX[FractionText[P1 / (P1 + P2)]]) + "\cdot" + (LaTeX[FractionText[P3 / P1]]) + "+\;" + (LaTeX[FractionText[P2 / (P1 + P2)]]) + "\;\cdot " + (LaTeX[FractionText[P4 / P2]]) + "=" + (LaTeX[FractionText[(P3 + P4) / (P1 + P2)]]) + "$"