Contents
Deep Breakdown
What it tells me (Situation Awareness): The complement of event is "everything except ." Since and together cover the entire sample space, their probabilities must sum to 1. This is one of the most-used probability identities in practice: it is often easier to compute and subtract from 1 than to compute directly.
Flowchart
Real-world use
Where it is used
"At least one" probability calculations: . Also: , .
Problem it solves
When computing directly is complex (e.g., "at least one" requires summing many cases), computing is often trivial.
How it solves the problem
Leverages and the disjointness of and : .
Example in a business
Probability that at least one of 10 email A/B tests detects a false positive (at each) if all null hypotheses are true: . This motivates multiple testing corrections.
The formula, piece by piece
- : complement of event (all outcomes NOT in ).
- : probability of event .
- : total probability from .
The formula in words
"The probability that does NOT occur equals 1 minus the probability that does occur." If , then .
Critical Concepts
- Requires and to be exhaustive (cover all outcomes) and mutually exclusive.
- "At least one" trick: .
- False discovery rate calculations depend on this.
- In code:
1 - p— the complement is always this simple.
Step-by-step calculation (tiny example)
Step 1: Known probability (3% CTR).
Step 2: Apply complement
Step 3: "At least one" extension
Code examples
Beginner example (Python)
# Multiple testing: probability of at least one false positive
alpha = 0.05
n_tests = 10
p_at_least_one_fp = 1 - (1 - alpha) ** n_tests
print(f"P(>= 1 false positive in {n_tests} tests) = {p_at_least_one_fp:.3f}")
# 0.401 - motivates Bonferroni correctionBeginner example (R)
alpha <- 0.05
n_tests <- 10
p_at_least_one_fp <- 1 - (1 - alpha)^n_tests
cat(sprintf("P(>= 1 false positive in %d tests) = %.3f\n", n_tests, p_at_least_one_fp))Professional example (Python)
import numpy as np
def family_wise_error_rate( per_test_alpha: float, n_tests: int ) -> float:
"""Compute FWER: P(at least one false positive) = 1 - (1 - alpha)^n. Uses complement rule: P(A^c) = 1 - P(A). Args: per_test_alpha: Type I error rate per individual test. n_tests: Number of independent tests performed. Returns: Family-wise error rate. """
return 1.0 - (1.0 - per_test_alpha) ** n_tests
def bonferroni_correction(target_fwer: float, n_tests: int) -> float:
"""Return per-test alpha to achieve target FWER via Bonferroni."""
return target_fwer / n_tests # A/B testing multiple comparisons analysis
ALPHA = 0.05
test_counts = [1, 5, 10, 20, 50, 100]
print(f"Complement rule: FWER analysis at alpha={ALPHA}")
print(f"{'n_tests':>10} {'FWER':>12} {'Bonferroni alpha':>18}")
for n in test_counts:
fwer = family_wise_error_rate(ALPHA, n)
bonf_alpha = bonferroni_correction(ALPHA, n)
print(f"{n:>10} {fwer:>12.4f} {bonf_alpha:>18.6f}")Source: AIO p. 84