BRAGA

02 Writing02-02 Notes02-02-369

Complementary Events

Published 16 Apr 20263 min read
Contents
  1. 01Deep Breakdown
  2. 02Flowchart
  3. 03Real-world use
  4. 04The formula, piece by piece
  5. 05The formula in words
  6. 06Critical Concepts
  7. 07Step-by-step calculation (tiny example)
  8. 08Code examples
P(Ac)=1−P(A)P(A^c) = 1 - P(A)
(1)

Deep Breakdown

What it tells me (Situation Awareness): The complement of event AA is "everything except AA." Since AA and AcA^c 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 P(Ac)P(A^c) and subtract from 1 than to compute P(A)P(A) directly.

Flowchart

Event A occursP(A) = pEvent A doesNOT occur(complementA^c)P(A^c) = 1 - pP(A) + P(A^c) =1

Real-world use

Where it is used

"At least one" probability calculations: P(at least one success)=1−P(no successes)P(\text{at least one success}) = 1 - P(\text{no successes}). Also: P(churn)=1−P(retain)P(\text{churn}) = 1 - P(\text{retain}), P(fraud detected)=1−P(missed)P(\text{fraud detected}) = 1 - P(\text{missed}).

Problem it solves

When computing P(A)P(A) directly is complex (e.g., "at least one" requires summing many cases), computing P(Ac)P(A^c) is often trivial.

How it solves the problem

Leverages P(Ω)=1P(\Omega) = 1 and the disjointness of AA and AcA^c: P(A)+P(Ac)=1P(A) + P(A^c) = 1.

Example in a business

Probability that at least one of 10 email A/B tests detects a false positive (at α=0.05\alpha=0.05 each) if all null hypotheses are true: 1−(1−0.05)10=1−0.9510≈0.4011 - (1-0.05)^{10} = 1 - 0.95^{10} \approx 0.401. This motivates multiple testing corrections.

The formula, piece by piece

P(Ac)=1−P(A)P(A^c) = 1 - P(A)

  • AcA^c: complement of event AA (all outcomes NOT in AA).
  • P(A)P(A): probability of event AA.
  • 11: total probability from P(Ω)=1P(\Omega) = 1.

The formula in words

"The probability that AA does NOT occur equals 1 minus the probability that AA does occur." If P(churn)=0.15P(\text{churn}) = 0.15, then P(retain)=1−0.15=0.85P(\text{retain}) = 1 - 0.15 = 0.85.

Critical Concepts

  • Requires AA and AcA^c to be exhaustive (cover all outcomes) and mutually exclusive.
  • "At least one" trick: P(≥1 success in n)=1−(1−p)nP(\geq 1 \text{ success in } n) = 1 - (1-p)^n.
  • 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 P(click)=0.03P(\text{click}) = 0.03 (3% CTR).

Step 2: Apply complement P(no click)=1−P(click)=1−0.03=0.97P(\text{no click}) = 1 - P(\text{click}) = 1 - 0.03 = 0.97

Step 3: "At least one" extension P(at least one click in 5 impressions)=1−0.975=1−0.859=0.141P(\text{at least one click in 5 impressions}) = 1 - 0.97^5 = 1 - 0.859 = 0.141

Code examples

Beginner example (Python)

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 correction

Beginner example (R)

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)

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

#probability-statistics#probability-theory#axioms-and-basic-probability

Keyboard shortcuts

Single keys, ignored while typing in a field or with Cmd, Ctrl or Alt held.

0
Home
1 2 3 4
Work, Writing, Tools, About
j / k
Next / previous section on this page
n / p
Next / previous project or essay
u
Up one level
l
Deutsch
t
Light or dark theme
?
This list
Esc
Close