Total probability law

Foundations of Probability in Python

Alexander A. Ramírez M.

CEO @ Synergy Vision

Deck of cards example

Deck of cards

Foundations of Probability in Python

Deck of cards example (Cont.)

Face cards from a Deck of cards

$$P(Face\ card)=?$$

Foundations of Probability in Python

Deck of cards example (Cont.)

Face and Club cards from a Deck of cards

$$P(Face\ card)=\color{red}{P(Club\ and\ Face\ card)}+...$$

Foundations of Probability in Python

Deck of cards example (Cont.)

Face and Spade cards from a Deck of cards

$$P(Face\ card)=P(Club\ and\ Face\ card)+\color{red}{P(Spade\ and\ Face\ card)}+...$$

Foundations of Probability in Python

Deck of cards example (Cont.)

Face and Heart cards from a Deck of cards

$$P(Face\ card)=P(Club\ and\ Face\ card)+P(Spade\ and\ Face\ card)+$$ $$\color{red}{P(Heart\ and\ Face\ card)}+...$$

Foundations of Probability in Python

Deck of cards example (Cont.)

Face and Diamond cards from a Deck of cards

$$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)}$$

Foundations of Probability in Python

Face card example in Python

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
Foundations of Probability in Python

Total probability

Parts set venn diagram

Foundations of Probability in Python

Total probability (Cont.)

Parts and damaged parts sets in a venn diagram

Foundations of Probability in Python

Total probability (Cont.)

Parts partitioned by vendor and damaged parts in a venn diagram

$$P(D)=?$$

Foundations of Probability in Python

Total probability (Cont.)

Damaged parts from vendor 1 in a venn diagram

$$P(D)=\color{red}{P(V1\ and\ D)}+...$$

Foundations of Probability in Python

Total probability (Cont.)

Damaged parts from vendor 2 in a venn diagram

$$P(D)=P(V1\ and\ D)+\color{red}{P(V2\ and\ D)}+...$$

Foundations of Probability in Python

Total probability (Cont.)

Damaged parts from vendor 3 in a venn diagram

$$P(D)=P(V1\ and\ D)+P(V2\ and\ D)+\color{red}{P(V3\ and\ D)}$$

Foundations of Probability in Python

Total probability (Cont.)

Damaged parts from all vendors in a venn diagram

$$P(D)=P(V1)P(D|V1)+P(V2)P(D|V2)+P(V3)P(D|V3)$$

Foundations of Probability in Python

Damaged parts example in Python

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.

  • What is the probability of a part being damaged?
Foundations of Probability in Python

Damaged parts example in Python (Cont.)

  • What is the probability of a part being damaged?
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
Foundations of Probability in Python

Damaged parts example in Python (Cont.)

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

Let's start using the total probability law

Foundations of Probability in Python

Preparing Video For Download...