Foundations of Probability in Python
Alexander A. Ramírez M.
CEO @ Synergy Vision
$$P(Face\ card)=?$$
$$P(Face\ card)=\color{red}{P(Club\ and\ Face\ card)}+...$$
$$P(Face\ card)=P(Club\ and\ Face\ card)+\color{red}{P(Spade\ and\ Face\ card)}+...$$
$$P(Face\ card)=P(Club\ and\ Face\ card)+P(Spade\ and\ Face\ card)+$$ $$\color{red}{P(Heart\ and\ Face\ card)}+...$$
$$P(Face\ card)=P(Club\ and\ Face\ card)+P(Spade\ and\ Face\ card)+$$ $$P(Heart\ and\ Face\ card)+\color{red}{P(Diamond\ and\ Face\ card)}$$
Total probability calculation, FC is Face card in the code
P_Club_n_FC = 3/52
P_Spade_n_FC = 3/52
P_Heart_n_FC = 3/52
P_Diamond_n_FC = 3/52
P_Face_card = P_Club_n_FC + P_Spade_n_FC + P_Heart_n_FC + P_Diamond_n_FC
print(P_Face_card)
The probability of a face card is:
0.230769230769
$$P(D)=?$$
$$P(D)=\color{red}{P(V1\ and\ D)}+...$$
$$P(D)=P(V1\ and\ D)+\color{red}{P(V2\ and\ D)}+...$$
$$P(D)=P(V1\ and\ D)+P(V2\ and\ D)+\color{red}{P(V3\ and\ D)}$$
$$P(D)=P(V1)P(D|V1)+P(V2)P(D|V2)+P(V3)P(D|V3)$$
A certain electronic part is manufactured by three different vendors, V1, V2, and V3.
Half of the parts are produced by V1, and V2 and V3 each produce 25%. The probability of a part being damaged given that it was produced by V1 is 1%, while it's 2% for V2 and 3% for V3.
P_V1 = 0.5
P_V2 = 0.25
P_V3 = 0.25
P_D_g_V1 = 0.01
P_D_g_V2 = 0.02
P_D_g_V3 = 0.03
We apply the total probability formula
P_Damaged = P_V1 * P_D_g_V1 + P_V2 * P_D_g_V2 + P_V3 * P_D_g_V3
print(P_Damaged)
The probability of being damaged is:
0.0175
Foundations of Probability in Python