TExcelTAD
Home › Probability Theory › Independent Events and Variables

Independent Events and Variables

Two events are independent when knowing that one happened tells you nothing about the other. Independence is what makes most probability calculations tractable, and assuming it when it is false is behind many real-world disasters, from financial risk models to correlated server failures.

Definition

Events EE and FF are independent if

Pr⁡[E∩F]=Pr⁡[E]⋅Pr⁡[F]\Pr[E \cap F] = \Pr[E] \cdot \Pr[F]

equivalently (when Pr⁡[F]>0\Pr[F] > 0) Pr⁡[E∣F]=Pr⁡[E]\Pr[E \mid F] = \Pr[E]. Events A1,…,AnA_1, \ldots, A_n are mutually independent if the product rule holds for every subcollection; checking only pairs is not enough.

Random variables XX and YY are independent if Pr⁡[X=x,Y=y]=Pr⁡[X=x]Pr⁡[Y=y]\Pr[X = x, Y = y] = \Pr[X = x]\Pr[Y = y] for all values x,yx, y (for continuous variables, the joint density factors; see Marginals and Independence).

Checking independence

Two dice: "first die is even" and "sum is 7" are independent; "first die is even" and "sum is 8" are not.

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

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

A = lambda w: w[0] % 2 == 0
for target in [7, 8]:
    B = lambda w, t=target: w[0] + w[1] == t
    both = P(lambda w: A(w) and B(w))
    print(f"sum {target}: P(A and B) = {both}, P(A) P(B) = {P(A) * P(B)}, independent: {both == P(A) * P(B)}")
sum 7: P(A and B) = 1/12, P(A) P(B) = 1/12, independent: True
sum 8: P(A and B) = 1/12, P(A) P(B) = 5/72, independent: False

For sum 7, whatever the first die shows, exactly one value of the second die completes the 7, so the first die carries no information. For sum 8, a first die of 1 makes 8 impossible.

Pairwise is not mutual

Toss two fair coins. Let AA = "first is heads", BB = "second is heads", CC = "the two coins agree". Each pair is independent, but all three are not: AA and BB together determine CC.

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

omega = list(product("HT", repeat=2))
P = lambda e: Fraction(sum(1 for w in omega if e(w)), len(omega))
A = lambda w: w[0] == "H"
B = lambda w: w[1] == "H"
C = lambda w: w[0] == w[1]
for name, X, Y in [("A,B", A, B), ("A,C", A, C), ("B,C", B, C)]:
    print(name, P(lambda w: X(w) and Y(w)) == P(X) * P(Y))
print("A,B,C:", P(lambda w: A(w) and B(w) and C(w)), "vs", P(A) * P(B) * P(C))
A,B True
A,C True
B,C True
A,B,C: 1/4 vs 1/8

The same structure explains why XOR-based secret sharing works: each share alone reveals nothing, yet two shares together reveal the secret.

Independent trials

Repeating an experiment under the same conditions, with no influence between repetitions, gives independent trials, the model behind Bernoulli trials. Independence lets you multiply: the chance that 3 independent replicas, each down 1% of the time, are all down at once is 0.013=10−60.01^3 = 10^{-6}. If the replicas share a power supply, the events are not independent and the real figure can be close to 0.01.

python · try it yourself
import random

rng = random.Random(6)
n = 1_000_000
indep = shared = 0
for _ in range(n):
    # independent replicas
    indep += all(rng.random() < 0.01 for _ in range(3))
    # replicas sharing a power supply that fails 0.5% of the time
    power_out = rng.random() < 0.005
    shared += power_out or all(rng.random() < 0.005 for _ in range(3))
print("independent: all down", indep / n)
print("shared power: all down", shared / n)
independent: all down 1e-06
shared power: all down 0.004986

In software

Redundancy only helps as much as failures are independent, which is why cloud providers offer separate availability zones. In statistics and machine learning, "independent and identically distributed" (i.i.d.) samples are the default assumption; data leakage and time-correlated data break it. Hash functions are designed so that bits of the output behave as if independent.

Exercises

Exercise 1: A die and a coin

A die is rolled and a coin tossed. Are "die shows 6" and "coin shows heads" independent? What is the probability of both?

Answer

Yes; 1/121/12.

Solution

The 12 outcomes (face, side) are equally likely and the product rule holds: 16⋅12=112\frac{1}{6} \cdot \frac{1}{2} = \frac{1}{12}.

Exercise 2: Disjoint versus independent

Can two disjoint events with positive probabilities be independent?

Answer

No.

Solution

Disjoint means Pr⁡[E∩F]=0\Pr[E \cap F] = 0, but Pr⁡[E]Pr⁡[F]>0\Pr[E]\Pr[F] > 0. In fact disjoint events are strongly dependent: if one happens, the other cannot.

Exercise 3: Reliability (code)

A system works if component A works and at least one of B and C works. Each works independently with probability 0.9. Compute the reliability exactly and by simulation.

Answer

0.9⋅(1−0.12)=0.8910.9 \cdot (1 - 0.1^2) = 0.891.

Solution
python · try it yourself
import random

rng = random.Random(1)
n = 200_000
ok = 0
for _ in range(n):
    a, b, c = (rng.random() < 0.9 for _ in range(3))
    ok += a and (b or c)
print(ok / n, 0.9 * (1 - 0.1 ** 2))
0.891695 0.891

Test yourself

Events EE and FF are independent when…

  1. E∩F=∅E \cap F = \varnothing
  2. P(E∩F)=P(E)P(F)P(E \cap F) = P(E) P(F)
  3. P(E)+P(F)=1P(E) + P(F) = 1
  4. P(E)=P(F)P(E) = P(F)

Three events are pairwise independent. Are they necessarily mutually independent?

  1. Yes
  2. No
  3. Only if they are disjoint
  4. Only for coins