L5 (Probability and Statistics)
L5 (Probability and Statistics)
Statistics
KFU, COLLEGE OF SCIENCES, DEP. OF MATHEMATICS AND STATISTICS, DR. REDA ALSHENAWY 1/25/2025 1
Different Probability Formulas
Probability formula with addition rule:
Whenever an event is the union of two other events, say 𝑨𝑨 and 𝑩𝑩, then
𝑷𝑷(𝑨𝑨 𝒐𝒐𝒐𝒐 𝑩𝑩) = 𝑷𝑷(𝑨𝑨) + 𝑷𝑷(𝑩𝑩) − 𝑷𝑷(𝑨𝑨 ∩ 𝑩𝑩)
𝑷𝑷(𝑨𝑨 ∪ 𝑩𝑩) = 𝑷𝑷(𝑨𝑨) + 𝑷𝑷(𝑩𝑩) − 𝑷𝑷(𝑨𝑨 ∩ 𝑩𝑩)
Probability formula with the complementary rule:
Whenever an event is the complement of another event, specifically, if A is an
event, then
𝑷𝑷(𝒏𝒏𝒐𝒐𝒏𝒏 𝑨𝑨) = 𝟏𝟏 − 𝑷𝑷(𝑨𝑨) 𝒐𝒐𝒐𝒐 𝑷𝑷(𝑨𝑨𝑨) = 𝟏𝟏 − 𝑷𝑷(𝑨𝑨).
𝑷𝑷(𝑨𝑨) + 𝑷𝑷(𝑨𝑨𝑨) = 𝟏𝟏.
KFU, COLLEGE OF SCIENCES, DEP. OF MATHEMATICS AND STATISTICS, DR. REDA ALSHENAWY 1/25/2025 2
Probability formula with multiplication rule:
Whenever an event is the intersection of two other events, that is,
events 𝐴𝐴 𝑎𝑎𝑎𝑎𝑎𝑎 𝐵𝐵 need to occur simultaneously.
Then:
𝑷𝑷(𝑨𝑨 ∩ 𝑩𝑩) = 𝑷𝑷(𝑨𝑨) ⋅ 𝑷𝑷(𝑩𝑩) (in case of independent events)
𝑷𝑷(𝑨𝑨 ∩ 𝑩𝑩) = 𝑷𝑷(𝑨𝑨) ⋅ 𝑷𝑷(𝑩𝑩 ∣ 𝑨𝑨) (in case of dependent events)
Probability formula with the conditional rule:
When event A is already known to have occurred, the probability of event B is
known as conditional probability and is given by:
𝑷𝑷(𝑩𝑩 ∣ 𝑨𝑨) = 𝑷𝑷(𝑨𝑨 ∩ 𝑩𝑩)/𝑷𝑷(𝑨𝑨)
KFU, COLLEGE OF SCIENCES, DEP. OF MATHEMATICS AND STATISTICS, DR. REDA ALSHENAWY 1/25/2025 3
KFU, COLLEGE OF SCIENCES, DEP. OF MATHEMATICS AND STATISTICS, DR. REDA ALSHENAWY 1/25/2025 4
The below figure depicts the Venn diagram representation
KFU, COLLEGE OF SCIENCES, DEP. OF MATHEMATICS AND STATISTICS, DR. REDA ALSHENAWY 1/25/2025 5
Example:
This question uses the following contingency table:
What is the probability a randomly selected person is male, given that they own a pet?
Step 1:
Repopulate the formula with new variables so that it makes sense for the question (optional, but it
helps to clarify what you’re looking for).
I’m going to say 𝑀𝑀 is for male and 𝑃𝑃𝑃𝑃 stands for pet owner, so the formula becomes:
𝑷𝑷(𝑴𝑴|𝑷𝑷𝑷𝑷) = 𝑷𝑷(𝑴𝑴 ∩ 𝑷𝑷𝑷𝑷) / 𝑷𝑷(𝑷𝑷𝑷𝑷)
KFU, COLLEGE OF SCIENCES, DEP. OF MATHEMATICS AND STATISTICS, DR. REDA ALSHENAWY 1/25/2025 6
Step 2: Figure out 𝑷𝑷(𝑴𝑴 ∩ 𝑷𝑷𝑷𝑷) from the table.
The intersection of male and pets (the intersection on the table of these two factors) is 0.41.
Step 3: Figure out 𝑷𝑷(𝑷𝑷𝑷𝑷) from the table. From the total column, 86% (0.86) of respondents had a
pet.
KFU, COLLEGE OF SCIENCES, DEP. OF MATHEMATICS AND STATISTICS, DR. REDA ALSHENAWY 1/25/2025 7
KFU, COLLEGE OF SCIENCES, DEP. OF MATHEMATICS AND STATISTICS, DR. REDA ALSHENAWY 1/25/2025 8
KFU, COLLEGE OF SCIENCES, DEP. OF MATHEMATICS AND STATISTICS, DR. REDA ALSHENAWY 1/25/2025 9
KFU, COLLEGE OF SCIENCES, DEP. OF MATHEMATICS AND STATISTICS, DR. REDA ALSHENAWY 1/25/2025 10
Example:
Two dies are thrown simultaneously, and the sum of the numbers obtained is found to be 7.
What is the probability that the number 3 has appeared at least once?
Solution:
The sample space 𝑆𝑆 would consist of all the numbers possible by the combination of two dies. Therefor 𝑆𝑆
consists of 6 × 6, i.e. 36 events. Event 𝐴𝐴 indicates the combination in which 3 has appeared at least once.
Event 𝐵𝐵 indicates the combination of the numbers which sum up to 7.
𝐴𝐴 = {(3, 1), (3, 2), (3, 3)(3, 4)(3, 5)(3, 6)(1, 3)(2, 3)(4, 3)(5, 3)(6, 3)}
𝐵𝐵 = {(1, 6)(2, 5)(3, 4)(4, 3)(5, 2)(6, 1)}
11 6 2
𝑃𝑃 𝐴𝐴 = ; 𝑃𝑃 𝐵𝐵 = ; 𝐴𝐴 ∩ 𝐵𝐵 = 2; 𝑃𝑃 𝐴𝐴 ∩ 𝐵𝐵 = ;
36 36 36
Applying the conditional probability formula we get,
𝑃𝑃(𝐴𝐴|𝐵𝐵) = 𝑃𝑃(𝐴𝐴 ∩ 𝐵𝐵)/𝑃𝑃(𝐵𝐵) = (2/36)/(6/36) = ⅓
KFU, COLLEGE OF SCIENCES, DEP. OF MATHEMATICS AND STATISTICS, DR. REDA ALSHENAWY 1/25/2025 11
Example:
In a group of 100 computer buyers, 40 bought CPU, 30 purchased monitor, and
20 purchased CPU and monitors. If a computer buyer chose at random and
bought a CPU, what is the probability they also bought a Monitor?
Solution:
As per the first event, 40 out of 100 bought CPU,
KFU, COLLEGE OF SCIENCES, DEP. OF MATHEMATICS AND STATISTICS, DR. REDA ALSHENAWY 1/25/2025 12
Now, according to the question, 20 buyers purchased both CPU and monitors. So,
this is the intersection of the happening of two events. Hence,
The probability that a buyer bought a monitor, given that they purchased a CPU, is
50%.
KFU, COLLEGE OF SCIENCES, DEP. OF MATHEMATICS AND STATISTICS, DR. REDA ALSHENAWY 1/25/2025 13
Calculate Conditional Probability in R:
In this section, we will discuss a step-by-step process to calculate
conditional probabilities in R using the 𝑝𝑝𝑜𝑜𝑜𝑜𝑝𝑝. 𝑡𝑡𝑎𝑎𝑡𝑡𝑡𝑡𝑡𝑡() 𝑓𝑓𝑓𝑓𝑎𝑎𝑓𝑓𝑡𝑡𝑓𝑓𝑜𝑜𝑎𝑎.
KFU, COLLEGE OF SCIENCES, DEP. OF MATHEMATICS AND STATISTICS, DR. REDA ALSHENAWY 1/25/2025 14
Step 2: Create a Contingency Table
A contingency table, also known as a cross-tabulation or crosstab, is a tabular method to
display the relationship between two or more categorical variables.
In R, you can create a contingency table using the 𝑡𝑡𝑎𝑎𝑡𝑡𝑡𝑡𝑡𝑡() 𝑓𝑓𝑓𝑓𝑎𝑎𝑓𝑓𝑡𝑡𝑓𝑓𝑜𝑜𝑎𝑎.
KFU, COLLEGE OF SCIENCES, DEP. OF MATHEMATICS AND STATISTICS, DR. REDA ALSHENAWY 1/25/2025 15
Step 4: Access Specific Conditional Probabilities
If you want to find a specific conditional probability, such as 𝑃𝑃(𝐵𝐵 = 𝑡𝑡𝑏 | 𝐴𝐴 = 𝑎𝑎𝑏), you can
access the corresponding cell in the conditional probability table using the appropriate
row and column names.
Example:
We will calculate the
Conditional probability of
Defective Yes 𝑔𝑔𝑓𝑓𝑔𝑔𝑡𝑡𝑎𝑎 Surface
Flaws Yes. i. e; 𝑃𝑃(𝐷𝐷|𝐹𝐹)
KFU, COLLEGE OF SCIENCES, DEP. OF MATHEMATICS AND STATISTICS, DR. REDA ALSHENAWY 1/25/2025 16
KFU, COLLEGE OF SCIENCES, DEP. OF MATHEMATICS AND STATISTICS, DR. REDA ALSHENAWY 1/25/2025 17
KFU, COLLEGE OF SCIENCES, DEP. OF MATHEMATICS AND STATISTICS, DR. REDA ALSHENAWY 1/25/2025 18
KFU, COLLEGE OF SCIENCES, DEP. OF MATHEMATICS AND STATISTICS, DR. REDA ALSHENAWY 1/25/2025 19
KFU, COLLEGE OF SCIENCES, DEP. OF MATHEMATICS AND STATISTICS, DR. REDA ALSHENAWY 1/25/2025 20
KFU, COLLEGE OF SCIENCES, DEP. OF MATHEMATICS AND STATISTICS, DR. REDA ALSHENAWY 1/25/2025 21
KFU, COLLEGE OF SCIENCES, DEP. OF MATHEMATICS AND STATISTICS, DR. REDA ALSHENAWY 1/25/2025 22
KFU, COLLEGE OF SCIENCES, DEP. OF MATHEMATICS AND STATISTICS, DR. REDA ALSHENAWY 1/25/2025 23
Answer
𝒅𝒅.
𝑃𝑃 𝐴𝐴 ∪ 𝐵𝐵 ∩ 𝐶𝐶
= 𝑃𝑃 𝐴𝐴 ∩ 𝐶𝐶 ∪ 𝐵𝐵 ∩ 𝐶𝐶
= 𝑃𝑃 ∅ ∪ ∅
= 𝑃𝑃 ∅ = 0
𝒆𝒆.
𝑃𝑃 𝐴𝐴′ ∩ 𝐵𝐵′ ∩ 𝐶𝐶 ′
= 𝑃𝑃 𝐴𝐴 ∪ 𝐵𝐵 ∪ 𝐶𝐶 ′
= 1 − 𝑃𝑃 𝐴𝐴 ∪ 𝐵𝐵 ∪ 𝐶𝐶
= 0.1
KFU, COLLEGE OF SCIENCES, DEP. OF MATHEMATICS AND STATISTICS, DR. REDA ALSHENAWY 1/25/2025 24
Answer
Find the probability that a randomly
selected lamp will yield unsatisfactory
results under any criteria.
13
a)𝑃𝑃 𝑓𝑓𝑎𝑎𝑢𝑢𝑎𝑎𝑡𝑡𝑓𝑓𝑢𝑢𝑓𝑓𝑎𝑎𝑓𝑓𝑡𝑡𝑜𝑜𝑜𝑜𝑢𝑢 = = 0.1
130
The customers for these lamps
demand 95% satisfactory results.
Can the lamp manufacturer meet this
demand?
117
b) 𝑃𝑃 𝑢𝑢𝑎𝑎𝑡𝑡𝑓𝑓𝑢𝑢𝑓𝑓𝑎𝑎𝑓𝑓𝑡𝑡𝑜𝑜𝑜𝑜𝑢𝑢 = 130
=
0.90 < 0.95,
NO, she(he) can not meet the demand
KFU, COLLEGE OF SCIENCES, DEP. OF MATHEMATICS AND STATISTICS, DR. REDA ALSHENAWY 1/25/2025 25
In addition to 2.99, 2.103
The End
Thank you
KFU, COLLEGE OF SCIENCES, DEP. OF MATHEMATICS AND STATISTICS, DR. REDA ALSHENAWY 1/25/2025 26