TExcelTAD
Home › Probability Theory › Rules of Probability

Rules of Probability

A handful of rules follow from the definition Pr⁡[E]=∑ω∈Em(ω)\Pr[E] = \sum_{\omega \in E} m(\omega), and they let you compute probabilities of complicated events from simpler ones without listing outcomes.

The basic rules

For events AA, BB in a sample space Ω\Omega:

  1. 0≤Pr⁡[A]≤10 \le \Pr[A] \le 1, Pr⁡[Ω]=1\Pr[\Omega] = 1, Pr⁡[∅]=0\Pr[\varnothing] = 0.
  2. Complement: Pr⁡[Aˉ]=1−Pr⁡[A]\Pr[\bar{A}] = 1 - \Pr[A].
  3. Monotonicity: if A⊆BA \subseteq B then Pr⁡[A]≤Pr⁡[B]\Pr[A] \le \Pr[B].
  4. Disjoint additivity: if A∩B=∅A \cap B = \varnothing then Pr⁡[A∪B]=Pr⁡[A]+Pr⁡[B]\Pr[A \cup B] = \Pr[A] + \Pr[B].
  5. Inclusion-exclusion: Pr⁡[A∪B]=Pr⁡[A]+Pr⁡[B]−Pr⁡[A∩B]\Pr[A \cup B] = \Pr[A] + \Pr[B] - \Pr[A \cap B].
  6. Union bound: Pr⁡[A1∪⋯∪An]≤Pr⁡[A1]+⋯+Pr⁡[An]\Pr[A_1 \cup \cdots \cup A_n] \le \Pr[A_1] + \cdots + \Pr[A_n].

Each follows by splitting sums over outcomes. For rule 5, the outcomes in A∩BA \cap B are counted twice in Pr⁡[A]+Pr⁡[B]\Pr[A] + \Pr[B], so subtract them once, exactly as in counting with inclusion-exclusion.

Checking the rules on dice

python · try it yourself
from fractions import Fraction
from itertools import product

omega = list(product(range(1, 7), repeat=2))
P = lambda event: Fraction(sum(1 for w in omega if event(w)), len(omega))

A = lambda w: w[0] + w[1] >= 10          # sum at least 10
B = lambda w: w[0] == w[1]               # a double
print("P(A) =", P(A), " P(B) =", P(B), " P(A and B) =", P(lambda w: A(w) and B(w)))
print("P(A or B) directly:      ", P(lambda w: A(w) or B(w)))
print("by inclusion-exclusion:  ", P(A) + P(B) - P(lambda w: A(w) and B(w)))
print("P(not A) =", P(lambda w: not A(w)), "= 1 - P(A) =", 1 - P(A))
P(A) = 1/6  P(B) = 1/6  P(A and B) = 1/18
P(A or B) directly:       5/18
by inclusion-exclusion:   5/18
P(not A) = 5/6 = 1 - P(A) = 5/6

Three or more events

Inclusion-exclusion extends by alternating signs:

Pr⁡[A∪B∪C]=Pr⁡[A]+Pr⁡[B]+Pr⁡[C]−Pr⁡[A∩B]−Pr⁡[A∩C]−Pr⁡[B∩C]+Pr⁡[A∩B∩C]\Pr[A \cup B \cup C] = \Pr[A] + \Pr[B] + \Pr[C] - \Pr[A \cap B] - \Pr[A \cap C] - \Pr[B \cap C] + \Pr[A \cap B \cap C]

A classic application is the matching problem: nn letters are put into nn addressed envelopes at random. The probability that at least one letter is in the right envelope is

Pr⁡[some match]=1−12!+13!−⋯±1n!  ⟶  1−1e≈0.632\Pr[\text{some match}] = 1 - \frac{1}{2!} + \frac{1}{3!} - \cdots \pm \frac{1}{n!} \;\longrightarrow\; 1 - \frac{1}{e} \approx 0.632

because for any kk specific letters, all are in place with probability (n−k)!/n!(n-k)!/n!, and there are (nk)\binom{n}{k} ways to choose them, giving the term 1/k!1/k!.

python · try it yourself
import math
import random

def p_match(n):
    return sum((-1) ** (k + 1) / math.factorial(k) for k in range(1, n + 1))

rng = random.Random(4)
def simulate(n, trials=50_000):
    hits = 0
    for _ in range(trials):
        perm = list(range(n))
        rng.shuffle(perm)
        hits += any(perm[i] == i for i in range(n))
    return hits / trials

for n in [2, 3, 5, 10]:
    print(n, round(p_match(n), 4), simulate(n))
print("limit 1 - 1/e =", round(1 - 1 / math.e, 4))
2 0.5 0.4985
3 0.6667 0.66226
5 0.6333 0.63318
10 0.6321 0.63484
limit 1 - 1/e = 0.6321

Surprisingly, the answer hardly depends on nn once n≥5n \ge 5: whether 10 or 10,000 letters, the chance of at least one match is about 63%.

The union bound in practice

The union bound needs no knowledge of how events overlap, which makes it the most used inequality in computer science. If each of 1000 servers fails on a given day with probability 10−510^{-5}, the probability that any fails is at most 1000⋅10−5=0.011000 \cdot 10^{-5} = 0.01, whatever the dependencies between failures.

In software

Reliability engineering applies these rules daily: the complement rule ("probability that all replicas survive"), the union bound (worst-case failure estimates), and inclusion-exclusion (overlapping failure modes). Probabilistic data structures such as Bloom filters are analysed with the same rules (Hashing and the Birthday Bound).

Exercises

Exercise 1: Cards

One card is drawn from a standard 52-card deck. What is the probability it is a heart or a face card (J, Q, K)?

Answer

22/52=11/2622/52 = 11/26.

Solution

Pr⁡[heart]=13/52\Pr[\text{heart}] = 13/52, Pr⁡[face]=12/52\Pr[\text{face}] = 12/52, Pr⁡[heart face]=3/52\Pr[\text{heart face}] = 3/52. Inclusion-exclusion: (13+12−3)/52=22/52(13 + 12 - 3)/52 = 22/52.

Exercise 2: Bounds

Pr⁡[A]=0.7\Pr[A] = 0.7 and Pr⁡[B]=0.5\Pr[B] = 0.5. What are the smallest and largest possible values of Pr⁡[A∩B]\Pr[A \cap B]?

Answer

Between 0.20.2 and 0.50.5.

Solution

Pr⁡[A∩B]=Pr⁡[A]+Pr⁡[B]−Pr⁡[A∪B]≥1.2−1=0.2\Pr[A \cap B] = \Pr[A] + \Pr[B] - \Pr[A \cup B] \ge 1.2 - 1 = 0.2, and Pr⁡[A∩B]≤min⁡(Pr⁡[A],Pr⁡[B])=0.5\Pr[A \cap B] \le \min(\Pr[A], \Pr[B]) = 0.5 by monotonicity. Both extremes are achievable.

Exercise 3: Divisible by 2, 3 or 5 (code)

A number is chosen uniformly from 1 to 300. Find the probability that it is divisible by 2, 3 or 5, using inclusion-exclusion, and check by counting.

Answer

220/300=11/15220/300 = 11/15.

Solution

12+13+15−16−110−115+130=2230\frac{1}{2} + \frac{1}{3} + \frac{1}{5} - \frac{1}{6} - \frac{1}{10} - \frac{1}{15} + \frac{1}{30} = \frac{22}{30} (exact here because 300 is a multiple of 30).

python · try it yourself
from fractions import Fraction as F

ie = F(1, 2) + F(1, 3) + F(1, 5) - F(1, 6) - F(1, 10) - F(1, 15) + F(1, 30)
count = sum(1 for n in range(1, 301) if n % 2 == 0 or n % 3 == 0 or n % 5 == 0)
print(ie, F(count, 300), count)
11/15 11/15 220

Test yourself

If P(A)=0.3P(A) = 0.3, P(B)=0.4P(B) = 0.4 and AA and BB are disjoint, what is P(A∪B)P(A \cup B)?

  1. 0.12
  2. 0.7
  3. 0.58
  4. 1

The union bound states that P(A1∪⋯∪An)P(A_1 \cup \cdots \cup A_n) is…

  1. equal to the sum
  2. at most the sum of the P(Ai)P(A_i)
  3. at least the sum
  4. the product of the P(Ai)P(A_i)

For large nn, the chance that a random permutation has at least one fixed point is about…

  1. 1/n1/n
  2. 1/21/2
  3. 1−1/e≈0.6321 - 1/e \approx 0.632
  4. 1