PROBABILITY & STATISTICS / 2. PROBABILITY AXIOMS & EVENTS

Probability Axioms, Sample Space & Events

The formal rules of probability — everything else derives from these


EXPLANATION

Probability is a function P that assigns a number between 0 and 1 to events.

Kolmogorov's Three Axioms (everything in probability follows from these):
1. P(A) ≥ 0 for any event A
2. P(S) = 1 where S is the sample space (something must happen)
3. P(A ∪ B) = P(A) + P(B) if A and B are mutually exclusive

Key definitions:
• Sample space S → set of all possible outcomes
• Event → a subset of S
• Complement → P(Aᶜ) = 1 - P(A)
• Union → P(A ∪ B) = P(A) + P(B) - P(A ∩ B)  [inclusion-exclusion]
• Intersection → P(A ∩ B) = P(A) × P(B) if A and B are INDEPENDENT

Independent events: knowing A happened tells you nothing about B.
P(A ∩ B) = P(A) × P(B)

Mutually exclusive: A and B cannot both happen.
P(A ∩ B) = 0, so P(A ∪ B) = P(A) + P(B)

Important: Independent ≠ Mutually Exclusive. They're almost opposite concepts.

DIAGRAM

Sample space S = {1, 2, 3, 4, 5, 6}  (die roll)
  Event A = {2, 4, 6}  (even)
  Event B = {1, 2, 3}  (≤ 3)

  P(A) = 3/6 = 0.5
  P(B) = 3/6 = 0.5
  P(A ∩ B) = P({2}) = 1/6        ← both even AND ≤ 3
  P(A ∪ B) = P(A)+P(B)-P(A∩B)   ← inclusion-exclusion
            = 0.5+0.5-1/6 = 5/6

  Venn diagram:
  ┌─────────────────────────┐
  │  S                      │
  │  ┌──────┐  ┌──────┐    │
  │  │  A   │∩ │  B   │    │
  │  │ 4,6  │2 │ 1,3  │    │
  │  └──────┘  └──────┘    │
  │         5               │
  └─────────────────────────┘

CODE

PYTHON
1import numpy as np
2from fractions import Fraction
3
4# ── Sample space simulation ───────────────────────────────────────
5np.random.seed(42)
6
7# Simulate 100,000 die rolls — verify axioms empirically
8rolls = np.random.randint(1, 7, size=100_000)
9event_A = rolls % 2 == 0 # even numbers
10event_B = rolls <= 3 # ≤ 3
11
12P_A = event_A.mean()
13P_B = event_B.mean()
14P_A_and_B = (event_A & event_B).mean()
15P_A_or_B = (event_A | event_B).mean()
16
17print(f"P(A) = {P_A:.4f} (expected 0.5)")
18print(f"P(B) = {P_B:.4f} (expected 0.5)")
19print(f"P(A∩B) = {P_A_and_B:.4f} (expected {1/6:.4f})")
20print(f"P(A∪B) = {P_A_or_B:.4f} (expected {5/6:.4f})")
21
22# Inclusion-exclusion rule verification
23print(f"P(A)+P(B)-P(A∩B) = {P_A + P_B - P_A_and_B:.4f}")
24
25# ── Independence check ────────────────────────────────────────────
26# Two events A, B are independent if P(A∩B) = P(A)×P(B)
27product = P_A * P_B
28print(f"\nP(A)×P(B) = {product:.4f}")
29print(f"P(A∩B) = {P_A_and_B:.4f}")
30print(f"Independent? {np.isclose(product, P_A_and_B, atol=0.01)}")
31# False — even numbers and ≤3 are NOT independent
32
33# ── Complement rule ───────────────────────────────────────────────
34# P(at least one 6 in 4 rolls) = 1 - P(no 6 in 4 rolls)
35P_no_six_per_roll = 5/6
36P_no_six_in_4_rolls = P_no_six_per_roll ** 4
37P_at_least_one_six = 1 - P_no_six_in_4_rolls
38print(f"\nP(at least one 6 in 4 rolls) = {P_at_least_one_six:.4f}")
39
40# ── Simulate birthday problem ─────────────────────────────────────
41def birthday_prob(n_people, simulations=50_000):
42 """P(at least 2 people share a birthday) with n people"""
43 count = 0
44 for _ in range(simulations):
45 birthdays = np.random.randint(1, 366, size=n_people)
46 if len(set(birthdays)) < n_people:
47 count += 1
48 return count / simulations
49
50for n in [10, 23, 30, 50]:
51 print(f"n={n:2d} people: P(shared birthday) {birthday_prob(n):.4f}")
52# At n=23: probability > 0.5!
← PREV1. Counting & CombinatoricsNEXT →3. Conditional Prob & Bayes