Lesson 3 of 15
Complement Rule & At-Least-One Problems
The Complement Rule
From the axioms: , so:
This is more powerful than it looks. Many problems are easier to solve via the complement.
At-Least-One Problems
What is the probability of getting at least one success in independent trials?
The complement is "zero successes in all trials":
# P(at least one head in 3 fair coin flips)
p_failure = 0.5 # P(tails on one flip)
n = 3
p = 1 - p_failure**n
print(round(p, 4)) # 0.875
Birthday Problem
How many people do you need so there's a >50% chance two share a birthday? The complement is "all birthdays distinct":
The answer is just 23 people — a famously counterintuitive result.
Your Task
Implement at_least_one(p_failure, n_trials) that returns , rounded to 4 decimal places.
Pyodide loading...
Loading...
Click "Run" to execute your code.