Warm-up — Lab 01 Assignment Solutions
Before proceeding with Chapter 3.3, we review and solve the practice problems assigned at the conclusion of Lab 01.
Problem 1 — Complementary Defect Model
Problem Statement
A production line has defective rate . For a sample of items drawn independently, compute the probability of finding at least one defective item.
Mathematical Formulation
Step 1 — Calculate probability of a non-defective item:
Step 2 — Probability that all 4 are non-defective:
Step 3 — Complement rule:
Python Code
p = 0.08
n = 4
p_none = (1 - p) ** n
p_at_least_one = 1 - p_none
print("P(At least 1 defective):", round(p_at_least_one, 5))
Expected Output
P(At least 1 defective): 0.28361
Problem 2 — Security Badge Key Permutations
Problem Statement
A security access key has 7 positions: 2 uppercase letters (A–Z, repeats allowed) followed by 5 digits (0–9, no repetition). Find the total unique keys and the probability of cracking it on the 1st attempt.
Mathematical Formulation
Step 1 — Letter combinations (repetition allowed):
Step 2 — Digit permutations without repetition ():
Step 3 — Total keys and cracking probability:
Python Code
letters = 26 * 26
digits = 10 * 9 * 8 * 7 * 6
total_keys = letters * digits
p_crack = 1 / total_keys
print("Total Keys:", total_keys)
print(f"P(Crack): {p_crack:.8e}")
Expected Output
Total Keys: 20442240
P(Crack): 4.89184566e-08
Problem 3 — Dependent 3-Card Sequence Draw
Problem Statement
From a standard shuffled 52-card deck, calculate the joint probability of drawing a King, then a Queen, then a Jack sequentially without replacement.
Mathematical Formulation
Step 1 — Sequential probabilities:
Step 2 — Multiply dependent probabilities:
Python Code
p_sequence = (4 / 52) * (4 / 51) * (4 / 50)
print("P(K -> Q -> J):", round(p_sequence, 8))
Expected Output
P(K -> Q -> J): 0.00048265
3.3 The Addition Rule
Case 3.3.1 — Mutually Exclusive Events
When do we use this?
When two events cannot occur on the same trial, add their probabilities.
Mathematical Equations
Worked Lecture Example
For one card drawn from a standard 52-card deck, find the probability of drawing a four OR an ace.
Step 1 — Find each probability
There are four fours and four aces in a standard deck:
Step 2 — Add the probabilities
The events are mutually exclusive because a single card cannot be both a four and an ace:
Final Result
Simple Python Code
probability = 4/52 + 4/52
print(round(probability, 5))
Expected Output
0.15385
Case 3.3.2 — General Addition Rule
When do we use this?
Use the general addition rule when two events can overlap (are not mutually exclusive).
Mathematical Equations
Worked Lecture Example
Roll one standard six-sided die. Let event , and event .
Step 1 — Find the overlap
and share the outcome :
Step 2 — Apply the addition rule
Subtract the overlap once to avoid double counting:
Final Result
Simple Python Code
probability = 2/6 + 3/6 - 1/6
print(round(probability, 4))
Expected Output
0.6667
Case 3.3.3 — Blood-Type Addition Example
When do we use this?
Use the addition rule with frequency table counts when categories overlap.
Mathematical Equations
Worked Lecture Example
Lecture counts:
- Type B =
- Rh-negative =
- Both Type B and Rh-negative =
- Total sample =
Step 1 — Substitute counts
Add the two category counts and subtract the overlap:
Step 2 — Calculate
The favorable count is :
Final Result
Simple Python Code
probability = (45 + 65 - 8) / 409
print(round(probability, 4))
Expected Output
0.2494
3.4 Additional Topics in Probability and Counting
Case 3.4.1 — Factorial and Permutations
When do we use this?
Use factorials and ordered multiplication when arrangements depend on order.
Mathematical Equations
Worked Lecture Example
The lecture evaluates a Sudoku first row and a three-digit code without repeated digits.
Step 1 — Sudoku first row
Arrange 9 distinct digits in 9 positions:
Step 2 — Three-digit code
There are 10 choices for the first digit, 9 choices for the second, and 8 for the third. A leading zero is allowed because it is an identification code:
Final Result
- Sudoku arrangements =
- Three-digit codes =
Simple Python Code
sudoku = 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1
codes = 10 * 9 * 8
print("Sudoku:", sudoku)
print("Codes:", codes)
Expected Output
Sudoku: 362880
Codes: 720
Case 3.4.2 — Combinations
When do we use this?
Use combinations when selecting items and the order of selection does not matter.
Mathematical Equations
Worked Lecture Example
Lecture examples include arranging repeated house types and choosing 4 companies from 16.
Step 1 — Repeated house types
For 12 houses divided into types of 6, 4, and 2:
Step 2 — Choose 4 companies from 16
Cancel factorials to simplify computation:
Final Result
Simple Python Code
groups = (16 * 15 * 14 * 13) // (4 * 3 * 2 * 1)
print(groups)
Expected Output
1820
Case 3.4.3 — Combination Probability
When do we use this?
Use combinations when selecting several items simultaneously without regard to order.
Mathematical Equations
Worked Lecture Example
In the lecture corn-kernel problem, 3 of 400 kernels are affected. Four kernels are selected at random. Find the probability of selecting exactly one affected kernel.
Step 1 — Choose the affected kernel
Choose 1 from the 3 affected kernels:
Step 2 — Choose the unaffected kernels
Choose 3 from the remaining 397 kernels:
Step 3 — Count favorable selections
Multiply the two combination counts:
Step 4 — Count all possible selections
Choose any 4 kernels from the 400 available:
Step 5 — Calculate the probability
Divide favorable outcomes by total possible outcomes:
Final Result
Simple Python Code
three_other = (397 * 396 * 395) // (3 * 2 * 1)
favourable = 3 * three_other
all_groups = (400 * 399 * 398 * 397) // (4 * 3 * 2 * 1)
probability = favourable / all_groups
print("Probability:", round(probability, 5))
Expected Output
Probability: 0.02955