Skip to content
Back to Modules
Part IA Easter Term

Introduction to Probability

Probability Statistics Distributions Limit Theorems Mathematics Part IA Easter Term
  • Foundations

    Sample spaces, events, counting, and probability axioms

    • Sample Spaces and Events

      Experiments and Outcomes

      Probability theory provides mathematical tools for reasoning about uncertain events. The starting point is the notion of an experiment: a process that produces an outcome.

      Examples:

      • Rolling a die: outcome is which face lands uppermost
      • Flipping a coin three times: outcome is a sequence like HTH
      • Measuring the time until a component fails: outcome is a non-negative real number

      Sample Space

      The sample space Ω\Omega (or SS) is the set of all possible outcomes of an experiment.

      Discrete Sample Spaces

      A sample space is discrete if it is finite or countably infinite.

      Example (coin flip): Ω={H,T}\Omega = \{H, T\}

      Example (two dice): Ω={(i,j):i,j{1,2,3,4,5,6}}\Omega = \{(i,j) : i,j \in \{1,2,3,4,5,6\}\} has 36 outcomes.

      Example (coin flips until heads): Ω={1,2,3,}\Omega = \{1, 2, 3, \ldots\} is countably infinite.

      Continuous Sample Spaces

      A sample space is continuous if outcomes can take any value in an interval.

      Example (time to failure): Ω=[0,)\Omega = [0, \infty)

      Example (temperature): Ω=R\Omega = \mathbb{R} or some bounded interval.

      Events

      An event is a subset of the sample space: a collection of outcomes. We say an event EE occurs if the actual outcome of the experiment is in EE.

      Example (single die):

      • Event “rolling an even number”: E={2,4,6}E = \{2, 4, 6\}
      • Event “rolling at least 5”: F={5,6}F = \{5, 6\}

      Example (two dice):

      • Event “sum equals 7”: E={(1,6),(2,5),(3,4),(4,3),(5,2),(6,1)}E = \{(1,6), (2,5), (3,4), (4,3), (5,2), (6,1)\}
      • Event “both dice show the same”: F={(1,1),(2,2),(3,3),(4,4),(5,5),(6,6)}F = \{(1,1), (2,2), (3,3), (4,4), (5,5), (6,6)\}

      Special Events

      • The entire sample space Ω\Omega is the certain event: it always occurs.
      • The empty set \emptyset is the impossible event: it never occurs.
      • An elementary event (or atomic event) contains exactly one outcome: {x}\{x\} for some xΩx \in \Omega.

      Event Operations

      Since events are sets, we can combine them using set operations:

      OperationNotationMeaning
      UnionEFE \cup FEE or FF (or both) occurs
      IntersectionEFE \cap F or EFEFBoth EE and FF occur
      ComplementEcE^c or Eˉ\bar{E}EE does not occur
      DifferenceEFE - F or EFE \setminus FEE occurs but FF does not

      Venn diagram for set operations

      Mutually Exclusive Events

      Events EE and FF are mutually exclusive (or disjoint) if they cannot both occur: EF=E \cap F = \emptyset.

      Example (single die): The events “roll an even number” {2,4,6}\{2,4,6\} and “roll a 3” {3}\{3\} are mutually exclusive. But “roll an even number” and “roll at most 4” {1,2,3,4}\{1,2,3,4\} are not mutually exclusive: both occur if we roll 2 or 4.

      The Event Space

      The collection of all events forms a sigma-algebra (or σ\sigma-algebra), denoted F\mathcal{F}. This is a collection of subsets of Ω\Omega satisfying:

      1. ΩF\Omega \in \mathcal{F}
      2. If EFE \in \mathcal{F}, then EcFE^c \in \mathcal{F} (closed under complements)
      3. If E1,E2,FE_1, E_2, \ldots \in \mathcal{F}, then i=1EiF\bigcup_{i=1}^{\infty} E_i \in \mathcal{F} (closed under countable unions)

      For finite sample spaces, F\mathcal{F} is typically the power set P(Ω)\mathcal{P}(\Omega): all possible subsets.

      Why sigma-algebras? They ensure we can assign probabilities consistently. If we can talk about the probability of EE and of FF, we should also be able to talk about the probability of EcE^c and EFE \cup F.

      De Morgan’s Laws

      For any events EE and FF:

      (EF)c=EcFc(E \cup F)^c = E^c \cap F^c (EF)c=EcFc(E \cap F)^c = E^c \cup F^c

      Intuition: For EFE \cup F to not occur, both EE and FF must not occur. For EFE \cap F to not occur, either EE or FF must not occur.

      Partition

      A partition of Ω\Omega is a collection of mutually exclusive events F1,F2,,FnF_1, F_2, \ldots, F_n whose union is Ω\Omega:

      FiFj= for ijF_i \cap F_j = \emptyset \text{ for } i \neq j i=1nFi=Ω\bigcup_{i=1}^{n} F_i = \Omega

      Partitions are crucial for the Law of Total Probability.

      Example (single die): {1},{2},{3},{4},{5},{6}\{1\}, \{2\}, \{3\}, \{4\}, \{5\}, \{6\} partitions the sample space.

      Example (blood type): F1=type A,F2=type B,F3=type AB,F4=type OF_1 = \text{type A}, F_2 = \text{type B}, F_3 = \text{type AB}, F_4 = \text{type O} partitions by blood type.

      Summary

      ConceptDefinition
      Sample space Ω\OmegaSet of all possible outcomes
      Event EESubset of the sample space
      Elementary eventEvent containing one outcome
      Mutually exclusiveEF=E \cap F = \emptyset
      PartitionMutually exclusive events that cover Ω\Omega
    • Counting and the Product Rule

      Why Counting?

      Many probability problems reduce to counting: determining how many outcomes lie in an event. If we can count the total number of equally likely outcomes and count how many satisfy our criterion, the probability is their ratio.

      The Product Rule

      Principle: If an experiment has n1n_1 possible outcomes, and for each of these, a second experiment has n2n_2 possible outcomes, then the combined experiment has n1×n2n_1 \times n_2 possible outcomes.

      More generally, for rr experiments:

      Total outcomes=n1×n2××nr\text{Total outcomes} = n_1 \times n_2 \times \cdots \times n_r

      Why does this work? Each outcome of the first experiment branches into n2n_2 outcomes of the second, each of those branches into n3n_3 outcomes of the third, and so on. The total is the product.

      Product rule tree diagram

      Examples

      Example 1: Rolling Two Dice

      Each die has 6 outcomes. The pair of dice has 6×6=366 \times 6 = 36 possible outcomes.

      Example 2: Coin Flips

      Three coin flips: each flip has 2 outcomes. Total: 2×2×2=82 \times 2 \times 2 = 8 outcomes.

      The sample space: {HHH,HHT,HTH,HTT,THH,THT,TTH,TTT}\{HHH, HHT, HTH, HTT, THH, THT, TTH, TTT\}

      Example 3: Licence Plates

      A licence plate has 3 letters followed by 3 digits. How many possible plates?

      • Each letter position: 26 choices
      • Each digit position: 10 choices
      • Total: 263×103=17,576,00026^3 \times 10^3 = 17{,}576{,}000

      Example 4: Hash Tables

      A hash table has 100 buckets. Two strings are hashed independently. How many ways can they be stored?

      Each string can go to any of 100 buckets. Total: 100×100=10,000100 \times 100 = 10{,}000 possible storage configurations.

      Ordered vs Unordered

      The product rule counts ordered outcomes: the sequence matters.

      Example (ordered): Drawing two balls from an urn with replacement, recording the order. If we have 5 balls, there are 5×5=255 \times 5 = 25 ordered pairs.

      Example (unordered): If we only care about which two balls we get (not the order), we divide by 2! for each pair: 2552+5=15\frac{25 - 5}{2} + 5 = 15 distinct unordered outcomes (the 5 pairs of the same ball, plus 20 ordered pairs reduced by a factor of 2).

      The Pigeonhole Principle

      Principle: If nn items are placed into kk boxes and n>kn > k, at least one box contains at least n/k\lceil n/k \rceil items.

      Corollary: If nn items are placed into n1n-1 boxes, at least one box contains at least 2 items.

      Example: Hash Collisions

      A hash table has 100 buckets. We hash 950 strings.

      • Is it possible some bucket has no entries? Yes, the items might cluster.
      • Is it guaranteed at least one bucket has at least 2 entries? Yes: 950>100950 > 100, so by pigeonhole, at least one bucket has at least 950/100=10\lceil 950/100 \rceil = 10 entries.
      • Is it guaranteed at least one bucket has at least 11 entries? No: we could potentially distribute 950 items with 9 buckets having 10 items and the rest having fewer.

      Counting with Restrictions

      Sometimes we impose restrictions that reduce the number of valid outcomes.

      Example: iPhone Passcodes

      Old iPhone passcodes were 4 digits. If fingerprints appear on 3 digits (one digit used twice), how many distinct passcodes?

      The passcode uses digits {a,b,c}\{a, b, c\} where one appears twice. We need to count sequences of length 4 using exactly these three digits.

      Method: Choose which digit appears twice (3 choices). Then arrange 4 items where 2 are identical: 4!2!=12\frac{4!}{2!} = 12 arrangements.

      Total: 3×12=363 \times 12 = 36.

      If fingerprints on only 2 digits: one digit used twice, another used twice. Choose which two digits (from the visible 2): must be those 2. Arrange: 4!2!2!=6\frac{4!}{2! \cdot 2!} = 6 arrangements.

      The General Counting Principle

      For a sequence of choices where the iith choice has nin_i options:

      Total=i=1rni\text{Total} = \prod_{i=1}^{r} n_i

      This assumes choices are independent: the options at each step do not depend on previous choices.

      When choices depend on previous selections (sampling without replacement), each nin_i decreases.

      Example: Drawing Without Replacement

      Draw 3 cards from a standard 52-card deck without replacement.

      • First card: 52 choices
      • Second card: 51 choices
      • Third card: 50 choices
      • Total ordered draws: 52×51×50=132,60052 \times 51 \times 50 = 132{,}600

      Summary

      ConceptFormula
      Product rulen1×n2××nrn_1 \times n_2 \times \cdots \times n_r
      Pigeonhole principlenn items in kk boxes \Rightarrow some box has n/k\geq \lceil n/k \rceil
      Ordered sampling with replacementnrn^r sequences of length rr from nn items
      Ordered sampling without replacementn(n1)(nr+1)=n!(nr)!n(n-1)\cdots(n-r+1) = \frac{n!}{(n-r)!}
    • Permutations and Combinations

      Factorial

      For a positive integer nn, the factorial is:

      n!=n×(n1)×(n2)××2×1n! = n \times (n-1) \times (n-2) \times \cdots \times 2 \times 1

      By convention, 0!=10! = 1.

      Factorials count the number of ways to arrange nn distinct objects in a sequence. The first position has nn choices, the second has n1n-1, and so on.

      Example: Arranging Books

      Six distinct books can be arranged on a shelf in 6!=7206! = 720 ways.

      Permutations

      A permutation is an ordered arrangement of objects.

      Permutations of nn Objects Taken rr at a Time

      The number of ways to arrange rr objects selected from nn distinct objects:

      P(n,r)=n!(nr)!=n(n1)(n2)(nr+1)P(n, r) = \frac{n!}{(n-r)!} = n(n-1)(n-2)\cdots(n-r+1)

      Intuition: We have nn choices for the first position, n1n-1 for the second, down to nr+1n-r+1 for the rrth position.

      Special case: P(n,n)=n!P(n, n) = n! arrangements of all nn objects.

      Example: Committee Officers

      From 10 people, select a president, vice-president, and treasurer. The order matters: select 3 and assign them to distinct roles.

      P(10,3)=10×9×8=720P(10, 3) = 10 \times 9 \times 8 = 720

      Combinations

      A combination is an unordered selection of objects.

      Combinations of nn Objects Taken rr at a Time

      The number of ways to select rr objects from nn distinct objects (order does not matter):

      (nr)=C(n,r)=n!r!(nr)!\binom{n}{r} = C(n, r) = \frac{n!}{r!(n-r)!}

      Why divide by r!r!? Each unordered selection corresponds to r!r! ordered arrangements. The permutations overcount by exactly this factor.

      Example: Selecting Books

      How many ways to select 3 books from a set of 6?

      (63)=6!3!3!=72036=20\binom{6}{3} = \frac{6!}{3! \cdot 3!} = \frac{720}{36} = 20

      Compare with permutations: P(6,3)=120P(6, 3) = 120. Each unordered set appears as 3!=63! = 6 permutations.

      Example: Committee Members

      From 10 people, select 3 committee members (no roles assigned):

      (103)=10!3!7!=7206=120\binom{10}{3} = \frac{10!}{3! \cdot 7!} = \frac{720}{6} = 120

      Key Properties of Binomial Coefficients

      Symmetry

      (nr)=(nnr)\binom{n}{r} = \binom{n}{n-r}

      Intuition: Selecting rr objects to include is equivalent to selecting nrn-r objects to exclude.

      Pascal’s Identity

      (nr)=(n1r1)+(n1r)\binom{n}{r} = \binom{n-1}{r-1} + \binom{n-1}{r}

      Intuition: Any selection of rr from nn objects either includes a specific object (leaving (n1r1)\binom{n-1}{r-1} ways) or excludes it (leaving (n1r)\binom{n-1}{r} ways).

      Sum

      r=0n(nr)=2n\sum_{r=0}^{n} \binom{n}{r} = 2^n

      This counts all subsets of an nn-element set. Each element can be either in or out: nn independent binary choices.

      Balls and Bins

      The techniques extend to distributing objects into containers.

      Distinct Balls into Distinct Bins

      nn distinct balls into kk distinct bins: knk^n ways. Each ball independently chooses a bin.

      Identical Balls into Distinct Bins

      nn identical balls into kk distinct bins, no restrictions: equivalent to placing k1k-1 dividers among n+k1n+k-1 positions.

      (n+k1k1)=(n+k1n)\binom{n+k-1}{k-1} = \binom{n+k-1}{n}

      Intuition: Imagine placing all nn balls in a row with k1k-1 dividers. The balls before the first divider go to bin 1, between first and second dividers to bin 2, and so on.

      Example: Server Distribution

      13 servers into 3 datacentres with capacities 6, 4, and 3. This counts arrangements where we partition the 13 labelled servers into groups of those sizes:

      (136)(74)(33)=1716×35×1=60,060\binom{13}{6} \binom{7}{4} \binom{3}{3} = 1716 \times 35 \times 1 = 60{,}060

      Alternatively: 13!6!4!3!\frac{13!}{6! \cdot 4! \cdot 3!} (multinomial coefficient).

      Permutations with Repetition

      When some objects are identical, the number of distinct arrangements is:

      n!n1!n2!nk!\frac{n!}{n_1! \cdot n_2! \cdots n_k!}

      where nin_i is the number of objects of type ii.

      Example: DNA Sequences

      How many distinct sequences can be formed from 3 A’s, 2 C’s, 1 G, and 1 T?

      7!3!2!1!1!=504012=420\frac{7!}{3! \cdot 2! \cdot 1! \cdot 1!} = \frac{5040}{12} = 420

      Example: Bit Strings

      Distinct bit strings from three 0’s and two 1’s:

      5!3!2!=12012=10\frac{5!}{3! \cdot 2!} = \frac{120}{12} = 10

      These are: 00111, 01011, 01101, 01110, 10011, 10101, 10110, 11001, 11010, 11100.

      Hypergeometric Formula

      When sampling without replacement, we use hypergeometric counts.

      Select nn items from a population of NN containing mm “special” items. The number of ways to get exactly ii special items:

      (mi)(Nmni)\binom{m}{i} \binom{N-m}{n-i}

      Choose ii special items from the mm available, and nin-i ordinary items from the NmN-m non-special.

      Summary Table

      ProblemFormula
      Arrange all nn objectsn!n!
      Arrange rr from nnP(n,r)=n!(nr)!P(n,r) = \frac{n!}{(n-r)!}
      Choose rr from nn(nr)=n!r!(nr)!\binom{n}{r} = \frac{n!}{r!(n-r)!}
      Arrange with repetitionsn!n1!nk!\frac{n!}{n_1! \cdots n_k!}
      nn identical into kk bins(n+k1n)\binom{n+k-1}{n}
    • Probability Axioms

      The Need for Axioms

      Intuitively, probability measures “how likely” an event is. But intuition can mislead. The axioms provide a rigorous foundation, ensuring all probability calculations are consistent.

      Kolmogorov’s Axioms

      Let Ω\Omega be a sample space and F\mathcal{F} an event space. A probability measure P:F[0,1]P: \mathcal{F} \to [0,1] satisfies:

      Axiom 1: Non-negativity

      P(E)0 for all events EP(E) \geq 0 \text{ for all events } E

      Probabilities are never negative.

      Axiom 2: Normalisation

      P(Ω)=1P(\Omega) = 1

      The certain event has probability 1. It always occurs.

      Axiom 3: Additivity

      For mutually exclusive events E1,E2,E_1, E_2, \ldots:

      P(i=1Ei)=i=1P(Ei)P\left(\bigcup_{i=1}^{\infty} E_i\right) = \sum_{i=1}^{\infty} P(E_i)

      The probability of the union of disjoint events equals the sum of their probabilities.

      For finite collections of mutually exclusive events:

      P(E1E2En)=P(E1)+P(E2)++P(En)P(E_1 \cup E_2 \cup \cdots \cup E_n) = P(E_1) + P(E_2) + \cdots + P(E_n)

      when all EiEj=E_i \cap E_j = \emptyset for iji \neq j.

      Consequences of the Axioms

      Probability of the Empty Set

      P()=0P(\emptyset) = 0

      Proof: Ω\Omega and \emptyset are mutually exclusive with Ω=Ω\Omega \cup \emptyset = \Omega. By Axiom 3: P(Ω)=P(Ω)+P()P(\Omega) = P(\Omega) + P(\emptyset), so P()=0P(\emptyset) = 0.

      Probability of Complement

      P(Ec)=1P(E)P(E^c) = 1 - P(E)

      Proof: EE and EcE^c partition Ω\Omega: EEc=ΩE \cup E^c = \Omega and EEc=E \cap E^c = \emptyset. By additivity: P(Ω)=P(E)+P(Ec)=1P(\Omega) = P(E) + P(E^c) = 1, hence P(Ec)=1P(E)P(E^c) = 1 - P(E).

      Probability Bounds

      0P(E)10 \leq P(E) \leq 1

      The lower bound is Axiom 1. The upper bound follows from P(E)=1P(Ec)P(E) = 1 - P(E^c) and P(Ec)0P(E^c) \geq 0.

      Monotonicity

      If EFE \subseteq F, then P(E)P(F)P(E) \leq P(F).

      Proof: Write F=E(FE)F = E \cup (F \setminus E) where these are disjoint. Then P(F)=P(E)+P(FE)P(E)P(F) = P(E) + P(F \setminus E) \geq P(E).

      Inclusion-Exclusion for Two Events

      P(EF)=P(E)+P(F)P(EF)P(E \cup F) = P(E) + P(F) - P(E \cap F)

      Why subtract P(EF)P(E \cap F)? The sum P(E)+P(F)P(E) + P(F) counts outcomes in EFE \cap F twice. We correct by subtracting once.

      Inclusion-exclusion for two events

      Inclusion-Exclusion for Three Events

      P(EFG)=P(E)+P(F)+P(G)P(EF)P(EG)P(FG)+P(EFG)P(E \cup F \cup G) = P(E) + P(F) + P(G) - P(E \cap F) - P(E \cap G) - P(F \cap G) + P(E \cap F \cap G)

      The pattern: add singletons, subtract pairwise intersections, add triple intersections.

      General Inclusion-Exclusion

      For nn events E1,E2,,EnE_1, E_2, \ldots, E_n:

      P(i=1nEi)=iP(Ei)i<jP(EiEj)+i<j<kP(EiEjEk)P\left(\bigcup_{i=1}^{n} E_i\right) = \sum_{i} P(E_i) - \sum_{i<j} P(E_i \cap E_j) + \sum_{i<j<k} P(E_i \cap E_j \cap E_k) - \cdots

      Alternating signs: add, subtract, add, subtract, and so on.

      Example: Card Drawing

      Draw a card from a standard deck. Let:

      • EE = card is a heart
      • FF = card is an ace

      P(EF)=P(E)+P(F)P(EF)=1352+452152=1652=413P(E \cup F) = P(E) + P(F) - P(E \cap F) = \frac{13}{52} + \frac{4}{52} - \frac{1}{52} = \frac{16}{52} = \frac{4}{13}

      Countable vs Uncountable

      The axioms extend to countable unions, but not uncountable ones. For uncountable sample spaces (like R\mathbb{R}), we cannot assign positive probability to every singleton while maintaining total probability 1.

      This motivates using probability density functions for continuous random variables rather than assigning probability to individual points.

      Constructing Probability Measures

      For finite sample spaces with equally likely outcomes:

      P(E)=EΩ=number of outcomes in Etotal number of outcomesP(E) = \frac{|E|}{|\Omega|} = \frac{\text{number of outcomes in } E}{\text{total number of outcomes}}

      This construction satisfies all axioms.

      Example (fair die): Ω={1,2,3,4,5,6}\Omega = \{1,2,3,4,5,6\} with each outcome having probability 1/61/6. Event “even” has probability {2,4,6}/6=3/6=1/2|\{2,4,6\}|/6 = 3/6 = 1/2.

      Summary

      PropertyFormula
      Certain eventP(Ω)=1P(\Omega) = 1
      Impossible eventP()=0P(\emptyset) = 0
      ComplementP(Ec)=1P(E)P(E^c) = 1 - P(E)
      Union (2 events)P(EF)=P(E)+P(F)P(EF)P(E \cup F) = P(E) + P(F) - P(E \cap F)
      MonotonicityEFP(E)P(F)E \subseteq F \Rightarrow P(E) \leq P(F)
      Bounds0P(E)10 \leq P(E) \leq 1
    • Set Operations and Probability

      Events as Sets

      Events are subsets of the sample space. Set operations translate naturally into probability operations.

      Union

      The union EFE \cup F is the event that EE or FF (or both) occurs.

      P(EF)=P(E)+P(F)P(EF)P(E \cup F) = P(E) + P(F) - P(E \cap F)

      The inclusion-exclusion formula corrects for double-counting outcomes in both events.

      Multiple Unions

      For nn events:

      P(i=1nEi)i=1nP(Ei)P\left(\bigcup_{i=1}^{n} E_i\right) \leq \sum_{i=1}^{n} P(E_i)

      This upper bound is the union bound (Boole’s inequality): the probability of at least one occurring is at most the sum of individual probabilities.

      Intersection

      The intersection EFE \cap F (or EFEF) is the event that both EE and FF occur.

      For mutually exclusive events: P(EF)=0P(E \cap F) = 0.

      Complement

      The complement EcE^c is the event that EE does not occur.

      P(Ec)=1P(E)P(E^c) = 1 - P(E)

      This is useful when computing the probability of “at least one” by considering “none”:

      P(at least one)=1P(none)P(\text{at least one}) = 1 - P(\text{none})

      Example: Matching Problem

      Three letters are randomly placed into three addressed envelopes. What is the probability at least one letter is in the correct envelope?

      Direct approach: Inclusion-exclusion over three events.

      Complement approach: Compute P(none correct)=P(derangement)P(\text{none correct}) = P(\text{derangement}). There are 2 derangements out of 3!=63! = 6 permutations. So P(none)=2/6=1/3P(\text{none}) = 2/6 = 1/3.

      P(at least one)=113=23P(\text{at least one}) = 1 - \frac{1}{3} = \frac{2}{3}

      Difference

      The set difference EF=EFE - F = E \setminus F is the event that EE occurs but FF does not.

      P(EF)=P(E)P(EF)P(E - F) = P(E) - P(E \cap F)

      Proof: E=(EF)(EF)E = (E - F) \cup (E \cap F) where these are disjoint. By additivity: P(E)=P(EF)+P(EF)P(E) = P(E - F) + P(E \cap F), so P(EF)=P(E)P(EF)P(E - F) = P(E) - P(E \cap F).

      Symmetric Difference

      The symmetric difference EF=(EF)(FE)E \triangle F = (E - F) \cup (F - E) is the event that exactly one of EE, FF occurs.

      P(EF)=P(E)+P(F)2P(EF)P(E \triangle F) = P(E) + P(F) - 2P(E \cap F)

      De Morgan’s Laws

      First Law

      (EF)c=EcFc(E \cup F)^c = E^c \cap F^c

      Probability interpretation: The event that neither EE nor FF occurs is the event that EE does not occur AND FF does not occur.

      Second Law

      (EF)c=EcFc(E \cap F)^c = E^c \cup F^c

      Probability interpretation: The event that not both EE and FF occur is the event that EE does not occur OR FF does not occur.

      Example

      Roll a die. Let EE = “roll even” {2,4,6}\{2,4,6\} and FF = “roll at least 5” {5,6}\{5,6\}.

      • EF={2,4,5,6}E \cup F = \{2,4,5,6\}, so (EF)c={1,3}(E \cup F)^c = \{1,3\}
      • Ec={1,3,5}E^c = \{1,3,5\}, Fc={1,2,3,4}F^c = \{1,2,3,4\}
      • EcFc={1,3}E^c \cap F^c = \{1,3\} (matches first law)

      Distributive Laws

      E(FG)=(EF)(EG)E \cap (F \cup G) = (E \cap F) \cup (E \cap G) E(FG)=(EF)(EG)E \cup (F \cap G) = (E \cup F) \cap (E \cup G)

      These allow us to expand or simplify probability expressions.

      Associative and Commutative Laws

      Union and intersection are associative and commutative:

      EF=FE,EF=FEE \cup F = F \cup E, \quad E \cap F = F \cap E E(FG)=(EF)G,E(FG)=(EF)GE \cup (F \cup G) = (E \cup F) \cup G, \quad E \cap (F \cap G) = (E \cap F) \cap G

      This means we can rearrange events in unions and intersections without changing the result.

      Summary Table

      OperationSet NotationProbability Formula
      UnionEFE \cup FP(E)+P(F)P(EF)P(E) + P(F) - P(E \cap F)
      IntersectionEFE \cap FP(EF)P(E \cap F)
      ComplementEcE^c1P(E)1 - P(E)
      DifferenceEFE - FP(E)P(EF)P(E) - P(E \cap F)
      De Morgan 1(EF)c(E \cup F)^cEcFcE^c \cap F^c
      De Morgan 2(EF)c(E \cap F)^cEcFcE^c \cup F^c
    • Inclusion-Exclusion Principle

      The Problem with Unions

      When computing P(EF)P(E \cup F), we cannot simply add P(E)+P(F)P(E) + P(F) because outcomes in EFE \cap F get counted twice.

      Two-Event Inclusion-Exclusion

      P(EF)=P(E)+P(F)P(EF)P(E \cup F) = P(E) + P(F) - P(E \cap F)

      Intuition: Add probabilities of each event, then subtract the intersection to correct for double-counting.

      Example: Cards

      Draw a card. Let EE = “heart” and FF = “ace”.

      P(EF)=1352+452152=1652=413P(E \cup F) = \frac{13}{52} + \frac{4}{52} - \frac{1}{52} = \frac{16}{52} = \frac{4}{13}

      Verify directly: 13 hearts + 3 other aces = 16 cards out of 52.

      Three-Event Inclusion-Exclusion

      P(EFG)=P(E)+P(F)+P(G)P(EF)P(EG)P(FG)+P(EFG)P(E \cup F \cup G) = P(E) + P(F) + P(G) - P(E \cap F) - P(E \cap G) - P(F \cap G) + P(E \cap F \cap G)

      Pattern: Add singletons, subtract pairs, add triples. The signs alternate.

      Inclusion-exclusion for three events

      Why Add the Triple?

      Each element in EFGE \cap F \cap G:

      • Counted 3 times in singletons (+3)
      • Counted 3 times in pairs (−3)
      • Not yet counted in triples (+0)

      We need +1 total, so add P(EFG)P(E \cap F \cap G).

      General Formula

      For nn events E1,E2,,EnE_1, E_2, \ldots, E_n:

      P(i=1nEi)=k=1n(1)k+11i1<i2<<iknP(Ei1Ei2Eik)P\left(\bigcup_{i=1}^{n} E_i\right) = \sum_{k=1}^{n} (-1)^{k+1} \sum_{1 \leq i_1 < i_2 < \cdots < i_k \leq n} P(E_{i_1} \cap E_{i_2} \cap \cdots \cap E_{i_k})

      In words: sum probabilities of kk-fold intersections with sign (1)k+1(-1)^{k+1}.

      Example: Hat Check Problem

      nn people throw their hats into a pile. Each picks a hat randomly. What is the probability at least one person gets their own hat?

      Let EiE_i = person ii gets their own hat.

      P(i=1nEi)=k=1n(1)k+1(nk)(nk)!n!P\left(\bigcup_{i=1}^{n} E_i\right) = \sum_{k=1}^{n} (-1)^{k+1} \binom{n}{k} \frac{(n-k)!}{n!}

      • P(Ei)=1nP(E_i) = \frac{1}{n} for each of (n1)\binom{n}{1} choices
      • P(EiEj)=(n2)!n!P(E_i \cap E_j) = \frac{(n-2)!}{n!} for (n2)\binom{n}{2} pairs
      • Generally: PP(kk specific people get their hats) =(nk)!n!= \frac{(n-k)!}{n!}

      This gives:

      P(at least one match)=k=1n(1)k+11k!P(\text{at least one match}) = \sum_{k=1}^{n} (-1)^{k+1} \frac{1}{k!}

      As nn \to \infty, this approaches 1e10.6321 - e^{-1} \approx 0.632.

      The Complement View

      For complex unions, computing P(none)P(\text{none}) via complement is often easier.

      P(i=1nEi)=1P(i=1nEic)P\left(\bigcup_{i=1}^{n} E_i\right) = 1 - P\left(\bigcap_{i=1}^{n} E_i^c\right)

      When events are independent: P(all fail)=P(Eic)P(\text{all fail}) = \prod P(E_i^c), giving:

      P(at least one)=1i=1n(1P(Ei))P(\text{at least one}) = 1 - \prod_{i=1}^{n}(1 - P(E_i))

      Example: Reliability

      A system has 3 components, each failing independently with probability 0.1. What is the probability the system fails (at least one component fails)?

      P(system fails)=1P(all work)=10.93=10.729=0.271P(\text{system fails}) = 1 - P(\text{all work}) = 1 - 0.9^3 = 1 - 0.729 = 0.271

      Inclusion-Exclusion for Counting

      The principle applies to counting, not just probability:

      i=1nAi=k=1n(1)k+11i1<<iknAi1Aik|\bigcup_{i=1}^{n} A_i| = \sum_{k=1}^{n} (-1)^{k+1} \sum_{1 \leq i_1 < \cdots < i_k \leq n} |A_{i_1} \cap \cdots \cap A_{i_k}|

      Example: Integer Properties

      How many integers from 1 to 1000 are divisible by 2 or 3?

      Let AA = multiples of 2, BB = multiples of 3.

      • A=1000/2=500|A| = \lfloor 1000/2 \rfloor = 500
      • B=1000/3=333|B| = \lfloor 1000/3 \rfloor = 333
      • AB|A \cap B| = multiples of 6: 1000/6=166\lfloor 1000/6 \rfloor = 166

      AB=500+333166=667|A \cup B| = 500 + 333 - 166 = 667

      Bonferroni Inequalities

      The partial sums in inclusion-exclusion alternate between over- and under-estimates:

      P(E1En)iP(Ei)P(E_1 \cup \cdots \cup E_n) \leq \sum_{i} P(E_i) P(E1En)iP(Ei)i<jP(EiEj)P(E_1 \cup \cdots \cup E_n) \geq \sum_{i} P(E_i) - \sum_{i<j} P(E_i \cap E_j)

      These provide upper and lower bounds when exact computation is impractical.

      Summary

      EventsFormula
      2 eventsP(E)+P(F)P(EF)P(E) + P(F) - P(E \cap F)
      3 eventsP(E)+P(F)+P(G)P(EF)P(EG)P(FG)+P(EFG)P(E)+P(F)+P(G) - P(E \cap F) - P(E \cap G) - P(F \cap G) + P(E \cap F \cap G)
      nn eventsk=1n(1)k+1i1<<ikP(Ei1Eik)\sum_{k=1}^{n} (-1)^{k+1} \sum_{i_1 < \cdots < i_k} P(E_{i_1} \cap \cdots \cap E_{i_k})
      Complement1P(Eic)1 - P(\bigcap E_i^c)
    • The Union Bound

      Statement

      Boole’s inequality (Union Bound): For any events E1,E2,,EnE_1, E_2, \ldots, E_n:

      P(i=1nEi)i=1nP(Ei)P\left(\bigcup_{i=1}^{n} E_i\right) \leq \sum_{i=1}^{n} P(E_i)

      The probability of at least one event occurring is at most the sum of their individual probabilities.

      For infinitely many events:

      P(i=1Ei)i=1P(Ei)P\left(\bigcup_{i=1}^{\infty} E_i\right) \leq \sum_{i=1}^{\infty} P(E_i)

      Proof

      By inclusion-exclusion:

      P(E1E2)=P(E1)+P(E2)P(E1E2)P(E1)+P(E2)P(E_1 \cup E_2) = P(E_1) + P(E_2) - P(E_1 \cap E_2) \leq P(E_1) + P(E_2)

      since P(E1E2)0P(E_1 \cap E_2) \geq 0.

      By induction: assume true for n1n-1 events. Then:

      P(i=1nEi)=P(i=1n1Ei)+P(En)P(i=1n1EiEn)i=1n1P(Ei)+P(En)=i=1nP(Ei)P\left(\bigcup_{i=1}^{n} E_i\right) = P\left(\bigcup_{i=1}^{n-1} E_i\right) + P(E_n) - P\left(\bigcup_{i=1}^{n-1} E_i \cap E_n\right) \leq \sum_{i=1}^{n-1} P(E_i) + P(E_n) = \sum_{i=1}^{n} P(E_i)

      When is Equality Achieved?

      Equality holds when all EiE_i are mutually exclusive: when EiEj=E_i \cap E_j = \emptyset for all iji \neq j, the intersection terms vanish and the bound becomes exact.

      Why the Union Bound Matters

      The union bound provides a simple upper bound when:

      1. Exact probabilities are hard to compute
      2. We need to prove something is “small enough”
      3. Events may be dependent (union bound doesn’t require independence)

      It is often used in algorithm analysis and error bounds.

      Example: Hash Collisions

      A hash table has mm buckets. We insert nn keys. Let EiE_i be the event that key ii collides with some earlier key.

      The probability of at least one collision satisfies:

      P(some collision)i=1nP(Ei)P(\text{some collision}) \leq \sum_{i=1}^{n} P(E_i)

      If each key lands uniformly: P(Ei)i1mP(E_i) \leq \frac{i-1}{m}. Then:

      P(some collision)i=1ni1m=n(n1)2mP(\text{some collision}) \leq \sum_{i=1}^{n} \frac{i-1}{m} = \frac{n(n-1)}{2m}

      This is the birthday problem bound.

      Example: Error Bounds

      A system makes nn independent trials, each with error probability ϵ\epsilon. Let EiE_i = “error on trial ii”.

      P(at least one error)nϵP(\text{at least one error}) \leq n \epsilon

      If ϵ=1n2\epsilon = \frac{1}{n^2}, then P(error)1nP(\text{error}) \leq \frac{1}{n}.

      This is useful in probabilistic analysis: if each step has small error, the total error is bounded.

      Frechet Inequalities

      Related bounds for intersections:

      max{0,iP(Ei)(n1)}P(i=1nEi)miniP(Ei)\max\{0, \sum_i P(E_i) - (n-1)\} \leq P\left(\bigcap_{i=1}^{n} E_i\right) \leq \min_i P(E_i)

      The upper bound follows from monotonicity: EiEj\bigcap E_i \subseteq E_j for each jj, so P(Ei)P(Ej)P(\bigcap E_i) \leq P(E_j).

      Bonferroni Correction

      The union bound motivates multiple testing corrections. If we run nn hypothesis tests, each at significance level α\alpha, the probability of at least one false positive is at most nαn\alpha.

      To ensure overall error rate α\alpha, use threshold α/n\alpha/n for each test.

      Comparing with Exact Calculation

      ScenarioExactUnion Bound
      Mutually exclusiveP(Ei)\sum P(E_i)P(Ei)\sum P(E_i) (tight)
      Independent1(1P(Ei))1 - \prod(1-P(E_i))P(Ei)\sum P(E_i) (loose when P(Ei)P(E_i) not tiny)
      General caseInclusion-exclusionP(Ei)\sum P(E_i)

      The union bound is loosest when probabilities are large and events overlap significantly.

      Summary

      • Union bound: P(Ei)P(Ei)P(\bigcup E_i) \leq \sum P(E_i)
      • Equality when: events are mutually exclusive
      • Useful for: simpler analysis, error bounds, algorithm correctness proofs
      • Limitation: can be very loose for large probabilities and dependent events
    • Conditional Probability

      The Intuition

      New information changes probabilities. If we roll a die and learn the result is even, the probability of rolling 6 changes from 16\frac{1}{6} to 13\frac{1}{3}.

      Conditional probability formalises this: given that some event occurred, what is the probability of another?

      Definition

      The conditional probability of EE given FF (with P(F)>0P(F) > 0) is:

      P(EF)=P(EF)P(F)P(E \mid F) = \frac{P(E \cap F)}{P(F)}

      Interpretation: We restrict our attention to outcomes where FF occurs. The probability of EE is then the relative proportion of these outcomes that also lie in EE.

      Conditional probability as restricted sample space

      Equivalent Forms

      Rearranging:

      P(EF)=P(EF)P(F)P(E \cap F) = P(E \mid F) \cdot P(F)

      This is useful for computing joint probabilities: decompose into conditional times marginal.

      Similarly:

      P(EF)=P(FE)P(E)P(E \cap F) = P(F \mid E) \cdot P(E)

      Properties

      Conditional probability satisfies all probability axioms:

      • P(EF)0P(E \mid F) \geq 0 for all EE
      • P(ΩF)=1P(\Omega \mid F) = 1
      • P(iEiF)=iP(EiF)P(\bigcup_{i} E_i \mid F) = \sum_{i} P(E_i \mid F) for disjoint EiE_i

      Conditional on FF, we have a valid probability measure on the restricted sample space FF.

      Examples

      Example 1: Dice

      Roll two dice. Given that the sum is 7, what is the probability the first die shows 4?

      Let EE = “first die is 4”, FF = “sum is 7”. The outcomes in FF are: {(1,6),(2,5),(3,4),(4,3),(5,2),(6,1)}\{(1,6), (2,5), (3,4), (4,3), (5,2), (6,1)\}.

      Out of these 6 equally likely outcomes, only (4,3)(4,3) has first die 4.

      P(EF)=16P(E \mid F) = \frac{1}{6}

      Compare: P(E)=16P(E) = \frac{1}{6} (unconditionally). In this case, knowing the sum is 7 doesn’t change the probability.

      Example 2: Cards

      Draw two cards without replacement from a standard deck. Given the first card is a heart, what is the probability the second card is a heart?

      Let EE = “second card is a heart”, FF = “first card is a heart”.

      After drawing a heart first, 12 hearts remain out of 51 cards.

      P(EF)=1251=417P(E \mid F) = \frac{12}{51} = \frac{4}{17}

      Compare: P(E)=12P(E) = \frac{1}{2} (unconditionally, by symmetry).

      Example 3: Medical Tests

      A test for a disease has 99% sensitivity (true positive rate) and 95% specificity (true negative rate). Disease prevalence is 1%. What is the probability of having the disease given a positive test?

      Let DD = “has disease”, TT = “tests positive”.

      We want P(DT)P(D \mid T).

      P(DT)=P(TD)P(D)P(T)P(D \mid T) = \frac{P(T \mid D) \cdot P(D)}{P(T)}

      where P(T)=P(TD)P(D)+P(TDc)P(Dc)=0.99×0.01+0.05×0.99=0.0099+0.0495=0.0594P(T) = P(T \mid D) P(D) + P(T \mid D^c) P(D^c) = 0.99 \times 0.01 + 0.05 \times 0.99 = 0.0099 + 0.0495 = 0.0594

      P(DT)=0.99×0.010.05940.00990.059416.7%P(D \mid T) = \frac{0.99 \times 0.01}{0.0594} \approx \frac{0.0099}{0.0594} \approx 16.7\%

      Despite a positive test, there’s only a 16.7% chance of having the disease, due to low prevalence.

      The Chain Rule

      For multiple events:

      P(E1E2En)=P(E1)P(E2E1)P(E3E1E2)P(EnE1En1)P(E_1 \cap E_2 \cap \cdots \cap E_n) = P(E_1) \cdot P(E_2 \mid E_1) \cdot P(E_3 \mid E_1 \cap E_2) \cdots P(E_n \mid E_1 \cap \cdots \cap E_{n-1})

      This decomposes complex joint probabilities into simpler conditional probabilities.

      Example: Drawing Without Replacement

      Draw 3 cards from 52 without replacement. Probability all are spades:

      P(all spades)=135212511150=131211525150P(\text{all spades}) = \frac{13}{52} \cdot \frac{12}{51} \cdot \frac{11}{50} = \frac{13 \cdot 12 \cdot 11}{52 \cdot 51 \cdot 50}

      Common Misconceptions

      Confusion with Inverse

      P(EF)P(FE)P(E \mid F) \neq P(F \mid E) in general.

      In the medical test example:

      • P(TD)=0.99P(T \mid D) = 0.99 (sensitivity)
      • P(DT)0.167P(D \mid T) \approx 0.167 (much smaller)

      The Prosecutor’s Fallacy

      Confusing P(evidenceinnocent)P(\text{evidence} \mid \text{innocent}) with P(innocentevidence)P(\text{innocent} \mid \text{evidence}). A small false positive rate doesn’t guarantee a small probability of innocence.

      Conditioning as Restriction

      Conditional probability can be understood as:

      1. Restrict the sample space to FF
      2. Renormalise probabilities so they sum to 1

      For equally likely outcomes:

      P(EF)=EFFP(E \mid F) = \frac{|E \cap F|}{|F|}

      Count outcomes in EFE \cap F, divide by outcomes in FF.

      Summary

      ConceptFormula
      DefinitionP(EF)=P(EF)P(F)P(E \mid F) = \frac{P(E \cap F)}{P(F)}
      Product ruleP(EF)=P(EF)P(F)P(E \cap F) = P(E \mid F) P(F)
      Chain ruleP(E1En)=i=1nP(EiE1Ei1)P(E_1 \cap \cdots \cap E_n) = \prod_{i=1}^{n} P(E_i \mid E_1 \cap \cdots \cap E_{i-1})
    • The Law of Total Probability and Bayes' Theorem

      Law of Total Probability

      Statement

      Let F1,F2,,FnF_1, F_2, \ldots, F_n be a partition of Ω\Omega: mutually exclusive events that cover all possibilities. For any event EE:

      P(E)=i=1nP(EFi)P(Fi)P(E) = \sum_{i=1}^{n} P(E \mid F_i) \cdot P(F_i)

      Intuition

      To find the probability of EE, condition on which scenario FiF_i occurs and sum over all scenarios, weighting by the probability of each scenario.

      Law of total probability tree diagram

      Proof

      E=EΩ=Ei=1nFi=i=1n(EFi)E = E \cap \Omega = E \cap \bigcup_{i=1}^{n} F_i = \bigcup_{i=1}^{n} (E \cap F_i)

      Since FiF_i are disjoint, EFiE \cap F_i are also disjoint. By additivity:

      P(E)=i=1nP(EFi)=i=1nP(EFi)P(Fi)P(E) = \sum_{i=1}^{n} P(E \cap F_i) = \sum_{i=1}^{n} P(E \mid F_i) P(F_i)

      Example: Two Dice

      Roll two dice. Let EE = “sum is even”. Partition by first die being odd (F1F_1) or even (F2F_2).

      • P(F1)=P(F2)=12P(F_1) = P(F_2) = \frac{1}{2}
      • P(EF1)P(E \mid F_1) = first die odd, sum even \Rightarrow second die odd: 12\frac{1}{2}
      • P(EF2)P(E \mid F_2) = first die even, sum even \Rightarrow second die even: 12\frac{1}{2}

      P(E)=P(EF1)P(F1)+P(EF2)P(F2)=1212+1212=12P(E) = P(E \mid F_1) P(F_1) + P(E \mid F_2) P(F_2) = \frac{1}{2} \cdot \frac{1}{2} + \frac{1}{2} \cdot \frac{1}{2} = \frac{1}{2}

      Bayes’ Theorem

      Statement

      P(FE)=P(EF)P(F)P(E)P(F \mid E) = \frac{P(E \mid F) \cdot P(F)}{P(E)}

      Or, using the law of total probability for P(E)P(E):

      P(FE)=P(EF)P(F)iP(EFi)P(Fi)P(F \mid E) = \frac{P(E \mid F) \cdot P(F)}{\sum_i P(E \mid F_i) \cdot P(F_i)}

      Terminology

      • Prior P(F)P(F): probability before observing evidence EE
      • Posterior P(FE)P(F \mid E): updated probability after observing evidence EE
      • Likelihood P(EF)P(E \mid F): how likely is the evidence under hypothesis FF
      • Marginal likelihood P(E)P(E): normalising constant

      Bayes' theorem terminology

      Proof

      By definition of conditional probability:

      P(FE)=P(FE)P(E)=P(EF)P(E)=P(EF)P(F)P(E)P(F \mid E) = \frac{P(F \cap E)}{P(E)} = \frac{P(E \cap F)}{P(E)} = \frac{P(E \mid F) \cdot P(F)}{P(E)}

      Example: Medical Diagnosis

      A disease affects 1% of the population. A test has:

      • 99% sensitivity: P(positivedisease)=0.99P(\text{positive} \mid \text{disease}) = 0.99
      • 95% specificity: P(negativeno disease)=0.95P(\text{negative} \mid \text{no disease}) = 0.95

      What is P(diseasepositive)P(\text{disease} \mid \text{positive})?

      Let DD = disease, TT = positive test.

      P(DT)=P(TD)P(D)P(TD)P(D)+P(TDc)P(Dc)=0.99×0.010.99×0.01+0.05×0.99=0.00990.059416.7%P(D \mid T) = \frac{P(T \mid D) P(D)}{P(T \mid D) P(D) + P(T \mid D^c) P(D^c)} = \frac{0.99 \times 0.01}{0.99 \times 0.01 + 0.05 \times 0.99} = \frac{0.0099}{0.0594} \approx 16.7\%

      Interpretation: Even with a positive test, there’s only a 17% chance of having the disease (for rare diseases, most positives are false positives).

      Example: Monty Hall Problem

      You’re on a game show with 3 doors. One hides a prize. You pick door 1. The host opens door 2, revealing no prize. Should you switch to door 3?

      Let FiF_i = prize behind door ii. Initially P(F1)=P(F2)=P(F3)=13P(F_1) = P(F_2) = P(F_3) = \frac{1}{3}.

      Let EE = host opens door 2.

      Compute P(F1E)P(F_1 \mid E) and P(F3E)P(F_3 \mid E):

      • If F1F_1 (prize behind door 1), host randomly opens door 2 or 3: P(EF1)=12P(E \mid F_1) = \frac{1}{2}
      • If F2F_2 (prize behind door 2), host cannot open door 2: P(EF2)=0P(E \mid F_2) = 0
      • If F3F_3 (prize behind door 3), host must open door 2: P(EF3)=1P(E \mid F_3) = 1

      P(F1E)=12×1312×13+0+1×13=1616+13=13P(F_1 \mid E) = \frac{\frac{1}{2} \times \frac{1}{3}}{\frac{1}{2} \times \frac{1}{3} + 0 + 1 \times \frac{1}{3}} = \frac{\frac{1}{6}}{\frac{1}{6} + \frac{1}{3}} = \frac{1}{3}

      P(F3E)=1×1312=23P(F_3 \mid E) = \frac{1 \times \frac{1}{3}}{\frac{1}{2}} = \frac{2}{3}

      Conclusion: Switch to door 3 for a 23\frac{2}{3} chance of winning.

      Example: Quality Control

      Two factories produce light bulbs. Factory A supplies 60% of the market with 2% defect rate. Factory B supplies 40% with 5% defect rate. A bulb is defective. What is the probability it came from A?

      Let AA = from factory A, BB = from factory B, DD = defective.

      P(AD)=0.02×0.600.02×0.60+0.05×0.40=0.0120.012+0.020=0.0120.032=38P(A \mid D) = \frac{0.02 \times 0.60}{0.02 \times 0.60 + 0.05 \times 0.40} = \frac{0.012}{0.012 + 0.020} = \frac{0.012}{0.032} = \frac{3}{8}

      Sequential Bayesian Updating

      As more evidence arrives, today’s posterior becomes tomorrow’s prior. This is the foundation of Bayesian inference.

      Example: Disease Testing Repeat

      If we get two independent positive tests:

      P(DT1T2)P(T1T2D)P(D)=P(T1D)P(T2D)P(D)P(D \mid T_1 \cap T_2) \propto P(T_1 \cap T_2 \mid D) P(D) = P(T_1 \mid D) P(T_2 \mid D) P(D)

      Starting from prior P(D)=0.01P(D) = 0.01, after one positive test the posterior is 0.167\approx 0.167. This becomes the new prior for the second test.

      Summary

      ConceptFormula
      Total probabilityP(E)=iP(EFi)P(Fi)P(E) = \sum_i P(E \mid F_i) P(F_i)
      Bayes’ theoremP(FE)=P(EF)P(F)P(E)P(F \mid E) = \frac{P(E \mid F) P(F)}{P(E)}
      PriorP(F)P(F) before evidence
      PosteriorP(FE)P(F \mid E) after evidence
      LikelihoodP(EF)P(E \mid F) how likely evidence under hypothesis
    • Bayes' Theorem and Independence

      Bayes’ Theorem Review

      P(FE)=P(EF)P(F)P(E)P(F \mid E) = \frac{P(E \mid F) \cdot P(F)}{P(E)}

      This lets us reverse the direction of conditioning: from P(EF)P(E \mid F) to P(FE)P(F \mid E).

      Computational Form

      With partition F1,,FnF_1, \ldots, F_n:

      P(FiE)=P(EFi)P(Fi)j=1nP(EFj)P(Fj)P(F_i \mid E) = \frac{P(E \mid F_i) \cdot P(F_i)}{\sum_{j=1}^{n} P(E \mid F_j) \cdot P(F_j)}

      The denominator is the law of total probability applied to P(E)P(E).

      Example: Spam Filtering

      An email contains the word “free”. Historical data shows:

      • P("free"spam)=0.3P(\text{"free"} \mid \text{spam}) = 0.3
      • P("free"not spam)=0.05P(\text{"free"} \mid \text{not spam}) = 0.05
      • P(spam)=0.4P(\text{spam}) = 0.4

      P(spam"free")=0.3×0.40.3×0.4+0.05×0.6=0.120.12+0.03=0.120.15=0.8P(\text{spam} \mid \text{"free"}) = \frac{0.3 \times 0.4}{0.3 \times 0.4 + 0.05 \times 0.6} = \frac{0.12}{0.12 + 0.03} = \frac{0.12}{0.15} = 0.8

      An email with “free” has 80% probability of being spam.

      Independence of Events

      Definition

      Events EE and FF are independent if:

      P(EF)=P(E)P(F)P(E \cap F) = P(E) \cdot P(F)

      Equivalently (when P(F)>0P(F) > 0):

      P(EF)=P(E)P(E \mid F) = P(E)

      Knowing FF occurred gives no information about EE.

      Intuition

      Two events are independent if the occurrence of one tells us nothing about the occurrence of the other. The probability of EE is the same whether or not we know FF occurred.

      Example: Coin Flips

      Flip a fair coin twice. Let EE = “first is heads”, FF = “second is heads”.

      P(EF)=P(HH)=14=12×12=P(E)P(F)P(E \cap F) = P(HH) = \frac{1}{4} = \frac{1}{2} \times \frac{1}{2} = P(E) \cdot P(F)

      The outcomes are independent.

      Example: Dependent Events

      Draw two cards without replacement. Let EE = “first is ace”, FF = “second is ace”.

      P(EF)=452351=122652452452P(E \cap F) = \frac{4}{52} \cdot \frac{3}{51} = \frac{12}{2652} \neq \frac{4}{52} \cdot \frac{4}{52}

      Not independent: drawing an ace first changes the probability of drawing an ace second.

      Independent vs Mutually Exclusive

      Common confusion: Independence and mutual exclusivity are different concepts.

      PropertyE,FE, F disjoint (ME)E,FE, F independent
      Defining equationEF=E \cap F = \emptysetP(EF)=P(E)P(F)P(E \cap F) = P(E) P(F)
      ProbabilityP(EF)=0P(E \cap F) = 0P(EF)=P(E)P(F)>0P(E \cap F) = P(E) P(F) > 0 typically
      Knowing FF occurredEE cannot occurGives no info about EE

      Key insight: If EE and FF are both possible (positive probability) and mutually exclusive, they are NOT independent. Knowing FF occurred tells us EE did NOT occur.

      Mutual Independence

      Pairwise Independence

      Events E1,E2,,EnE_1, E_2, \ldots, E_n are pairwise independent if EiE_i and EjE_j are independent for all iji \neq j.

      This is weaker than mutual independence.

      Mutual Independence

      Events E1,E2,,EnE_1, E_2, \ldots, E_n are mutually independent if for every subset S{1,2,,n}S \subseteq \{1, 2, \ldots, n\}:

      P(iSEi)=iSP(Ei)P\left(\bigcap_{i \in S} E_i\right) = \prod_{i \in S} P(E_i)

      Important: Pairwise independence does NOT imply mutual independence.

      Example: Pairwise but Not Mutual

      Flip two fair coins. Define:

      • AA = first coin is heads
      • BB = second coin is heads
      • CC = coins match (both heads or both tails)

      Check independence:

      • P(A)=P(B)=P(C)=12P(A) = P(B) = P(C) = \frac{1}{2}
      • P(AB)=14=P(A)P(B)P(A \cap B) = \frac{1}{4} = P(A) P(B) (pairwise independent)
      • P(AC)=14=P(A)P(C)P(A \cap C) = \frac{1}{4} = P(A) P(C) (pairwise independent)
      • P(BC)=14=P(B)P(C)P(B \cap C) = \frac{1}{4} = P(B) P(C) (pairwise independent)

      But:

      • P(ABC)=14P(A \cap B \cap C) = \frac{1}{4} (only HH)
      • P(A)P(B)P(C)=18P(A) P(B) P(C) = \frac{1}{8}

      These events are pairwise independent but NOT mutually independent.

      Conditional Independence

      Events EE and FF are conditionally independent given GG if:

      P(EFG)=P(EG)P(FG)P(E \cap F \mid G) = P(E \mid G) \cdot P(F \mid G)

      Events can be independent unconditionally but dependent conditionally, or vice versa.

      Example: Berger’s Bullets

      Two shooters aim at a target. Let A,BA, B be “shooter A/B hits”. Unconditionally, AA and BB might be independent. But given the target is hit, knowing AA missed makes it more likely BB hit, creating dependence.

      Properties of Independence

      1. If EE and FF are independent, then so are EE and FcF^c.

        Proof: P(E)=P(EF)+P(EFc)=P(E)P(F)+P(EFc)P(E) = P(E \cap F) + P(E \cap F^c) = P(E) P(F) + P(E \cap F^c), so P(EFc)=P(E)P(E)P(F)=P(E)(1P(F))=P(E)P(Fc)P(E \cap F^c) = P(E) - P(E) P(F) = P(E)(1 - P(F)) = P(E) P(F^c).

      2. If EE and FF are independent, then EcE^c and FcF^c are independent.

      3. Independence is symmetric: EE independent of FF iff FF independent of EE.

      Application: System Reliability

      Components in series all must work. If each has reliability pp and failures are independent:

      P(system works)=pnP(\text{system works}) = p^n

      Components in parallel: at least one must work:

      P(system works)=1(1p)nP(\text{system works}) = 1 - (1-p)^n

      Summary

      ConceptDefinition
      IndependenceP(EF)=P(E)P(F)P(E \cap F) = P(E) P(F)
      Equivalent formP(EF)=P(E)P(E \mid F) = P(E) (when P(F)>0P(F) > 0)
      Mutual independenceP(iSEi)=iSP(Ei)P(\bigcap_{i \in S} E_i) = \prod_{i \in S} P(E_i) for all subsets SS
      Conditional independenceP(EFG)=P(EG)P(FG)P(E \cap F \mid G) = P(E \mid G) P(F \mid G)
  • Discrete Random Variables

    PMFs, expectation, variance, and discrete distributions

    • Random Variables

      What is a Random Variable?

      A random variable XX is a function from the sample space to the real numbers:

      X:ΩRX: \Omega \to \mathbb{R}

      Formally, it assigns a numerical value to each outcome.

      Why Functions?

      Outcomes (like “three coin flips”) are often complex or qualitative. Random variables let us work numerically: counting heads, summing dice, measuring time.

      Example: Coin Flips

      Flip three coins. The outcome is a sequence like {H,T,H}\{H, T, H\}. Define XX = number of heads.

      OutcomeXX
      HHH3
      HHT2
      HTH2
      HTT1
      THH2
      THT1
      TTH1
      TTT0

      Discrete vs Continuous Random Variables

      Discrete

      XX is discrete if it takes values from a finite or countably infinite set.

      Examples:

      • Number of heads in 10 flips: {0,1,2,,10}\{0, 1, 2, \ldots, 10\}
      • Rolls until first 6: {1,2,3,}\{1, 2, 3, \ldots\}
      • Number of customers arriving: {0,1,2,}\{0, 1, 2, \ldots\}

      Continuous

      XX is continuous if it can take any value in an interval.

      Examples:

      • Time until failure: [0,)[0, \infty)
      • Temperature: R\mathbb{R}
      • Height: [0,300][0, 300] cm

      Indicator Variables

      An indicator variable (or Bernoulli variable) for event EE is:

      IE={1if E occurs0otherwiseI_E = \begin{cases} 1 & \text{if } E \text{ occurs} \\ 0 & \text{otherwise} \end{cases}

      Properties

      E[IE]=0P(Ec)+1P(E)=P(E)E[I_E] = 0 \cdot P(E^c) + 1 \cdot P(E) = P(E)

      The expected value of an indicator equals the probability of the event.

      This is incredibly useful: to compute P(E)P(E), compute E[IE]E[I_E].

      Example: Matching Cards

      Shuffle a deck. What is the expected number of cards in their original position?

      Let IiI_i indicate card ii is in position ii. Then X=i=152IiX = \sum_{i=1}^{52} I_i counts matches.

      E[Ii]=P(card i in position i)=152E[I_i] = P(\text{card } i \text{ in position } i) = \frac{1}{52}

      By linearity:

      E[X]=i=152E[Ii]=52×152=1E[X] = \sum_{i=1}^{52} E[I_i] = 52 \times \frac{1}{52} = 1

      On average, exactly one card is in its original position, regardless of deck size.

      Types of Random Variables

      TypeValuesExample
      Indicator{0,1}\{0, 1\}Success/failure
      Binary{0,1}\{0, 1\} (or {1,1}\{-1, 1\})Yes/no outcomes
      Count{0,1,2,}\{0, 1, 2, \ldots\}Number of arrivals
      ContinuousReal intervalTime, weight

      Random Variables in Programming

      Think of a random variable like a variable in a programming language:

      • It has a type (discrete or continuous)
      • It has a range of possible values
      • It has a distribution describing likelihood of each value
      • It can be sampled to produce a concrete value

      Example in Context

      # X is a random variable
      # - Type: discrete
      # - Range: {1, 2, 3, 4, 5, 6}
      # - Distribution: uniform
      import random
      x = random.randint(1, 6)  # Sample a value

      Functions of Random Variables

      If XX is a random variable and gg is a function, then Y=g(X)Y = g(X) is also a random variable.

      Example: If XX is the roll of a die, then Y=2X+1Y = 2X + 1 takes values {3,5,7,9,11,13}\{3, 5, 7, 9, 11, 13\}.

      Summary

      ConceptDefinition
      Random variableFunction ΩR\Omega \to \mathbb{R}
      Discrete RVTakes countably many values
      Continuous RVTakes values in an interval
      IndicatorIE={1E occurs0otherwiseI_E = \begin{cases} 1 & E \text{ occurs} \\ 0 & \text{otherwise} \end{cases}
    • Probability Mass Functions

      Definition

      For a discrete random variable XX, the probability mass function (PMF) gives the probability of each possible value:

      p(x)=P(X=x)p(x) = P(X = x)

      The function pp completely describes the distribution of XX.

      Properties

      A valid PMF satisfies:

      1. Non-negativity: p(x)0p(x) \geq 0 for all xx

      2. Sums to 1: xp(x)=1\sum_{x} p(x) = 1 (over all possible values)

      3. Probability computation: For any event EE:

      P(XE)=xEp(x)P(X \in E) = \sum_{x \in E} p(x)

      Example: Fair Die

      For a fair six-sided die:

      xxp(x)p(x)
      11/61/6
      21/61/6
      31/61/6
      41/61/6
      51/61/6
      61/61/6

      p(x)=16 for x{1,2,3,4,5,6}p(x) = \frac{1}{6} \text{ for } x \in \{1, 2, 3, 4, 5, 6\}

      Example: Biased Coin

      A biased coin shows heads with probability pp. Let XX = number of heads in one flip.

      xxP(X=x)P(X = x)
      01p1 - p
      1pp

      The PMF: p(0)=1pp(0) = 1 - p, p(1)=pp(1) = p.

      Example: Two Dice Sum

      Roll two fair dice. Let XX = sum of the dice. Values range from 2 to 12.

      xxOutcomesp(x)p(x)
      2(1,1)1/361/36
      3(1,2), (2,1)2/362/36
      4(1,3), (2,2), (3,1)3/363/36
      5(1,4), (2,3), (3,2), (4,1)4/364/36
      65/365/36
      76/366/36
      85/365/36
      94/364/36
      103/363/36
      112/362/36
      121/361/36

      Notice the symmetry around 7.

      PMF for sum of two dice

      Computing with PMFs

      To find P(Xa)P(X \leq a):

      P(Xa)=xap(x)P(X \leq a) = \sum_{x \leq a} p(x)

      To find P(aXb)P(a \leq X \leq b):

      P(aXb)=x=abp(x)P(a \leq X \leq b) = \sum_{x=a}^{b} p(x)

      Example

      For the dice sum: P(X10)=P(X=10)+P(X=11)+P(X=12)=336+236+136=636=16P(X \geq 10) = P(X = 10) + P(X = 11) + P(X = 12) = \frac{3}{36} + \frac{2}{36} + \frac{1}{36} = \frac{6}{36} = \frac{1}{6}.

      Support

      The support of XX is the set of values where p(x)>0p(x) > 0:

      supp(X)={x:p(x)>0}\text{supp}(X) = \{x : p(x) > 0\}

      For a fair die: supp(X)={1,2,3,4,5,6}\text{supp}(X) = \{1, 2, 3, 4, 5, 6\}.

      Visualising PMFs

      PMFs are often shown as bar charts, with bar heights representing probabilities. The total height of all bars equals 1.

      PMF visualisation

      Joint PMFs

      For two discrete random variables XX and YY, the joint PMF is:

      p(x,y)=P(X=x,Y=y)p(x, y) = P(X = x, Y = y)

      It satisfies:

      xyp(x,y)=1\sum_{x} \sum_{y} p(x, y) = 1

      The marginal PMF of XX is:

      pX(x)=yp(x,y)p_X(x) = \sum_{y} p(x, y)

      Summary

      ConceptFormula
      PMF definitionp(x)=P(X=x)p(x) = P(X = x)
      Normalisationxp(x)=1\sum_x p(x) = 1
      Event probabilityP(XE)=xEp(x)P(X \in E) = \sum_{x \in E} p(x)
      Support{x:p(x)>0}\{x : p(x) > 0\}
    • Cumulative Distribution Functions

      Definition

      The cumulative distribution function (CDF) of a random variable XX is:

      F(x)=P(Xx)F(x) = P(X \leq x)

      It gives the probability that XX is less than or equal to xx.

      Why CDFs?

      The CDF has advantages over the PMF/PDF:

      1. It exists for all random variables (discrete, continuous, or mixed)
      2. It completely determines the distribution
      3. It can be estimated empirically from data
      4. Probabilities are computed by subtraction rather than summation

      Properties

      Every CDF FF satisfies:

      1. Non-decreasing

      If a<ba < b, then F(a)F(b)F(a) \leq F(b).

      Reason: As xx increases, we accumulate more probability.

      2. Limits

      limxF(x)=0,limx+F(x)=1\lim_{x \to -\infty} F(x) = 0, \quad \lim_{x \to +\infty} F(x) = 1

      3. Right-Continuous

      limyxF(y)=F(x)\lim_{y \downarrow x} F(y) = F(x)

      For discrete RVs, this means the CDF jumps at the value, not before.

      Bounds

      0F(x)1 for all x0 \leq F(x) \leq 1 \text{ for all } x

      Computing Probabilities

      Using the CDF:

      P(a<Xb)=F(b)F(a)P(a < X \leq b) = F(b) - F(a)

      P(X>x)=1F(x)P(X > x) = 1 - F(x)

      P(X<x)=F(x) (left-limit)P(X < x) = F(x^-) \text{ (left-limit)}

      For discrete RVs with jump at aa:

      P(X=a)=F(a)F(a)P(X = a) = F(a) - F(a^-)

      The size of the jump at aa equals P(X=a)P(X = a).

      Example: Fair Die

      For a fair die, the possible outcomes are 1,2,3,4,5,6\\{1, 2, 3, 4, 5, 6\\}.

      F(x)={0x<1161x<2262x<3363x<4464x<5565x<61x6F(x) = \begin{cases} 0 & x < 1 \\ \frac{1}{6} & 1 \leq x < 2 \\ \frac{2}{6} & 2 \leq x < 3 \\ \frac{3}{6} & 3 \leq x < 4 \\ \frac{4}{6} & 4 \leq x < 5 \\ \frac{5}{6} & 5 \leq x < 6 \\ 1 & x \geq 6 \end{cases}

      This is a step function: flat between values, jumps at each possible outcome.

      CDF for fair die

      Example: Dice Sum

      For sum of two dice, X{2,3,,12}X \in \{2, 3, \ldots, 12\}.

      F(6)=P(X6)=1+2+3+4+536=1536=512F(6) = P(X \leq 6) = \frac{1+2+3+4+5}{36} = \frac{15}{36} = \frac{5}{12}

      F(7)=F(6)+P(X=7)=1536+636=2136=712F(7) = F(6) + P(X = 7) = \frac{15}{36} + \frac{6}{36} = \frac{21}{36} = \frac{7}{12}

      Relation to PMF

      For discrete random variables:

      F(x)=yxp(y)F(x) = \sum_{y \leq x} p(y)

      Conversely:

      p(x)=F(x)F(x)=P(X=x)p(x) = F(x) - F(x^-) = P(X = x)

      The PMF is the “derivative” of the CDF (in discrete sense).

      Example: Geometric CDF

      For XGeo(p)X \sim \text{Geo}(p) (geometric distribution):

      F(n)=P(Xn)=1(1p)nF(n) = P(X \leq n) = 1 - (1-p)^n

      Derivation: The event XnX \leq n is equivalent to “at least one success in first nn trials”, which has probability 1P(no successes)=1(1p)n1 - P(\text{no successes}) = 1 - (1-p)^n.

      Percentiles

      The ppth percentile (or quantile) is the value xpx_p such that:

      F(xp)=pF(x_p) = p

      Or more carefully: inf{x:F(x)p}\inf\{x : F(x) \geq p\}.

      Example: The median is the 50th percentile: F(x0.5)=0.5F(x_{0.5}) = 0.5.

      Empirical CDF

      Given data x1,x2,,xnx_1, x_2, \ldots, x_n, the empirical CDF is:

      F^(x)=1n{i:xix}\hat{F}(x) = \frac{1}{n} \cdot |\{i : x_i \leq x\}|

      This is the proportion of observations at or below xx.

      By the Glivenko-Cantelli theorem, as nn \to \infty, the empirical CDF converges uniformly to the true CDF.

      Summary

      PropertyDescription
      DefinitionF(x)=P(Xx)F(x) = P(X \leq x)
      Monotonicitya<bF(a)F(b)a < b \Rightarrow F(a) \leq F(b)
      LimitsF()=0F(-\infty) = 0, F(+)=1F(+\infty) = 1
      Jump sizeP(X=x)=F(x)F(x)P(X = x) = F(x) - F(x^-)
      Interval probP(a<Xb)=F(b)F(a)P(a < X \leq b) = F(b) - F(a)
    • Expectation

      Definition

      The expected value (or expectation, mean) of a discrete random variable XX is:

      E[X]=xxp(x)E[X] = \sum_{x} x \cdot p(x)

      where the sum is over all values in the support of XX.

      Interpretation: The long-run average if we repeatedly sample from XX.

      Intuition

      The expectation is a weighted average of possible values, weighted by their probabilities. Values that occur more often contribute more to the average.

      Example: Fair Die

      E[X]=i=16i16=1+2+3+4+5+66=216=3.5E[X] = \sum_{i=1}^{6} i \cdot \frac{1}{6} = \frac{1+2+3+4+5+6}{6} = \frac{21}{6} = 3.5

      Note: 3.5 is not a possible outcome. The expectation need not be a value XX can take.

      Example: Biased Coin

      Let XX = number of heads in one flip, with P(X=1)=pP(X=1) = p.

      E[X]=0(1p)+1p=pE[X] = 0 \cdot (1-p) + 1 \cdot p = p

      The expected number of heads equals the success probability.

      Example: Lottery

      A lottery ticket costs £2. With probability 10610^{-6}, it wins £1{,}000{,}000. Otherwise, it wins £0.

      E[winnings]=106×106+(1106)×0=1E[\text{winnings}] = 10^{-6} \times 10^6 + (1 - 10^{-6}) \times 0 = 1

      Expected winnings: £1. Expected profit: £1 - £2 = -£1 (a loss).

      Does Expectation Always Exist?

      Not always. The expectation requires:

      xxp(x)<\sum_{x} |x| \cdot p(x) < \infty

      If XX can take values with x|x| so large that the weighted sum diverges, expectation does not exist.

      Example: The Cauchy distribution has no finite expectation: its tails are too heavy.

      Properties

      1. Constant

      E[c]=cE[c] = c

      for any constant cc.

      2. Monotonicity

      If XYX \leq Y (with probability 1), then E[X]E[Y]E[X] \leq E[Y].

      3. Non-negativity Preservation

      If X0X \geq 0 (with probability 1), then E[X]0E[X] \geq 0.

      Interpretations

      Physical: Centre of Mass

      Place masses p(x)p(x) at positions xx on a line. The expectation is the centre of mass: the balance point.

      Expectation as centre of mass

      Financial: Fair Price

      If you pay E[X]E[X] to play a game with payout XX, you break even on average. This is the “fair price.”

      Statistical: Sample Mean

      By the Law of Large Numbers, the sample mean Xˉn=1ni=1nXi\bar{X}_n = \frac{1}{n}\sum_{i=1}^n X_i converges to E[X]E[X] as nn \to \infty.

      Expectation of Functions

      For a function gg:

      E[g(X)]=xg(x)p(x)E[g(X)] = \sum_{x} g(x) \cdot p(x)

      Note: In general, E[g(X)]g(E[X])E[g(X)] \neq g(E[X]). The expectation of a function is not the function of the expectation.

      Example: Squared Die

      E[X2]=i=16i216=1+4+9+16+25+366=91615.17E[X^2] = \sum_{i=1}^{6} i^2 \cdot \frac{1}{6} = \frac{1+4+9+16+25+36}{6} = \frac{91}{6} \approx 15.17

      Compare: E[X]2=3.52=12.25E[X]^2 = 3.5^2 = 12.25. Not equal.

      Jensen’s Inequality

      For a convex function gg:

      E[g(X)]g(E[X])E[g(X)] \geq g(E[X])

      For a concave function gg:

      E[g(X)]g(E[X])E[g(X)] \leq g(E[X])

      Example: g(x)=x2g(x) = x^2 is convex, so E[X2]E[X]2E[X^2] \geq E[X]^2.

      Summary

      ConceptFormula
      DefinitionE[X]=xxp(x)E[X] = \sum_x x \cdot p(x)
      ConstantE[c]=cE[c] = c
      FunctionE[g(X)]=xg(x)p(x)E[g(X)] = \sum_x g(x) p(x)
      Centre of massPhysical interpretation
    • Linearity of Expectation

      The Linearilty Property

      Expectation preserves linearity. For any random variables XX and YY, and constants aa and bb:

      E[aX+b]=aE[X]+bE[aX + b] = aE[X] + b

      E[X+Y]=E[X]+E[Y]E[X + Y] = E[X] + E[Y]

      E[aX+bY]=aE[X]+bE[Y]E[aX + bY] = aE[X] + bE[Y]

      Crucially: XX and YY need NOT be independent. Linearity holds regardless of dependence.

      Proof for Constants

      E[aX+b]=x(ax+b)p(x)=axxp(x)+bxp(x)=aE[X]+b1=aE[X]+bE[aX + b] = \sum_x (ax + b) p(x) = a\sum_x x p(x) + b\sum_x p(x) = aE[X] + b \cdot 1 = aE[X] + b

      Proof for Sum of Two Variables

      For discrete XX and YY:

      E[X+Y]=xy(x+y)p(x,y)=xyxp(x,y)+xyyp(x,y)E[X + Y] = \sum_x \sum_y (x + y) p(x, y) = \sum_x \sum_y x p(x, y) + \sum_x \sum_y y p(x, y)

      =xxyp(x,y)+yyxp(x,y)=xxpX(x)+yypY(y)=E[X]+E[Y]= \sum_x x \sum_y p(x, y) + \sum_y y \sum_x p(x, y) = \sum_x x p_X(x) + \sum_y y p_Y(y) = E[X] + E[Y]

      Why This Matters

      Linearity is perhaps the most useful property of expectation. Many problems that would otherwise be intractable become straightforward.

      Example: Transformed Die

      Roll a fair die. Let Y=3X+1Y = 3X + 1.

      We could compute E[Y]E[Y] directly: values are {4,7,10,13,16,19}\{4, 7, 10, 13, 16, 19\} with equal probability, giving E[Y]=4+7+10+13+16+196=696=11.5E[Y] = \frac{4+7+10+13+16+19}{6} = \frac{69}{6} = 11.5.

      But using linearity:

      E[Y]=E[3X+1]=3E[X]+1=3(3.5)+1=11.5E[Y] = E[3X + 1] = 3E[X] + 1 = 3(3.5) + 1 = 11.5

      Indicator Trick

      Many problems become easy by expressing the quantity of interest as a sum of indicators.

      Example: Matching Problem

      nn people throw hats into a pile, then each picks one randomly. Expected number who get their own hat?

      Let IiI_i = indicator that person ii gets their own hat. Then:

      X=i=1nIiX = \sum_{i=1}^{n} I_i

      is the number of matches.

      E[Ii]=P(person i gets own hat)=1nE[I_i] = P(\text{person } i \text{ gets own hat}) = \frac{1}{n}

      By linearity:

      E[X]=i=1nE[Ii]=n1n=1E[X] = \sum_{i=1}^{n} E[I_i] = n \cdot \frac{1}{n} = 1

      Regardless of nn, the expected number of matches is 1.

      Example: Expected Number of Aces

      Draw 5 cards from a standard deck. Expected number of aces?

      Let IiI_i = indicator that card ii is an ace.

      E[Ii]=P(card i is ace)=452=113E[I_i] = P(\text{card } i \text{ is ace}) = \frac{4}{52} = \frac{1}{13}

      E[number of aces]=i=15E[Ii]=5113=513E[\text{number of aces}] = \sum_{i=1}^{5} E[I_i] = 5 \cdot \frac{1}{13} = \frac{5}{13}

      Example: Email Spam

      100 emails, each independently has probability 0.4 of being spam. Expected number of spam emails?

      Let IiI_i indicate email ii is spam.

      E[Ii]=0.4E[I_i] = 0.4

      E[spam count]=100×0.4=40E[\text{spam count}] = 100 \times 0.4 = 40

      Linearity Extends to nn Variables

      By induction:

      E[i=1nXi]=i=1nE[Xi]E\left[\sum_{i=1}^{n} X_i\right] = \sum_{i=1}^{n} E[X_i]

      Regardless of dependence among the XiX_i.

      Caution: Products and Functions

      Linearity does NOT extend to products:

      E[XY]E[X]E[Y] in generalE[XY] \neq E[X] E[Y] \text{ in general}

      Equality holds if XX and YY are independent.

      Linearity does NOT extend to arbitrary functions:

      E[g(X)]g(E[X]) in generalE[g(X)] \neq g(E[X]) \text{ in general}

      Counterexample: E[X2]E[X]2E[X^2] \neq E[X]^2 for a die roll.

      Application: Sums of Identical Distributions

      If X1,X2,,XnX_1, X_2, \ldots, X_n are i.i.d. with mean μ\mu:

      E[X1+X2++Xn]=nμE[X_1 + X_2 + \cdots + X_n] = n\mu

      This is the foundation of the Law of Large Numbers.

      Probabilistic Method

      Linearity enables the probabilistic method: to prove existence of an object with property PP, show E[X]>0E[X] > 0 for some non-negative random variable XX, where X>0X > 0 implies property PP. Then there must exist some outcome with X>0X > 0.

      Summary

      PropertyFormula
      Scaling and shiftE[aX+b]=aE[X]+bE[aX + b] = aE[X] + b
      AdditivityE[X+Y]=E[X]+E[Y]E[X + Y] = E[X] + E[Y]
      GeneralE[iXi]=iE[Xi]E[\sum_i X_i] = \sum_i E[X_i]
      No independence neededHolds for dependent variables
    • LOTUS and Moments

      LOTUS: Law of the Unconscious Statistician

      When computing E[g(X)]E[g(X)], you might think we need the distribution of Y=g(X)Y = g(X) first. LOTUS says no: we can compute directly using the distribution of XX.

      Statement: For a discrete random variable XX:

      E[g(X)]=xg(x)p(x)E[g(X)] = \sum_{x} g(x) \cdot p(x)

      For a continuous random variable XX:

      E[g(X)]=g(x)f(x)dxE[g(X)] = \int_{-\infty}^{\infty} g(x) f(x) \, dx

      Why “unconscious”? Many people apply this “unconsciously” without realising it’s a theorem requiring proof.

      Proof (Discrete Case)

      Let Y=g(X)Y = g(X). By definition:

      E[Y]=yyP(Y=y)=yyP(g(X)=y)E[Y] = \sum_y y \cdot P(Y = y) = \sum_y y \cdot P(g(X) = y)

      But P(g(X)=y)=x:g(x)=yp(x)P(g(X) = y) = \sum_{x: g(x) = y} p(x). So:

      E[Y]=yyx:g(x)=yp(x)=yx:g(x)=yyp(x)=yx:g(x)=yg(x)p(x)E[Y] = \sum_y y \sum_{x: g(x) = y} p(x) = \sum_y \sum_{x: g(x) = y} y \cdot p(x) = \sum_y \sum_{x: g(x) = y} g(x) \cdot p(x)

      Each xx appears exactly once (grouped by the value g(x)g(x)), giving:

      E[Y]=xg(x)p(x)E[Y] = \sum_x g(x) \cdot p(x)

      Why LOTUS Matters

      Instead of finding the PMF/PDF of Y=g(X)Y = g(X), we compute directly. This is often much easier.

      Example: Squared Die

      XX = fair die roll. Find E[X2]E[X^2].

      Without LOTUS: Find distribution of X2X^2 (values {1,4,9,16,25,36}\{1, 4, 9, 16, 25, 36\}), then compute expectation.

      With LOTUS:

      E[X2]=i=16i216=1+4+9+16+25+366=916E[X^2] = \sum_{i=1}^{6} i^2 \cdot \frac{1}{6} = \frac{1 + 4 + 9 + 16 + 25 + 36}{6} = \frac{91}{6}

      Moments

      nth Moment

      The nnth moment of XX is:

      E[Xn]=xxnp(x)E[X^n] = \sum_x x^n \cdot p(x)

      The first moment is the expectation: E[X]E[X].

      Central Moments

      The nnth central moment is:

      E[(XE[X])n]E[(X - E[X])^n]

      The second central moment is the variance.

      Common Functions

      Linear Function

      E[aX+b]=aE[X]+bE[aX + b] = aE[X] + b

      This follows from linearity, not specifically LOTUS.

      Positive Powers

      E[Xn]=xxnp(x)E[X^n] = \sum_x x^n p(x)

      Used for computing variance and higher moments.

      Absolute Value

      E[X]=xxp(x)E[|X|] = \sum_x |x| p(x)

      The expectation of X|X| is called the mean absolute deviation from zero.

      Example: E[2X]E[2^X]

      If XX ~ Binomial(nn, pp), find E[2X]E[2^X].

      By LOTUS:

      E[2X]=k=0n2k(nk)pk(1p)nk=k=0n(nk)(2p)k(1p)nkE[2^X] = \sum_{k=0}^{n} 2^k \binom{n}{k} p^k (1-p)^{n-k} = \sum_{k=0}^{n} \binom{n}{k} (2p)^k (1-p)^{n-k}

      This is the binomial expansion of (2p+(1p))n=(1+p)n(2p + (1-p))^n = (1 + p)^n.

      E[2X]=(1+p)nE[2^X] = (1 + p)^n

      Probability Generating Functions

      For a non-negative integer-valued random variable XX, the probability generating function is:

      GX(t)=E[tX]=k=0tkP(X=k)G_X(t) = E[t^X] = \sum_{k=0}^{\infty} t^k P(X = k)

      This is LOTUS with g(x)=txg(x) = t^x.

      Key property: P(X=k)=GX(k)(0)k!P(X = k) = \frac{G_X^{(k)}(0)}{k!} (the kkth derivative at 0).

      Variance via LOTUS

      Var(X)=E[X2]E[X]2\text{Var}(X) = E[X^2] - E[X]^2

      LOTUS computes E[X2]E[X^2] directly.

      For a fair die:

      Var(X)=E[X2]E[X]2=916(72)2=916494=18214712=3512\text{Var}(X) = E[X^2] - E[X]^2 = \frac{91}{6} - \left(\frac{7}{2}\right)^2 = \frac{91}{6} - \frac{49}{4} = \frac{182 - 147}{12} = \frac{35}{12}

      Summary

      ConceptFormula
      LOTUS (discrete)E[g(X)]=xg(x)p(x)E[g(X)] = \sum_x g(x) p(x)
      LOTUS (continuous)E[g(X)]=g(x)f(x)dxE[g(X)] = \int g(x) f(x) dx
      nnth momentE[Xn]E[X^n]
      nnth central momentE[(XE[X])n]E[(X - E[X])^n]
      PGFG(t)=E[tX]G(t) = E[t^X]
    • Variance and Standard Deviation

      Spread in Distributions

      The expectation E[X]E[X] gives the centre of a distribution, but says nothing about spread. Two distributions can have the same mean but very different variability.

      Example: All three distributions below have mean 3, but very different spread:

      ValueDist ADist BDist C
      101/30
      2000
      311/30
      4000
      501/31
      • A is concentrated at 3 (no spread)
      • B spreads evenly across 1, 3, 5 (medium spread)
      • C spreads to 3 and 5 (different spread)

      We need a measure of spread.

      Variance

      Definition

      The variance of XX is:

      Var(X)=E[(Xμ)2]\text{Var}(X) = E[(X - \mu)^2]

      where μ=E[X]\mu = E[X]. This is the expected squared deviation from the mean.

      Properties:

      • Variance 0\geq 0
      • Variance =0= 0 iff XX is constant (almost surely)
      • Variance increases as values spread out from the mean

      Computational Formula

      Var(X)=E[X2]E[X]2\text{Var}(X) = E[X^2] - E[X]^2

      Proof:

      E[(Xμ)2]=E[X22μX+μ2]=E[X2]2μE[X]+μ2=E[X2]2μ2+μ2=E[X2]μ2E[(X - \mu)^2] = E[X^2 - 2\mu X + \mu^2] = E[X^2] - 2\mu E[X] + \mu^2 = E[X^2] - 2\mu^2 + \mu^2 = E[X^2] - \mu^2

      This formula is often easier: compute E[X]E[X] and E[X2]E[X^2], then subtract.

      Standard Deviation

      The standard deviation is the square root of variance:

      σX=Var(X)\sigma_X = \sqrt{\text{Var}(X)}

      Why take the square root? Variance has units of X2X^2. Standard deviation returns to the original units.

      If XX is in metres, Var(X)\text{Var}(X) is in square metres, but σX\sigma_X is in metres.

      Example: Fair Die

      E[X]=72,E[X2]=916E[X] = \frac{7}{2}, \quad E[X^2] = \frac{91}{6}

      Var(X)=916494=18214712=35122.92\text{Var}(X) = \frac{91}{6} - \frac{49}{4} = \frac{182 - 147}{12} = \frac{35}{12} \approx 2.92

      σX=35121.71\sigma_X = \sqrt{\frac{35}{12}} \approx 1.71

      Properties of Variance

      1. Constants

      Var(c)=0\text{Var}(c) = 0

      Var(X+c)=Var(X)\text{Var}(X + c) = \text{Var}(X)

      Adding a constant shifts the distribution but doesn’t change spread.

      2. Scaling

      Var(aX)=a2Var(X)\text{Var}(aX) = a^2 \text{Var}(X)

      Proof: Var(aX)=E[(aX)2]E[aX]2=a2E[X2]a2E[X]2=a2Var(X)\text{Var}(aX) = E[(aX)^2] - E[aX]^2 = a^2 E[X^2] - a^2 E[X]^2 = a^2 \text{Var}(X).

      3. Sum of Independent Variables

      If XX and YY are independent:

      Var(X+Y)=Var(X)+Var(Y)\text{Var}(X + Y) = \text{Var}(X) + \text{Var}(Y)

      Warning: This requires independence! Without it:

      Var(X+Y)=Var(X)+Var(Y)+2Cov(X,Y)\text{Var}(X + Y) = \text{Var}(X) + \text{Var}(Y) + 2\text{Cov}(X, Y)

      4. General Sum Formula

      Var(X+Y)=Var(X)+Var(Y)+2E[(XE[X])(YE[Y])]\text{Var}(X + Y) = \text{Var}(X) + \text{Var}(Y) + 2 E[(X - E[X])(Y - E[Y])]

      The last term is twice the covariance.

      Example: Sums of I.I.D. Variables

      Let X1,X2,,XnX_1, X_2, \ldots, X_n be i.i.d. with variance σ2\sigma^2. What is Var(Xi)\text{Var}(\sum X_i)?

      By independence:

      Var(X1++Xn)=nσ2\text{Var}(X_1 + \cdots + X_n) = n\sigma^2

      For the average Xˉ=1nXi\bar{X} = \frac{1}{n}\sum X_i:

      Var(Xˉ)=Var(1nXi)=1n2nσ2=σ2n\text{Var}(\bar{X}) = \text{Var}\left(\frac{1}{n}\sum X_i\right) = \frac{1}{n^2} \cdot n\sigma^2 = \frac{\sigma^2}{n}

      Interpretation: Averaging reduces variance. More samples = more precise estimate.

      Chebyshev’s Inequality Preview

      Variance bounds how often XX deviates far from μ\mu. Chebyshev’s inequality:

      P(Xμkσ)1k2P(|X - \mu| \geq k\sigma) \leq \frac{1}{k^2}

      At most 1/91/9 of the distribution lies more than 3 standard deviations from the mean, for any distribution.

      Summary

      QuantityFormula
      VarianceVar(X)=E[(Xμ)2]\text{Var}(X) = E[(X - \mu)^2]
      ComputationalVar(X)=E[X2]E[X]2\text{Var}(X) = E[X^2] - E[X]^2
      Standard deviationσX=Var(X)\sigma_X = \sqrt{\text{Var}(X)}
      ScalingVar(aX)=a2Var(X)\text{Var}(aX) = a^2 \text{Var}(X)
      Shift invariantVar(X+c)=Var(X)\text{Var}(X + c) = \text{Var}(X)
      Independent sumVar(X+Y)=Var(X)+Var(Y)\text{Var}(X + Y) = \text{Var}(X) + \text{Var}(Y)
    • Bernoulli and Binomial Distributions

      Bernoulli Distribution

      Definition

      A random variable XX follows the Bernoulli distribution with parameter pp if:

      P(X=1)=p,P(X=0)=1pP(X = 1) = p, \quad P(X = 0) = 1 - p

      Write: XBern(p)X \sim \text{Bern}(p).

      Context: Models a single trial with two outcomes: success (1) with probability pp, or failure (0) with probability 1p1-p.

      PMF

      p(x)={1px=0px=10otherwisep(x) = \begin{cases} 1 - p & x = 0 \\ p & x = 1 \\ 0 & \text{otherwise} \end{cases}

      Or compactly: p(x)=px(1p)1xp(x) = p^x(1-p)^{1-x} for x{0,1}x \in \{0,1\}.

      Expectation

      E[X]=0(1p)+1p=pE[X] = 0 \cdot (1-p) + 1 \cdot p = p

      Variance

      E[X2]=02(1p)+12p=pE[X^2] = 0^2 \cdot (1-p) + 1^2 \cdot p = p

      Var(X)=E[X2]E[X]2=pp2=p(1p)\text{Var}(X) = E[X^2] - E[X]^2 = p - p^2 = p(1-p)

      Examples

      • Coin flip: XBern(0.5)X \sim \text{Bern}(0.5) for a fair coin
      • Defective item: XBern(0.02)X \sim \text{Bern}(0.02) if 2% are defective
      • Pass/fail: XBern(p)X \sim \text{Bern}(p) where pp is pass rate

      Binomial Distribution

      Definition

      XBin(n,p)X \sim \text{Bin}(n, p) if XX counts the number of successes in nn independent Bernoulli trials, each with success probability pp.

      PMF

      P(X=k)=(nk)pk(1p)nk,k=0,1,,nP(X = k) = \binom{n}{k} p^k (1-p)^{n-k}, \quad k = 0, 1, \ldots, n

      Why this formula?

      • Choose which kk of nn trials are successes: (nk)\binom{n}{k} ways
      • Each such arrangement has probability pk(1p)nkp^k (1-p)^{n-k}

      Range

      X{0,1,2,,n}X \in \{0, 1, 2, \ldots, n\}

      Expectation

      Let X=X1+X2++XnX = X_1 + X_2 + \cdots + X_n where XiBern(p)X_i \sim \text{Bern}(p) are independent.

      E[X]=E[X1]++E[Xn]=npE[X] = E[X_1] + \cdots + E[X_n] = np

      Intuition: If each trial succeeds with probability pp, expect npnp successes in nn trials.

      Variance

      Since the XiX_i are independent:

      Var(X)=Var(X1)++Var(Xn)=np(1p)\text{Var}(X) = \text{Var}(X_1) + \cdots + \text{Var}(X_n) = n \cdot p(1-p)

      Shape

      • For small pp: distribution is skewed right (concentration near 0)
      • For p=0.5p = 0.5: symmetric around n/2n/2
      • For large pp: distribution is skewed left (concentration near nn)

      Binomial PMF shapes

      Example: Coin Flips

      Flip a fair coin 100 times. Expected number of heads?

      XBin(100,0.5)X \sim \text{Bin}(100, 0.5)

      E[X]=100×0.5=50E[X] = 100 \times 0.5 = 50 Var(X)=100×0.5×0.5=25\text{Var}(X) = 100 \times 0.5 \times 0.5 = 25 σX=5\sigma_X = 5

      Example: Quality Control

      A factory produces items with 2% defect rate. In a sample of 200, what is the probability of exactly 3 defects?

      XBin(200,0.02)X \sim \text{Bin}(200, 0.02)

      P(X=3)=(2003)(0.02)3(0.98)197P(X = 3) = \binom{200}{3} (0.02)^3 (0.98)^{197}

      Compute: (2003)=2001991986=1,313,400\binom{200}{3} = \frac{200 \cdot 199 \cdot 198}{6} = 1{,}313{,}400

      P(X=3)1,313,400×0.000008×0.0180.19P(X = 3) \approx 1{,}313{,}400 \times 0.000008 \times 0.018 \approx 0.19

      Relation Between Bernoulli and Binomial

      The sum of nn independent Bern(p)\text{Bern}(p) variables is Bin(n,p)\text{Bin}(n, p):

      i=1nBern(p)=Bin(n,p)\sum_{i=1}^{n} \text{Bern}(p) = \text{Bin}(n, p)

      This gives us the expectation and variance immediately by linearity and independence.

      Binomial as Sampling

      The binomial arises from sampling with replacement or from a large population where the success probability stays constant.

      If sampling is without replacement from a small population, use the hypergeometric distribution instead.

      Normal Approximation

      For large nn, Bin(n,p)\text{Bin}(n, p) is approximately normal:

      XN(np,np(1p))X \approx N(np, np(1-p))

      Rule of thumb: use when np5np \geq 5 and n(1p)5n(1-p) \geq 5.

      Summary Table

      DistributionPMFMeanVariance
      Bernoulli(pp)p1(1p)1xp^1(1-p)^{1-x}ppp(1p)p(1-p)
      Binomial(n,pn,p)(nk)pk(1p)nk\binom{n}{k}p^k(1-p)^{n-k}npnpnp(1p)np(1-p)
    • Poisson Distribution

      Motivation

      The Poisson distribution models the number of events occurring in a fixed interval (time, space, etc.) when events occur:

      • Independently of each other
      • At a constant average rate
      • One at a time

      Examples:

      • Number of emails arriving in an hour
      • Number of typos per page
      • Number of earthquakes per year in a region
      • Number of customers entering a shop per hour

      Preview: The Constant ee

      The Poisson distribution uses the mathematical constant e2.71828e \approx 2.71828.

      Key identities: e=n=01n!,ex=n=0xnn!e = \sum_{n=0}^{\infty} \frac{1}{n!}, \quad e^x = \sum_{n=0}^{\infty} \frac{x^n}{n!}

      eλ=limn(1λn)ne^{-\lambda} = \lim_{n \to \infty} \left(1 - \frac{\lambda}{n}\right)^n

      Definition

      XPoisson(λ)X \sim \text{Poisson}(\lambda) if:

      P(X=k)=λkeλk!,k=0,1,2,P(X = k) = \frac{\lambda^k e^{-\lambda}}{k!}, \quad k = 0, 1, 2, \ldots

      The parameter λ>0\lambda > 0 is both the mean and the variance.

      Range

      X{0,1,2,3,}X \in \{0, 1, 2, 3, \ldots\} (all non-negative integers)

      Expectation

      E[X]=k=0kλkeλk!=eλk=1λk(k1)!=eλλk=1λk1(k1)!=eλλeλ=λE[X] = \sum_{k=0}^{\infty} k \cdot \frac{\lambda^k e^{-\lambda}}{k!} = e^{-\lambda} \sum_{k=1}^{\infty} \frac{\lambda^k}{(k-1)!} = e^{-\lambda} \cdot \lambda \sum_{k=1}^{\infty} \frac{\lambda^{k-1}}{(k-1)!} = e^{-\lambda} \cdot \lambda \cdot e^{\lambda} = \lambda

      Variance

      By similar calculation: Var(X)=λ\text{Var}(X) = \lambda.

      Not a coincidence: The mean and variance are equal for Poisson. This is a distinguishing feature.

      Derivation from Binomial

      Let YBin(n,p)Y \sim \text{Bin}(n, p). If nn \to \infty and p0p \to 0 with np=λnp = \lambda fixed:

      Bin(n,p)Poisson(λ)\text{Bin}(n, p) \to \text{Poisson}(\lambda)

      Intuition

      Consider events occurring over time. Divide the interval into nn tiny subintervals:

      • Each subinterval has probability p=λ/np = \lambda/n of containing an event
      • Number of events in the whole interval is Bin(n,p)\text{Bin}(n, p)
      • As nn \to \infty, this approaches Poisson(λ)\text{Poisson}(\lambda)

      Proof Sketch

      P(Y=k)=(nk)pk(1p)nk=n(n1)(nk+1)k!(λn)k(1λn)nkP(Y = k) = \binom{n}{k} p^k (1-p)^{n-k} = \frac{n(n-1)\cdots(n-k+1)}{k!} \left(\frac{\lambda}{n}\right)^k \left(1 - \frac{\lambda}{n}\right)^{n-k}

      As nn \to \infty:

      • n(n1)(nk+1)nk1\frac{n(n-1)\cdots(n-k+1)}{n^k} \to 1
      • (1λ/n)nkeλ(1 - \lambda/n)^{n-k} \to e^{-\lambda}

      Result: P(X=k)=λkeλk!P(X = k) = \frac{\lambda^k e^{-\lambda}}{k!}

      Example: Call Centre

      A call centre receives an average of 5 calls per minute. What is the probability of exactly 3 calls in a minute?

      XPoisson(λ=5)X \sim \text{Poisson}(\lambda = 5)

      P(X=3)=53e53!=125×0.0067460.14P(X = 3) = \frac{5^3 e^{-5}}{3!} = \frac{125 \times 0.00674}{6} \approx 0.14

      What is the probability of at most 2 calls?

      P(X2)=P(X=0)+P(X=1)+P(X=2)=e5(1+5+252)=18.5e50.125P(X \leq 2) = P(X = 0) + P(X = 1) + P(X = 2) = e^{-5}\left(1 + 5 + \frac{25}{2}\right) = 18.5 e^{-5} \approx 0.125

      Example: Rare Events

      If events are rare (small pp), but we have many trials (large nn), use Poisson as an approximation to Binomial.

      Earthquakes: Suppose there’s a 0.001 chance of a major earthquake each year. In 1000 years, expected number is λ=1\lambda = 1.

      P(at least one in 1000 years)=1P(X=0)=1e10.632P(\text{at least one in 1000 years}) = 1 - P(X = 0) = 1 - e^{-1} \approx 0.632

      Poisson Process

      A Poisson process with rate λ\lambda satisfies:

      1. N(0)=0N(0) = 0 (no events at time 0)
      2. Independent increments: counts in disjoint intervals are independent
      3. N(t)Poisson(λt)N(t) \sim \text{Poisson}(\lambda t): number of events in time interval of length tt

      The inter-arrival times are exponentially distributed with parameter λ\lambda.

      Additivity

      If XPoisson(λ1)X \sim \text{Poisson}(\lambda_1) and YPoisson(λ2)Y \sim \text{Poisson}(\lambda_2) are independent:

      X+YPoisson(λ1+λ2)X + Y \sim \text{Poisson}(\lambda_1 + \lambda_2)

      Intuition: Merging two independent streams of events at rates λ1\lambda_1 and λ2\lambda_2 gives rate λ1+λ2\lambda_1 + \lambda_2.

      Summary Table

      PropertyValue
      PMFP(X=k)=λkeλk!P(X = k) = \frac{\lambda^k e^{-\lambda}}{k!}
      Range{0,1,2,}\{0, 1, 2, \ldots\}
      Meanλ\lambda
      Varianceλ\lambda
      Relation to binomialLimit of Bin(n,p)\text{Bin}(n, p) as nn \to \infty, np=λnp = \lambda
    • Geometric Distribution

      Definition

      XGeo(p)X \sim \text{Geo}(p) counts the number of Bernoulli trials until the first success, where each trial is independent with success probability pp.

      PMF

      P(X=n)=(1p)n1p,n=1,2,3,P(X = n) = (1-p)^{n-1} p, \quad n = 1, 2, 3, \ldots

      Why this formula? To have X=nX = n:

      • First n1n-1 trials must fail: probability (1p)n1(1-p)^{n-1}
      • Trial nn succeeds: probability pp

      Range

      X{1,2,3,}X \in \{1, 2, 3, \ldots\} (positive integers, starting at 1)

      Expectation

      E[X]=n=1n(1p)n1pE[X] = \sum_{n=1}^{\infty} n \cdot (1-p)^{n-1} p

      Using n=1nrn1=1(1r)2\sum_{n=1}^{\infty} n r^{n-1} = \frac{1}{(1-r)^2} for r<1|r| < 1:

      E[X]=p1p2=1pE[X] = p \cdot \frac{1}{p^2} = \frac{1}{p}

      Intuition: If success has probability pp, on average you need 1/p1/p trials.

      Example

      For a fair coin (p=0.5p = 0.5), expected number of flips until heads is E[X]=2E[X] = 2.

      If p=0.1p = 0.1, expected trials until success is E[X]=10E[X] = 10.

      Variance

      Var(X)=1pp2\text{Var}(X) = \frac{1-p}{p^2}

      Derivation: Using E[X2]=2pp2E[X^2] = \frac{2-p}{p^2}, we get Var(X)=E[X2]E[X]2=2pp21p2=1pp2\text{Var}(X) = E[X^2] - E[X]^2 = \frac{2-p}{p^2} - \frac{1}{p^2} = \frac{1-p}{p^2}.

      Memoryless Property

      The geometric distribution is the only discrete distribution that is memoryless:

      P(X>m+nX>m)=P(X>n)P(X > m + n \mid X > m) = P(X > n)

      Interpretation: If you’ve already waited mm trials without success, the probability of waiting at least nn more trials is the same as starting fresh.

      Proof

      P(X>n)=(1p)nP(X > n) = (1-p)^n

      P(X>m+nX>m)=P(X>m+n)P(X>m)=(1p)m+n(1p)m=(1p)n=P(X>n)P(X > m + n \mid X > m) = \frac{P(X > m + n)}{P(X > m)} = \frac{(1-p)^{m+n}}{(1-p)^m} = (1-p)^n = P(X > n)

      Example

      Flip a coin until heads appears. If you’ve flipped 10 tails already, the probability of flipping at least 5 more is the same as if you just started fresh. The coin has no memory.

      CDF

      F(n)=P(Xn)=1(1p)nF(n) = P(X \leq n) = 1 - (1-p)^n

      This is the probability of at least one success in nn trials.

      Examples

      Example 1: Coin Flips

      Flip a fair coin until heads. XGeo(0.5)X \sim \text{Geo}(0.5).

      • P(X=1)=0.5P(X = 1) = 0.5
      • P(X=2)=0.5×0.5=0.25P(X = 2) = 0.5 \times 0.5 = 0.25
      • P(X=3)=0.52×0.5=0.125P(X = 3) = 0.5^2 \times 0.5 = 0.125
      • E[X]=2E[X] = 2

      Example 2: Bit Generation

      Generate random bits until the first 1, where each bit is 1 with probability p=0.3p = 0.3.

      E[X]=10.33.33E[X] = \frac{1}{0.3} \approx 3.33

      P(X5)=1(0.7)5=10.168=0.832P(X \leq 5) = 1 - (0.7)^5 = 1 - 0.168 = 0.832

      Example 3: Network Packets

      A network sends packets until acknowledgment received. Packet loss rate is 5%.

      Expected packets sent until acknowledgment:

      E[X]=10.951.053E[X] = \frac{1}{0.95} \approx 1.053

      Alternative Convention

      Some textbooks define geometric distribution starting at 0:

      Y=X1Geo0(p)Y = X - 1 \sim \text{Geo}_0(p)

      This counts failures before first success. Then Y{0,1,2,}Y \in \{0, 1, 2, \ldots\} with:

      E[Y]=1pp,Var(Y)=1pp2E[Y] = \frac{1-p}{p}, \quad \text{Var}(Y) = \frac{1-p}{p^2}

      Always check which convention is being used.

      Relation to Other Distributions

      • Bernoulli: Each trial is Bernoulli(p)(p)
      • Binomial: Counts successes in nn trials; geometric counts trials until first success
      • Negative Binomial: Counts trials until rrth success; geometric is the special case r=1r = 1

      Summary

      PropertyValue
      PMFP(X=n)=(1p)n1pP(X = n) = (1-p)^{n-1} p
      Range{1,2,3,}\{1, 2, 3, \ldots\}
      Mean1p\frac{1}{p}
      Variance1pp2\frac{1-p}{p^2}
      MemorylessP(X>m+nX>m)=P(X>n)P(X > m + n \mid X > m) = P(X > n)
      CDFF(n)=1(1p)nF(n) = 1 - (1-p)^n
    • Negative Binomial, Hypergeometric, and Discrete Uniform

      Negative Binomial Distribution

      Definition

      XNegBin(r,p)X \sim \text{NegBin}(r, p) counts the number of Bernoulli trials until the rrth success.

      PMF

      P(X=n)=(n1r1)(1p)nrpr,n=r,r+1,r+2,P(X = n) = \binom{n-1}{r-1} (1-p)^{n-r} p^r, \quad n = r, r+1, r+2, \ldots

      Why this formula?

      • Trial nn must be a success (the rrth one)
      • Exactly r1r-1 successes in the first n1n-1 trials: (n1r1)\binom{n-1}{r-1} ways
      • nrn - r failures, rr successes

      Range

      X{r,r+1,r+2,}X \in \{r, r+1, r+2, \ldots\}

      Expectation and Variance

      E[X]=rpE[X] = \frac{r}{p}

      Var(X)=r(1p)p2\text{Var}(X) = \frac{r(1-p)}{p^2}

      Relation to Geometric

      Geo(p)=NegBin(1,p)\text{Geo}(p) = \text{NegBin}(1, p)

      The geometric counts trials until the first success.

      Example: Coin Flips

      Flip a fair coin until the third heads. XNegBin(3,0.5)X \sim \text{NegBin}(3, 0.5).

      E[X]=30.5=6E[X] = \frac{3}{0.5} = 6

      P(X=5)=(42)(0.5)2(0.5)3=6×132=316P(X = 5) = \binom{4}{2} (0.5)^2 (0.5)^3 = 6 \times \frac{1}{32} = \frac{3}{16}

      Hypergeometric Distribution

      Definition

      XHyp(N,n,m)X \sim \text{Hyp}(N, n, m) counts the number of successes when drawing nn items without replacement from a population of NN containing exactly mm successes.

      PMF

      P(X=i)=(mi)(Nmni)(Nn),i=max(0,nN+m),,min(m,n)P(X = i) = \frac{\binom{m}{i} \binom{N-m}{n-i}}{\binom{N}{n}}, \quad i = \max(0, n-N+m), \ldots, \min(m, n)

      Why this formula?

      • Choose ii successes from mm: (mi)\binom{m}{i}
      • Choose nin-i failures from NmN-m: (Nmni)\binom{N-m}{n-i}
      • Divide by total ways to choose nn from NN: (Nn)\binom{N}{n}

      Range

      X ranges from max(0,n(Nm))\max(0, n - (N-m)) to min(n,m)\min(n, m).

      Expectation

      E[X]=nmNE[X] = \frac{nm}{N}

      Variance

      Var(X)=nmN(1mN)NnN1\text{Var}(X) = \frac{nm}{N}\left(1 - \frac{m}{N}\right)\frac{N-n}{N-1}

      The factor NnN1\frac{N-n}{N-1} is the finite population correction.

      Example: Quality Control

      A batch of 20 components contains 5 defective. Select 4 at random. What is the probability exactly 2 are defective?

      XHyp(20,4,5)X \sim \text{Hyp}(20, 4, 5)

      P(X=2)=(52)(152)(204)=10×1054845=105048450.217P(X = 2) = \frac{\binom{5}{2} \binom{15}{2}}{\binom{20}{4}} = \frac{10 \times 105}{4845} = \frac{1050}{4845} \approx 0.217

      Example: Card Hands

      Deal 5 cards from a 52-card deck. Probability of exactly 2 hearts?

      There are 13 hearts in the deck.

      P(X=2)=(132)(393)(525)P(X = 2) = \frac{\binom{13}{2} \binom{39}{3}}{\binom{52}{5}}

      Comparison with Binomial

      PropertyBinomialHypergeometric
      SamplingWith replacementWithout replacement
      TrialsIndependentDependent
      UsageLarge populationFinite population
      Approximation-Binomial when n/Nn/N small

      When NnN \gg n: Hyp(N,n,m)Bin(n,m/N)\text{Hyp}(N, n, m) \approx \text{Bin}(n, m/N)

      Discrete Uniform Distribution

      Definition

      XUnif{1,2,,N}X \sim \text{Unif}\{1, 2, \ldots, N\} takes each integer from 1 to N with equal probability.

      PMF

      P(X=k)=1N,k{1,2,,N}P(X = k) = \frac{1}{N}, \quad k \in \{1, 2, \ldots, N\}

      Parameters

      Some versions use {a,a+1,,b}\{a, a+1, \ldots, b\} with N=ba+1N = b - a + 1.

      Expectation

      E[X]=N+12E[X] = \frac{N + 1}{2}

      Variance

      Var(X)=N2112\text{Var}(X) = \frac{N^2 - 1}{12}

      Example: Die Roll

      A fair die: XUnif{1,2,3,4,5,6}X \sim \text{Unif}\{1, 2, 3, 4, 5, 6\}.

      E[X]=72,Var(X)=3512E[X] = \frac{7}{2}, \quad \text{Var}(X) = \frac{35}{12}

      Example: Random Digit

      A random digit from 0 to 9: XUnif{0,1,,9}X \sim \text{Unif}\{0, 1, \ldots, 9\}.

      E[X]=92=4.5E[X] = \frac{9}{2} = 4.5

      Example: Tank Problem

      In the tank estimation problem, captured serial numbers are assumed to come from Unif{1,2,,N}\text{Unif}\{1, 2, \ldots, N\}, where we want to estimate the unknown NN.

      Summary Table

      DistributionPMFMeanVariance
      NegBin(r,pr,p)(n1r1)(1p)nrpr\binom{n-1}{r-1}(1-p)^{n-r}p^rr/pr/pr(1p)/p2r(1-p)/p^2
      Hyp(N,n,mN,n,m)(mi)(Nmni)(Nn)\frac{\binom{m}{i}\binom{N-m}{n-i}}{\binom{N}{n}}nm/Nnm/NnmN(1mN)NnN1\frac{nm}{N}(1-\frac{m}{N})\frac{N-n}{N-1}
      Unif{1,,N}\{1,\ldots,N\}1/N1/N(N+1)/2(N+1)/2(N21)/12(N^2-1)/12
  • Continuous Random Variables

    PDFs, continuous distributions, and normal calculations

    • Probability Density Functions

      From Discrete to Continuous

      Discrete random variables take countably many values. But many quantities (time, weight, temperature) can take any value in an interval.

      Problem: For continuous XX, P(X=x)=0P(X = x) = 0 for any specific xx. What does “exactly 3.214159… seconds” mean?”

      We need a different approach.

      Probability Density Function

      A continuous random variable XX has a probability density function (PDF) f(x)f(x) such that:

      P(aXb)=abf(x)dxP(a \leq X \leq b) = \int_a^b f(x) \, dx

      Properties:

      1. f(x)0f(x) \geq 0 for all xx
      2. f(x)dx=1\int_{-\infty}^{\infty} f(x) \, dx = 1

      Key difference from PMF: f(x)f(x) is NOT a probability. It can exceed 1. Only the integral over an interval gives a probability.

      Visual Interpretation

      The probability P(aXb)P(a \leq X \leq b) is the area under the curve f(x)f(x) from aa to bb.

      PDF as area under curve

      Point Probabilities are Zero

      For any specific value cc:

      P(X=c)=ccf(x)dx=0P(X = c) = \int_c^c f(x) \, dx = 0

      A continuous random variable never equals an exact value “with probability 1.” This is why we work with intervals.

      The CDF

      For continuous XX, the CDF is:

      F(x)=P(Xx)=xf(t)dtF(x) = P(X \leq x) = \int_{-\infty}^x f(t) \, dt

      The PDF is the derivative of the CDF:

      f(x)=F(x)f(x) = F'(x)

      Relationship

      P(aXb)=F(b)F(a)P(a \leq X \leq b) = F(b) - F(a)

      This works because:

      abf(x)dx=F(b)F(a)\int_a^b f(x) \, dx = F(b) - F(a)

      by the Fundamental Theorem of Calculus.

      Example: Uniform on [0, 2]

      f(x)={120x20otherwisef(x) = \begin{cases} \frac{1}{2} & 0 \leq x \leq 2 \\ 0 & \text{otherwise} \end{cases}

      • Total area: 2×12=12 \times \frac{1}{2} = 1
      • P(X1)=0112dx=12P(X \leq 1) = \int_0^1 \frac{1}{2} dx = \frac{1}{2}
      • f(1)=12f(1) = \frac{1}{2}, but P(X=1)=0P(X = 1) = 0

      Example: Exponential Density

      f(x)=λeλx,x0f(x) = \lambda e^{-\lambda x}, \quad x \geq 0

      F(x)=1eλx,x0F(x) = 1 - e^{-\lambda x}, \quad x \geq 0

      P(X>t)=eλtP(X > t) = e^{-\lambda t}

      Finding the Normalisation Constant

      For f(x)=cx2f(x) = c x^2 on [0,1][0, 1], find cc such that ff is a valid PDF.

      01cx2dx=1\int_0^1 c x^2 \, dx = 1

      c13=1c=3c \cdot \frac{1}{3} = 1 \Rightarrow c = 3

      The PDF is f(x)=3x2f(x) = 3x^2 for x[0,1]x \in [0, 1].

      Properties of PDFs

      1. Non-negative: f(x)0f(x) \geq 0
      2. Integrates to 1: f(x)dx=1\int_{-\infty}^{\infty} f(x) dx = 1
      3. Not probabilities: f(x)f(x) may exceed 1
      4. Point values: P(X=x)=0P(X = x) = 0
      5. Intervals: Use integration for P(aXb)P(a \leq X \leq b)

      Support

      The support of a continuous RV is where f(x)>0f(x) > 0:

      supp(X)={x:f(x)>0}\text{supp}(X) = \{x : f(x) > 0\}

      • Uniform on [0,1][0,1]: support is [0,1][0, 1]
      • Exponential: support is [0,)[0, \infty)
      • Normal: support is R\mathbb{R}

      Summary

      ConceptFormula
      PDF definitionP(aXb)=abf(x)dxP(a \leq X \leq b) = \int_a^b f(x) dx
      CDFF(x)=xf(t)dtF(x) = \int_{-\infty}^x f(t) dt
      Derivative relationf(x)=F(x)f(x) = F'(x)
      Normalisationf(x)dx=1\int_{-\infty}^{\infty} f(x) dx = 1
      Point probabilityP(X=c)=0P(X = c) = 0
    • Expectation and Variance for Continuous Random Variables

      Expectation

      For a continuous random variable XX with PDF ff:

      E[X]=xf(x)dxE[X] = \int_{-\infty}^{\infty} x f(x) \, dx

      This is the continuous analogue of the discrete sum: integration replaces summation.

      Intuition

      The expectation is still a weighted average, but now with an integral. The density f(x)f(x) weights each infinitesimal contribution.

      Example: Uniform on [0, 2]

      E[X]=02x12dx=12[x22]02=1242=1E[X] = \int_0^2 x \cdot \frac{1}{2} \, dx = \frac{1}{2} \left[ \frac{x^2}{2} \right]_0^2 = \frac{1}{2} \cdot \frac{4}{2} = 1

      The centre of [0,2][0, 2] is 1.

      Example: Exponential

      For XExp(λ)X \sim \text{Exp}(\lambda):

      E[X]=0xλeλxdxE[X] = \int_0^{\infty} x \lambda e^{-\lambda x} \, dx

      Integration by parts gives:

      E[X]=1λE[X] = \frac{1}{\lambda}

      Expectation of Functions (LOTUS)

      For any function gg:

      E[g(X)]=g(x)f(x)dxE[g(X)] = \int_{-\infty}^{\infty} g(x) f(x) \, dx

      Example: E[X2]E[X^2] for Uniform [0, 2]

      E[X2]=02x212dx=12[x33]02=1283=43E[X^2] = \int_0^2 x^2 \cdot \frac{1}{2} \, dx = \frac{1}{2} \left[ \frac{x^3}{3} \right]_0^2 = \frac{1}{2} \cdot \frac{8}{3} = \frac{4}{3}

      Variance

      Var(X)=E[(XE[X])2]\text{Var}(X) = E[(X - E[X])^2]

      Var(X)=E[X2]E[X]2\text{Var}(X) = E[X^2] - E[X]^2

      The computational formula works exactly as for discrete variables.

      Example: Uniform on [0, 2]

      E[X]=1,E[X2]=43E[X] = 1, \quad E[X^2] = \frac{4}{3}

      Var(X)=431=13\text{Var}(X) = \frac{4}{3} - 1 = \frac{1}{3}

      Example: Exponential

      E[X]=1λ,E[X2]=2λ2E[X] = \frac{1}{\lambda}, \quad E[X^2] = \frac{2}{\lambda^2}

      Var(X)=2λ21λ2=1λ2\text{Var}(X) = \frac{2}{\lambda^2} - \frac{1}{\lambda^2} = \frac{1}{\lambda^2}

      Standard deviation: σX=1λ\sigma_X = \frac{1}{\lambda}

      Properties Remain Unchanged

      All properties of expectation and variance carry over:

      PropertyContinuous
      LinearityE[aX+b]=aE[X]+bE[aX + b] = aE[X] + b
      AdditivityE[X+Y]=E[X]+E[Y]E[X + Y] = E[X] + E[Y]
      ScalingVar(aX)=a2Var(X)\text{Var}(aX) = a^2 \text{Var}(X)
      ShiftVar(X+c)=Var(X)\text{Var}(X + c) = \text{Var}(X)

      Standard Deviation

      σX=Var(X)\sigma_X = \sqrt{\text{Var}(X)}

      This returns to the original units.

      Example: Uniform on [a, b]

      For XUnif[a,b]X \sim \text{Unif}[a, b]:

      E[X]=a+b2E[X] = \frac{a + b}{2}

      Var(X)=(ba)212\text{Var}(X) = \frac{(b-a)^2}{12}

      σX=ba12\sigma_X = \frac{b-a}{\sqrt{12}}

      Quantiles

      The ppth quantile xpx_p satisfies:

      F(xp)=pF(x_p) = p

      Or: xpf(x)dx=p\int_{-\infty}^{x_p} f(x) \, dx = p.

      Example: Exponential

      Find x0.5x_{0.5} (median) for XExp(λ)X \sim \text{Exp}(\lambda).

      P(Xx0.5)=1eλx0.5=0.5P(X \leq x_{0.5}) = 1 - e^{-\lambda x_{0.5}} = 0.5

      eλx0.5=0.5e^{-\lambda x_{0.5}} = 0.5

      x0.5=ln2λx_{0.5} = \frac{\ln 2}{\lambda}

      Note: x0.5E[X]=1λx_{0.5} \neq E[X] = \frac{1}{\lambda}. For exponential, median 0.693/λ\approx 0.693/\lambda, mean =1/λ= 1/\lambda.

      Summary

      QuantityDiscreteContinuous
      Expectationxp(x)\sum x p(x)xf(x)dx\int x f(x) dx
      E[g(X)]E[g(X)]g(x)p(x)\sum g(x) p(x)g(x)f(x)dx\int g(x) f(x) dx
      VarianceE[X2]E[X]2E[X^2] - E[X]^2Same formula
    • Uniform Distribution

      Continuous Uniform

      Definition

      XUnif[a,b]X \sim \text{Unif}[a, b] has constant density over an interval.

      PDF

      f(x)={1baaxb0otherwisef(x) = \begin{cases} \frac{1}{b-a} & a \leq x \leq b \\ 0 & \text{otherwise} \end{cases}

      CDF

      F(x)={0x<axabaaxb1x>bF(x) = \begin{cases} 0 & x < a \\ \frac{x-a}{b-a} & a \leq x \leq b \\ 1 & x > b \end{cases}

      Parameters

      • aa: lower bound
      • bb: upper bound (b>ab > a)

      Expectation and Variance

      E[X]=a+b2E[X] = \frac{a + b}{2}

      The mean is the midpoint.

      Proof:

      E[X]=abx1badx=1ba[x22]ab=b2a22(ba)=(ba)(b+a)2(ba)=a+b2E[X] = \int_a^b x \cdot \frac{1}{b-a} \, dx = \frac{1}{b-a} \left[ \frac{x^2}{2} \right]_a^b = \frac{b^2 - a^2}{2(b-a)} = \frac{(b-a)(b+a)}{2(b-a)} = \frac{a+b}{2}

      Var(X)=(ba)212\text{Var}(X) = \frac{(b-a)^2}{12}

      Proof:

      E[X2]=abx21badx=b3a33(ba)=a2+ab+b23E[X^2] = \int_a^b x^2 \cdot \frac{1}{b-a} dx = \frac{b^3 - a^3}{3(b-a)} = \frac{a^2 + ab + b^2}{3}

      Var(X)=E[X2]E[X]2=a2+ab+b23a2+2ab+b24=b22ab+a212=(ba)212\text{Var}(X) = E[X^2] - E[X]^2 = \frac{a^2 + ab + b^2}{3} - \frac{a^2 + 2ab + b^2}{4} = \frac{b^2 - 2ab + a^2}{12} = \frac{(b-a)^2}{12}

      Visualisation

      The PDF is a flat rectangle of height 1ba\frac{1}{b-a} and width bab-a. Area = 1.

      The CDF is a straight line from (a,0)(a, 0) to (b,1)(b, 1).

      Uniform PDF and CDF

      Examples

      Example 1: Random Time

      A bus arrives uniformly at random between 8:00 and 8:30. XUnif[0,30]X \sim \text{Unif}[0, 30] (minutes past 8:00).

      E[X]=15 minutesE[X] = 15 \text{ minutes}

      P(X10)=1030=13P(X \leq 10) = \frac{10}{30} = \frac{1}{3}

      Example 2: Random Point

      Choose a point uniformly on [0,1][0, 1]. XUnif[0,1]X \sim \text{Unif}[0, 1].

      P(X0.4)=0.4P(X \leq 0.4) = 0.4

      P(0.2X0.7)=0.5P(0.2 \leq X \leq 0.7) = 0.5

      Generating Uniform Variates

      Uniform random variables are the foundation of simulation. From UUnif[0,1]U \sim \text{Unif}[0, 1], we can generate many other distributions.

      Inverse transform method: If FF is a CDF with inverse F1F^{-1}, then X=F1(U)X = F^{-1}(U) has CDF FF.

      Example: Generating Exponential

      For exponential with rate λ\lambda:

      F(x)=1eλxF(x) = 1 - e^{-\lambda x}

      F1(u)=1λln(1u)F^{-1}(u) = -\frac{1}{\lambda} \ln(1 - u)

      So X=1λln(1U)X = -\frac{1}{\lambda} \ln(1 - U) or equivalently X=1λlnUX = -\frac{1}{\lambda} \ln U (since UU and 1U1-U have the same distribution) generates an exponential.

      Properties

      Probability of Interval

      For XUnif[a,b]X \sim \text{Unif}[a, b]:

      P(cXd)=dcbaP(c \leq X \leq d) = \frac{d - c}{b - a}

      Probability is proportional to interval length.

      Memoryless?

      No. For uniform, knowing X>cX > c tells us X>cX > c is impossible if c<ac < a, and restricts XX to [c,b][c, b] if ac<ba \leq c < b.

      Linear Transformation

      If XUnif[a,b]X \sim \text{Unif}[a, b] and Y=cX+dY = cX + d (c>0c > 0), then YUnif[ca+d,cb+d]Y \sim \text{Unif}[ca + d, cb + d].

      Summary Table

      PropertyValue
      PDFf(x)=1baf(x) = \frac{1}{b-a} on [a,b][a,b]
      CDFF(x)=xabaF(x) = \frac{x-a}{b-a} on [a,b][a,b]
      Meana+b2\frac{a+b}{2}
      Variance(ba)212\frac{(b-a)^2}{12}
      SDba12\frac{b-a}{\sqrt{12}}
    • Exponential Distribution

      Motivation

      The exponential distribution models the time until an event occurs when events happen:

      • Continuously over time
      • At a constant average rate
      • Independently of past history

      Examples:

      • Time until radioactive decay
      • Time until customer arrives
      • Lifetime of a component
      • Time between earthquakes (if Poisson process)

      Definition

      XExp(λ)X \sim \text{Exp}(\lambda) has PDF:

      f(x)=λeλx,x0f(x) = \lambda e^{-\lambda x}, \quad x \geq 0

      where λ>0\lambda > 0 is the rate parameter.

      Range

      X[0,)X \in [0, \infty)

      CDF

      F(x)=1eλx,x0F(x) = 1 - e^{-\lambda x}, \quad x \geq 0

      Survival Function

      P(X>x)=eλxP(X > x) = e^{-\lambda x}

      Expectation and Variance

      E[X]=1λE[X] = \frac{1}{\lambda}

      Interpretation: If events occur at rate λ\lambda per unit time, average wait time is 1/λ1/\lambda.

      Var(X)=1λ2\text{Var}(X) = \frac{1}{\lambda^2}

      σX=1λ=E[X]\sigma_X = \frac{1}{\lambda} = E[X]

      For exponential, mean equals standard deviation.

      Memoryless Property

      The exponential is the only continuous memoryless distribution:

      P(X>s+tX>s)=P(X>t)P(X > s + t \mid X > s) = P(X > t)

      Interpretation: If a component has survived ss time units, its remaining lifetime distribution is the same as a new component.

      Proof

      P(X>s+tX>s)=P(X>s+t)P(X>s)=eλ(s+t)eλs=eλt=P(X>t)P(X > s + t \mid X > s) = \frac{P(X > s + t)}{P(X > s)} = \frac{e^{-\lambda(s+t)}}{e^{-\lambda s}} = e^{-\lambda t} = P(X > t)

      Practical Meaning

      A lightbulb with exponential lifetime has no “aging.” A 10-year-old bulb (that still works) is as good as new. This is reasonable for some random failures but not for wear-out failures.

      Quantiles

      For XExp(λ)X \sim \text{Exp}(\lambda):

      P(Xxp)=1eλxp=pP(X \leq x_p) = 1 - e^{-\lambda x_p} = p

      xp=ln(1p)λx_p = -\frac{\ln(1-p)}{\lambda}

      Median:

      x0.5=ln2λ0.693λx_{0.5} = \frac{\ln 2}{\lambda} \approx \frac{0.693}{\lambda}

      Note: median << mean since the distribution is right-skewed.

      Relation to Poisson

      If events occur as a Poisson process with rate λ\lambda:

      • Number of events in time tt ~ Poisson(λt)\text{Poisson}(\lambda t)
      • Time until first event ~ Exp(λ)\text{Exp}(\lambda)
      • Time until kkth event ~ Gamma(k,λ)\text{Gamma}(k, \lambda)

      Example

      Customers arrive at rate 2 per minute. Time until first customer:

      XExp(λ=2)X \sim \text{Exp}(\lambda = 2)

      E[X]=12=0.5 minutesE[X] = \frac{1}{2} = 0.5 \text{ minutes}

      P(X>1)=e21=e20.135P(X > 1) = e^{-2 \cdot 1} = e^{-2} \approx 0.135

      Minimum of Exponentials

      If X1,,XnX_1, \ldots, X_n are independent with XiExp(λi)X_i \sim \text{Exp}(\lambda_i), then:

      min(X1,,Xn)Exp(i=1nλi)\min(X_1, \ldots, X_n) \sim \text{Exp}\left(\sum_{i=1}^n \lambda_i\right)

      Intuition: If nn independent processes are running, and we wait for the first to “fire,” the minimum follows exponential with combined rate.

      Example: Competing Risks

      A system has two failure modes, with failure rates λ1=0.01\lambda_1 = 0.01/hour and λ2=0.02\lambda_2 = 0.02/hour. Time to failure:

      min(X1,X2)Exp(0.03)\min(X_1, X_2) \sim \text{Exp}(0.03)

      E[failure time]=10.0333.3 hoursE[\text{failure time}] = \frac{1}{0.03} \approx 33.3 \text{ hours}

      Visualisation

      The exponential PDF starts at λ\lambda and decays toward 0. It is always decreasing (no mode except at 0).

      Exponential PDFs for different lambdas

      Summary

      PropertyValue
      PDFf(x)=λeλxf(x) = \lambda e^{-\lambda x}, x0x \geq 0
      CDFF(x)=1eλxF(x) = 1 - e^{-\lambda x}
      Mean1λ\frac{1}{\lambda}
      Variance1λ2\frac{1}{\lambda^2}
      Medianln2λ\frac{\ln 2}{\lambda}
      MemorylessP(X>s+tX>s)=P(X>t)P(X > s+t \mid X > s) = P(X > t)
    • Normal Distribution

      Importance

      The normal distribution (Gaussian) is the most important distribution in statistics. It appears naturally as the limit of sums (Central Limit Theorem) and models many physical phenomena.

      Climate: heights, measurement errors, IQ scores, physical measurements, and economic data all approximate normal distributions.

      Definition

      XN(μ,σ2)X \sim N(\mu, \sigma^2) has PDF:

      f(x)=1σ2πe(xμ)22σ2,xRf(x) = \frac{1}{\sigma\sqrt{2\pi}} e^{-\frac{(x-\mu)^2}{2\sigma^2}}, \quad x \in \mathbb{R}

      Parameters

      • μ\mu: mean (centre)
      • σ2\sigma^2: variance (spread), σ>0\sigma > 0

      Range

      X(,)X \in (-\infty, \infty) (all real numbers)

      CDF

      F(x)=Φ(xμσ)F(x) = \Phi\left(\frac{x - \mu}{\sigma}\right)

      where Φ\Phi is the CDF of the standard normal N(0,1)N(0,1). No closed form exists; we use tables or software.

      Properties

      Symmetry

      The normal is symmetric around μ\mu:

      P(Xμa)=P(Xμ+a)P(X \leq \mu - a) = P(X \geq \mu + a)

      f(μ+a)=f(μa)f(\mu + a) = f(\mu - a)

      Mean equals Median equals Mode

      E[X]=μ=median=modeE[X] = \mu = \text{median} = \text{mode}

      Variance

      Var(X)=σ2\text{Var}(X) = \sigma^2

      Linear Transformations

      If XN(μ,σ2)X \sim N(\mu, \sigma^2) and Y=aX+bY = aX + b (a0a \neq 0):

      YN(aμ+b,a2σ2)Y \sim N(a\mu + b, a^2\sigma^2)

      Important: Any linear transformation of a normal is still normal.

      Standard Normal

      The standard normal ZN(0,1)Z \sim N(0, 1) has:

      ϕ(z)=12πez2/2\phi(z) = \frac{1}{\sqrt{2\pi}} e^{-z^2/2}

      CDF: Φ(z)=P(Zz)\Phi(z) = P(Z \leq z)

      Standardisation

      For XN(μ,σ2)X \sim N(\mu, \sigma^2):

      Z=XμσN(0,1)Z = \frac{X - \mu}{\sigma} \sim N(0, 1)

      This converts any normal to standard normal, enabling use of standard tables.

      Visualisation

      The normal PDF is the famous “bell curve”: symmetric, peaked at μ\mu, with spread controlled by σ\sigma.

      • μ\mu shifts the centre
      • σ\sigma controls the width: larger σ\sigma = more spread

      Normal PDFs for different parameters

      Probability Calculations

      Use standardisation and Φ\Phi tables.

      P(Xx)=Φ(xμσ)P(X \leq x) = \Phi\left(\frac{x - \mu}{\sigma}\right)

      P(aXb)=Φ(bμσ)Φ(aμσ)P(a \leq X \leq b) = \Phi\left(\frac{b - \mu}{\sigma}\right) - \Phi\left(\frac{a - \mu}{\sigma}\right)

      Example

      XN(100,152)X \sim N(100, 15^2). Find P(X115)P(X \leq 115).

      Standardise: Z=11510015=1Z = \frac{115 - 100}{15} = 1

      P(X115)=P(Z1)=Φ(1)0.841P(X \leq 115) = P(Z \leq 1) = \Phi(1) \approx 0.841

      From tables: Φ(1)0.8413\Phi(1) \approx 0.8413.

      Empirical Rule (68-95-99.7)

      For any normal N(μ,σ2)N(\mu, \sigma^2):

      IntervalCoverage
      μ±σ\mu \pm \sigma68%\approx 68\%
      μ±2σ\mu \pm 2\sigma95%\approx 95\%
      μ±3σ\mu \pm 3\sigma99.7%\approx 99.7\%

      This is useful for quick estimates.

      Exact Values

      Φ(1)Φ(1)=0.84130.1587=0.6826\Phi(1) - \Phi(-1) = 0.8413 - 0.1587 = 0.6826

      Φ(2)Φ(2)=0.97720.0228=0.9544\Phi(2) - \Phi(-2) = 0.9772 - 0.0228 = 0.9544

      Φ(3)Φ(3)=0.99870.0013=0.9974\Phi(3) - \Phi(-3) = 0.9987 - 0.0013 = 0.9974

      Sum of Independent Normals

      If XN(μ1,σ12)X \sim N(\mu_1, \sigma_1^2) and YN(μ2,σ22)Y \sim N(\mu_2, \sigma_2^2) are independent:

      X+YN(μ1+μ2,σ12+σ22)X + Y \sim N(\mu_1 + \mu_2, \sigma_1^2 + \sigma_2^2)

      The sum of independent normals is normal. This is not true for arbitrary sums.

      Extending to nn Variables

      For independent XiN(μ,σ2)X_i \sim N(\mu, \sigma^2):

      Xˉ=1nXiN(μ,σ2n)\bar{X} = \frac{1}{n}\sum X_i \sim N\left(\mu, \frac{\sigma^2}{n}\right)

      Summary Table

      PropertyValue
      PDF1σ2πe(xμ)2/(2σ2)\frac{1}{\sigma\sqrt{2\pi}} e^{-(x-\mu)^2/(2\sigma^2)}
      Meanμ\mu
      Varianceσ2\sigma^2
      Standard normalN(0,1)N(0, 1)
      StandardisationZ=XμσZ = \frac{X - \mu}{\sigma}
      Sum of independent normalsNormal with μ=μ1+μ2\mu = \mu_1 + \mu_2, σ2=σ12+σ22\sigma^2 = \sigma_1^2 + \sigma_2^2
    • Standard Normal Distribution

      Standard Normal

      The standard normal ZN(0,1)Z \sim N(0, 1) has:

      • Mean μ=0\mu = 0
      • Variance σ2=1\sigma^2 = 1
      • PDF: ϕ(z)=12πez2/2\phi(z) = \frac{1}{\sqrt{2\pi}} e^{-z^2/2}
      • CDF: Φ(z)=P(Zz)=zϕ(t)dt\Phi(z) = P(Z \leq z) = \int_{-\infty}^{z} \phi(t) \, dt

      Why Standardise?

      No closed form exists for Φ(z)\Phi(z). We use tables or software to find Φ(z)\Phi(z) for specific zz.

      Tables give Φ(z)\Phi(z) for positive zz. By symmetry:

      Φ(z)=1Φ(z)\Phi(-z) = 1 - \Phi(z)

      Common Values

      zzΦ(z)\Phi(z)
      0.00.5000
      0.50.6915
      1.00.8413
      1.50.9332
      1.6450.9500
      1.960.9750
      2.00.9772
      2.50.9938
      3.00.9987

      Using Tables

      Finding P(Zz)P(Z \leq z) for z>0z > 0

      Look up zz in the table.

      Finding P(Zz)P(Z \leq z) for z<0z < 0

      Use symmetry: Φ(z)=1Φ(z)\Phi(-|z|) = 1 - \Phi(|z|).

      Example: P(Z1.5)=1P(Z1.5)=10.9332=0.0668P(Z \leq -1.5) = 1 - P(Z \leq 1.5) = 1 - 0.9332 = 0.0668.

      Finding P(aZb)P(a \leq Z \leq b)

      P(aZb)=Φ(b)Φ(a)P(a \leq Z \leq b) = \Phi(b) - \Phi(a)

      Example: P(1Z2)=Φ(2)Φ(1)=0.97720.1587=0.8185P(-1 \leq Z \leq 2) = \Phi(2) - \Phi(-1) = 0.9772 - 0.1587 = 0.8185.

      Inverse: Finding Quantiles

      Given Φ(zp)=p\Phi(z_p) = p, find zpz_p.

      For p>0.5p > 0.5: Look up the value directly.

      For p<0.5p < 0.5: Use symmetry: zp=z1pz_p = -z_{1-p}.

      Critical Values

      Probabilityzz value
      90%±1.645\pm 1.645
      95%±1.96\pm 1.96
      99%±2.576\pm 2.576

      These are central interval boundaries.

      Standardisation

      For XN(μ,σ2)X \sim N(\mu, \sigma^2):

      1. Convert XX to ZZ: Z=XμσZ = \frac{X - \mu}{\sigma}
      2. Look up Φ(z)\Phi(z)
      3. Interpret the result

      Example: Battery Lifetime

      Batteries have mean lifetime 500 hours, SD 20 hours, normally distributed. What proportion last over 530 hours?

      P(X>530)=P(Z>53050020)=P(Z>1.5)P(X > 530) = P\left(Z > \frac{530 - 500}{20}\right) = P(Z > 1.5)

      =1Φ(1.5)=10.9332=0.0668= 1 - \Phi(1.5) = 1 - 0.9332 = 0.0668

      About 6.68%.

      Example: Within k Standard Deviations

      What proportion of values lie within 1.5 standard deviations of the mean?

      P(Z<1.5)=P(1.5<Z<1.5)=Φ(1.5)Φ(1.5)P(|Z| < 1.5) = P(-1.5 < Z < 1.5) = \Phi(1.5) - \Phi(-1.5)

      =Φ(1.5)(1Φ(1.5))=2Φ(1.5)1= \Phi(1.5) - (1 - \Phi(1.5)) = 2\Phi(1.5) - 1

      =2(0.9332)1=0.8664= 2(0.9332) - 1 = 0.8664

      About 86.6%.

      PDF Properties

      Symmetry

      ϕ(z)=ϕ(z)\phi(-z) = \phi(z) ϕ(z) maximised at z=0\phi(z) \text{ maximised at } z = 0 ϕ(0)=12π0.399\phi(0) = \frac{1}{\sqrt{2\pi}} \approx 0.399

      Asymptotic

      limz±ϕ(z)=0\lim_{z \to \pm\infty} \phi(z) = 0

      The tails approach zero but never reach it.

      Summary

      TaskMethod
      P(Zz)P(Z \leq z), z>0z > 0Look up in table
      P(Zz)P(Z \leq z), z<0z < 0$1 - \Phi(
      P(aZb)P(a \leq Z \leq b)Φ(b)Φ(a)\Phi(b) - \Phi(a)
      P(Z>z)P(Z > z)1Φ(z)1 - \Phi(z)
      Find zpz_p from ppInverse lookup or symmetry
    • Normal Distribution Calculations

      Worked Examples

      Example 1: Heights

      Adult male heights are normally distributed with μ=175\mu = 175 cm, σ=7\sigma = 7 cm. What proportion are over 190 cm?

      Standardise: z=1901757=1572.14z = \frac{190 - 175}{7} = \frac{15}{7} \approx 2.14

      P(X>190)=P(Z>2.14)=1Φ(2.14)P(X > 190) = P(Z > 2.14) = 1 - \Phi(2.14)

      From tables: Φ(2.14)0.9838\Phi(2.14) \approx 0.9838.

      P(X>190)=10.9838=0.0162P(X > 190) = 1 - 0.9838 = 0.0162

      About 1.62% exceed 190 cm.

      Example 2: Manufacturing

      A machine produces rods with mean length 100 cm and SD 0.5 cm. Specifications require lengths between 99 cm and 101 cm. What proportion are within spec?

      P(99X101)=P(991000.5Z1011000.5)=P(2Z2)P(99 \leq X \leq 101) = P\left(\frac{99-100}{0.5} \leq Z \leq \frac{101-100}{0.5}\right) = P(-2 \leq Z \leq 2)

      =Φ(2)Φ(2)=0.97720.0228=0.9544= \Phi(2) - \Phi(-2) = 0.9772 - 0.0228 = 0.9544

      About 95.44% are within specification.

      Example 3: Finding a Value

      What height is exceeded by 10% of adult males?

      We want xx such that P(X>x)=0.10P(X > x) = 0.10.

      P(X>x)=0.10P(Z>z)=0.10P(X > x) = 0.10 \Rightarrow P(Z > z) = 0.10

      From tables: P(Z>1.282)0.10P(Z > 1.282) \approx 0.10 (90th percentile is 1.282).

      z=x1757=1.282z = \frac{x - 175}{7} = 1.282

      x=175+7×1.282=175+8.97=183.97x = 175 + 7 \times 1.282 = 175 + 8.97 = 183.97

      About 184 cm is exceeded by 10% of heights.

      Example 4: Two-Sided Interval

      Find a symmetric interval around the mean containing 95% of values.

      P(zZz)=0.95P(-z \leq Z \leq z) = 0.95

      Φ(z)Φ(z)=0.95\Phi(z) - \Phi(-z) = 0.95

      Φ(z)(1Φ(z))=0.95\Phi(z) - (1 - \Phi(z)) = 0.95

      2Φ(z)1=0.952\Phi(z) - 1 = 0.95

      Φ(z)=0.975\Phi(z) = 0.975

      From tables: z=1.96z = 1.96.

      So 95% of values lie within μ±1.96σ\mu \pm 1.96\sigma.

      Continuity Correction

      When approximating discrete distributions with the normal, use a continuity correction.

      For XBinomial(n,p)X \sim \text{Binomial}(n, p) approximated by N(np,np(1p))N(np, np(1-p)):

      P(X=k)P(k0.5<Y<k+0.5)P(X = k) \approx P\left(k - 0.5 < Y < k + 0.5\right)

      P(Xk)P(Y<k+0.5)P(X \leq k) \approx P(Y < k + 0.5)

      Example: Coin Flips

      Flip a fair coin 100 times. Approximate the probability of 55 or more heads.

      XBin(100,0.5)X \sim \text{Bin}(100, 0.5). Approximate with YN(50,25)Y \sim N(50, 25).

      Without correction: P(X55)P(Y55)=P(Z55505)=P(Z1)=0.1587P(X \geq 55) \approx P(Y \geq 55) = P\left(Z \geq \frac{55 - 50}{5}\right) = P(Z \geq 1) = 0.1587

      With continuity correction:

      P(X55)P(Y54.5)=P(Z54.5505)=P(Z0.9)=0.1841P(X \geq 55) \approx P(Y \geq 54.5) = P\left(Z \geq \frac{54.5 - 50}{5}\right) = P(Z \geq 0.9) = 0.1841

      Exact: P(X55)=k=55100(100k)0.51000.184P(X \geq 55) = \sum_{k=55}^{100} \binom{100}{k} 0.5^{100} \approx 0.184

      The continuity correction improves the approximation significantly.

      z-Scores

      A z-score (or standard score) measures how many standard deviations a value is from the mean:

      z=xμσz = \frac{x - \mu}{\sigma}

      Interpretation:

      • z=0z = 0: value equals the mean
      • z>0z > 0: value above the mean
      • z<0z < 0: value below the mean
      • z>2|z| > 2: unusually far from mean (occurs about 5% of the time)

      Example: Comparing Tests

      Alice scores 85 on Test A (mean 70, SD 10). Bob scores 78 on Test B (mean 60, SD 8). Who did better relative to their class?

      • Alice: zA=857010=1.5z_A = \frac{85 - 70}{10} = 1.5
      • Bob: zB=78608=2.25z_B = \frac{78 - 60}{8} = 2.25

      Bob’s z-score is higher, so Bob performed better relative to his class.

      Summary

      TaskApproach
      P(X>x)P(X > x)Standardise, use 1Φ(z)1 - \Phi(z)
      P(X<x)P(X < x)Standardise, use Φ(z)\Phi(z)
      P(a<X<b)P(a < X < b)Φ(zb)Φ(za)\Phi(z_b) - \Phi(z_a)
      Find xx given percentilex=μ+zpσx = \mu + z_p \sigma
      Continuity correctionAdd/subtract 0.5 for discrete approx
  • Joint Distributions

    Joint, marginal, and conditional distributions; covariance and correlation

    • Joint Distributions for Discrete Random Variables

      Motivation

      Many experiments involve multiple random variables simultaneously. We need to describe how they behave together, not just individually.

      Examples:

      • Height and weight of a person
      • Roll of two dice
      • Price and quantity sold

      Joint PMF

      For discrete random variables XX and YY, the joint PMF is:

      p(x,y)=P(X=x,Y=y)p(x, y) = P(X = x, Y = y)

      Properties

      1. p(x,y)0p(x, y) \geq 0 for all (x,y)(x, y)
      2. xyp(x,y)=1\sum_x \sum_y p(x, y) = 1
      3. P((X,Y)A)=(x,y)Ap(x,y)P((X, Y) \in A) = \sum_{(x,y) \in A} p(x, y)

      Example: Two Dice

      Roll two dice. Let XX = first die, YY = second die.

      Since independent: p(x,y)=P(X=x)P(Y=y)=1616=136p(x, y) = P(X = x) P(Y = y) = \frac{1}{6} \cdot \frac{1}{6} = \frac{1}{36} for all x,y{1,,6}x, y \in \{1, \ldots, 6\}.

      All 36 outcomes (x,y)(x, y) have probability 136\frac{1}{36}.

      Example: Dependent Variables

      Draw two cards without replacement. Let XX = number of hearts in first draw, YY = number of hearts in second draw.

      X,Y{0,1}X, Y \in \{0, 1\}. Total hearts in deck: 13.

      • P(X=0)=3952P(X = 0) = \frac{39}{52}
      • P(X=1)=1352P(X = 1) = \frac{13}{52}
      • P(Y=0,Y=1X=0)=3951,1251P(Y = 0, Y = 1 \mid X = 0) = \frac{39}{51}, \frac{12}{51}

      Joint PMF:

      X\YX \backslash YY=0Y = 0Y=1Y = 1
      X=0X = 039523851\frac{39}{52} \cdot \frac{38}{51}39521351\frac{39}{52} \cdot \frac{13}{51}
      X=1X = 113523951\frac{13}{52} \cdot \frac{39}{51}13521251\frac{13}{52} \cdot \frac{12}{51}

      Computing Joint Probabilities

      Product Rule

      p(x,y)=P(Y=yX=x)P(X=x)p(x, y) = P(Y = y \mid X = x) \cdot P(X = x)

      If independent:

      p(x,y)=P(X=x)P(Y=y)=pX(x)pY(y)p(x, y) = P(X = x) \cdot P(Y = y) = p_X(x) \cdot p_Y(y)

      Example

      Two items from a batch. Each is defective with probability p=0.1p = 0.1, independent. Let XX = number defective in item 1 (Bernoulli), YY = number defective in item 2.

      X\YX \backslash YY=0Y = 0Y=1Y = 1
      X=0X = 00.810.810.090.09
      X=1X = 10.090.090.010.01

      The entry for (X=0,Y=0)(X=0, Y=0): P(X=0)P(Y=0)=0.9×0.9=0.81P(X=0) P(Y=0) = 0.9 \times 0.9 = 0.81.

      Marginal PMFs

      From the joint PMF, we can recover the marginal PMF of each variable:

      pX(x)=yp(x,y)p_X(x) = \sum_y p(x, y)

      pY(y)=xp(x,y)p_Y(y) = \sum_x p(x, y)

      Intuition: To find the distribution of XX alone, “marginalise out” YY by summing over all possible yy values.

      Example

      From the joint table for two defective items:

      P(X=0)=0.81+0.09=0.9P(X = 0) = 0.81 + 0.09 = 0.9

      P(X=1)=0.09+0.01=0.1P(X = 1) = 0.09 + 0.01 = 0.1

      These are the original marginal probabilities.

      Visualisation

      Joint PMFs can be visualised as a 3D bar chart or as a 2D heatmap with values in each cell.

      Joint PMF as table

      Independence from Joint PMF

      XX and YY are independent if and only if:

      p(x,y)=pX(x)pY(y)for all x,yp(x, y) = p_X(x) \cdot p_Y(y) \quad \text{for all } x, y

      Checking Independence

      Compute the product of marginals. If it equals the joint PMF everywhere, they are independent.

      Counterexample: In cards without replacement:

      P(X=0,Y=0)=39523851=14822652P(X = 0, Y = 0) = \frac{39}{52} \cdot \frac{38}{51} = \frac{1482}{2652}

      P(X=0)P(Y=0)=39523952=15212704P(X = 0) P(Y = 0) = \frac{39}{52} \cdot \frac{39}{52} = \frac{1521}{2704}

      Not equal \Rightarrow not independent. (Drawing a non-heart first affects probability of non-heart second.)

      Summary

      ConceptFormula
      Joint PMFp(x,y)=P(X=x,Y=y)p(x,y) = P(X=x, Y=y)
      Marginal of XXpX(x)=yp(x,y)p_X(x) = \sum_y p(x,y)
      Independencep(x,y)=pX(x)pY(y)p(x,y) = p_X(x) p_Y(y)
    • Joint Distributions for Continuous Random Variables

      Joint PDF

      For continuous random variables XX and YY, the joint PDF f(x,y)f(x, y) satisfies:

      P((X,Y)A)=Af(x,y)dxdyP((X, Y) \in A) = \iint_A f(x, y) \, dx \, dy

      Properties

      1. f(x,y)0f(x, y) \geq 0 for all (x,y)(x, y)
      2. f(x,y)dxdy=1\int_{-\infty}^{\infty} \int_{-\infty}^{\infty} f(x, y) \, dx \, dy = 1

      Interpretation

      The joint PDF is a surface over the xyxy-plane. Probabilities correspond to volumes under the surface.

      P(aXb,cYd)=abcdf(x,y)dydxP(a \leq X \leq b, c \leq Y \leq d) = \int_a^b \int_c^d f(x, y) \, dy \, dx

      Joint PDF as surface

      Joint CDF

      The joint CDF is:

      F(x,y)=P(Xx,Yy)=xyf(u,v)dvduF(x, y) = P(X \leq x, Y \leq y) = \int_{-\infty}^x \int_{-\infty}^y f(u, v) \, dv \, du

      Recovering the PDF:

      f(x,y)=2F(x,y)xyf(x, y) = \frac{\partial^2 F(x, y)}{\partial x \partial y}

      Example: Uniform on Unit Square

      (X,Y)(X, Y) uniform on [0,1]×[0,1][0, 1] \times [0, 1]:

      f(x,y)={10x1,0y10otherwisef(x, y) = \begin{cases} 1 & 0 \leq x \leq 1, 0 \leq y \leq 1 \\ 0 & \text{otherwise} \end{cases}

      P(X+Y1)=0101x1dydx=01(1x)dx=[xx22]01=12P(X + Y \leq 1) = \int_0^1 \int_0^{1-x} 1 \, dy \, dx = \int_0^1 (1 - x) \, dx = \left[x - \frac{x^2}{2}\right]_0^1 = \frac{1}{2}

      Marginal PDFs

      fX(x)=f(x,y)dyf_X(x) = \int_{-\infty}^{\infty} f(x, y) \, dy

      fY(y)=f(x,y)dxf_Y(y) = \int_{-\infty}^{\infty} f(x, y) \, dx

      Intuition: Integrate out one variable to get the distribution of the other.

      Example

      f(x,y)={2exe2yx>0,y>00otherwisef(x, y) = \begin{cases} 2e^{-x} e^{-2y} & x > 0, y > 0 \\ 0 & \text{otherwise} \end{cases}

      Find fX(x)f_X(x):

      fX(x)=02exe2ydy=2ex0e2ydy=2ex12=ex,x>0f_X(x) = \int_0^{\infty} 2e^{-x} e^{-2y} \, dy = 2e^{-x} \int_0^{\infty} e^{-2y} \, dy = 2e^{-x} \cdot \frac{1}{2} = e^{-x}, \quad x > 0

      So XExp(1)X \sim \text{Exp}(1).

      Similarly: fY(y)=2e2yf_Y(y) = 2e^{-2y}, y>0y > 0. So YExp(2)Y \sim \text{Exp}(2).

      Independence for Continuous Variables

      XX and YY are independent if:

      f(x,y)=fX(x)fY(y)for all x,yf(x, y) = f_X(x) \cdot f_Y(y) \quad \text{for all } x, y

      Equivalently:

      F(x,y)=FX(x)FY(y)F(x, y) = F_X(x) \cdot F_Y(y)

      Example

      For the PDF above:

      fX(x)fY(y)=ex2e2y=2exe2y=f(x,y)f_X(x) f_Y(y) = e^{-x} \cdot 2e^{-2y} = 2e^{-x} e^{-2y} = f(x, y)

      Thus XX and YY are independent.

      Counterexample

      Let f(x,y)=8xyf(x, y) = 8xy on 0xy10 \leq x \leq y \leq 1.

      fX(x)=x18xydy=8x1x22=4x(1x2)f_X(x) = \int_x^1 8xy \, dy = 8x \cdot \frac{1 - x^2}{2} = 4x(1 - x^2)

      fY(y)=0y8xydx=8yy22=4y3f_Y(y) = \int_0^y 8xy \, dx = 8y \cdot \frac{y^2}{2} = 4y^3

      fX(x)fY(y)=16xy3(1x2)8xyf_X(x) f_Y(y) = 16xy^3(1 - x^2) \neq 8xy

      Not independent.

      Example: Computing Probabilities

      For f(x,y)=2exe2yf(x, y) = 2e^{-x} e^{-2y} (x,y>0x, y > 0), find P(X<Y)P(X < Y).

      P(X<Y)=00y2exe2ydxdyP(X < Y) = \int_0^{\infty} \int_0^y 2e^{-x} e^{-2y} \, dx \, dy

      Inner integral: 0y2exdx=2(1ey)\int_0^y 2e^{-x} \, dx = 2(1 - e^{-y})

      P(X<Y)=02e2y2(1ey)dy=40(e2ye3y)dyP(X < Y) = \int_0^{\infty} 2e^{-2y} \cdot 2(1 - e^{-y}) \, dy = 4\int_0^{\infty} (e^{-2y} - e^{-3y}) \, dy

      =4(1213)=416=23= 4\left(\frac{1}{2} - \frac{1}{3}\right) = 4 \cdot \frac{1}{6} = \frac{2}{3}

      Summary

      ConceptFormula
      Joint PDFP((X,Y)A)=Af(x,y)dxdyP((X,Y) \in A) = \iint_A f(x,y) dx dy
      MarginalfX(x)=f(x,y)dyf_X(x) = \int f(x,y) dy
      Independencef(x,y)=fX(x)fY(y)f(x,y) = f_X(x) f_Y(y)
      Joint CDFF(x,y)=P(Xx,Yy)F(x,y) = P(X \leq x, Y \leq y)
    • Marginal Distributions

      Definition

      Given a joint distribution of XX and YY, the marginal distribution of XX gives the distribution of XX alone, ignoring YY.

      The term “marginal” comes from writing joint distributions in tables with totals in the margins.

      Discrete Case

      pX(x)=yp(x,y)p_X(x) = \sum_y p(x, y)

      pY(y)=xp(x,y)p_Y(y) = \sum_x p(x, y)

      Example: Joint Distribution Table

      X\YX \backslash YY=0Y = 0Y=1Y = 1Y=2Y = 2pX(x)p_X(x)
      X=0X = 00.100.050.050.20
      X=1X = 10.150.200.100.45
      X=2X = 20.050.150.150.35
      pY(y)p_Y(y)0.300.400.301.00

      To find pX(0)p_X(0): sum row X=0X = 0: 0.10+0.05+0.05=0.200.10 + 0.05 + 0.05 = 0.20.

      To find pY(1)p_Y(1): sum column Y=1Y = 1: 0.05+0.20+0.15=0.400.05 + 0.20 + 0.15 = 0.40.

      Continuous Case

      fX(x)=f(x,y)dyf_X(x) = \int_{-\infty}^{\infty} f(x, y) \, dy

      fY(y)=f(x,y)dxf_Y(y) = \int_{-\infty}^{\infty} f(x, y) \, dx

      Example

      f(x,y)=6xy on 0x1,0yxf(x, y) = 6xy \text{ on } 0 \leq x \leq 1, 0 \leq y \leq \sqrt{x}

      Find fX(x)f_X(x):

      fX(x)=0x6xydy=6xx2=3x2,0x1f_X(x) = \int_0^{\sqrt{x}} 6xy \, dy = 6x \cdot \frac{x}{2} = 3x^2, \quad 0 \leq x \leq 1

      Find fY(y)f_Y(y):

      First, determine the region. For fixed yy, xx ranges from y2y^2 to 1.

      fY(y)=y216xydx=6y1y42=3y(1y4),0y1f_Y(y) = \int_{y^2}^1 6xy \, dx = 6y \cdot \frac{1 - y^4}{2} = 3y(1 - y^4), \quad 0 \leq y \leq 1

      Why Marginals Matter

      Marginals let us analyse one variable while ignoring others:

      1. Computing P(XA)P(X \in A): Use the marginal of XX
      2. Finding E[X]E[X]: Compute from the marginal
      3. Testing independence: Compare joint to product of marginals

      Information Loss

      Marginals lose information about dependence:

      • Many different joints can give the same marginals
      • Knowing marginals does not determine the joint

      Example: Same Marginals, Different Joints

      Two joint distributions with identical marginals:

      Joint 1 (independent):

      X\YX \backslash YY=0Y = 0Y=1Y = 1
      X=0X = 00.250.25
      X=1X = 10.250.25

      Joint 2 (perfect positive correlation):

      X\YX \backslash YY=0Y = 0Y=1Y = 1
      X=0X = 00.50
      X=1X = 100.5

      Both have XBern(0.5)X \sim \text{Bern}(0.5) and YBern(0.5)Y \sim \text{Bern}(0.5) as marginals, but completely different dependence structures.

      Marginal Expectation

      To compute expectations from marginals:

      E[X]=xxpX(x)orxfX(x)dxE[X] = \sum_x x \cdot p_X(x) \quad \text{or} \quad \int x f_X(x) dx

      Using the joint directly (unnecessary but valid):

      E[X]=xyxp(x,y)E[X] = \sum_x \sum_y x \cdot p(x, y)

      Summary

      ConceptDiscreteContinuous
      Marginal of XXyp(x,y)\sum_y p(x,y)f(x,y)dy\int f(x,y) dy
      Marginal of YYxp(x,y)\sum_x p(x,y)f(x,y)dx\int f(x,y) dx
      LossJoint \to marginal loses dependence info
    • Independence of Random Variables

      Definition

      Random variables XX and YY are independent if:

      F(x,y)=FX(x)FY(y)for all x,yF(x, y) = F_X(x) \cdot F_Y(y) \quad \text{for all } x, y

      Equivalently (for the usual cases):

      Discrete: p(x,y)=pX(x)pY(y)for all x,yp(x, y) = p_X(x) \cdot p_Y(y) \quad \text{for all } x, y

      Continuous: f(x,y)=fX(x)fY(y)for all x,yf(x, y) = f_X(x) \cdot f_Y(y) \quad \text{for all } x, y

      Intuition

      XX and YY are independent if knowing XX gives no information about YY (and vice versa). The joint distribution factors into the product of marginals.

      Checking Independence

      Method 1: Factor Joint into Marginals

      Compute pX(x)p_X(x) and pY(y)p_Y(y), then verify p(x,y)=pX(x)pY(y)p(x, y) = p_X(x) p_Y(y) everywhere.

      Example: p(x,y)=exyp(x, y) = e^{-x-y} for x,y>0x, y > 0.

      pX(x)=exp_X(x) = e^{-x} (marginal) pY(y)=eyp_Y(y) = e^{-y} (marginal)

      pX(x)pY(y)=exey=exy=p(x,y)p_X(x) p_Y(y) = e^{-x} e^{-y} = e^{-x-y} = p(x, y)

      Independent.

      Method 2: Check if Support is Rectangular

      If the support of (X,Y)(X, Y) is not a rectangle (or hyper-rectangle for n>2n > 2), then XX and YY cannot be independent.

      Example: f(x,y)=6xyf(x, y) = 6xy on 0x10 \leq x \leq 1, 0yx0 \leq y \leq \sqrt{x}.

      The support is triangular, not rectangular, so XX and YY are NOT independent.

      Independence Implies

      If XX and YY are independent:

      1. Joint Probability Factors

      P(XA,YB)=P(XA)P(YB)P(X \in A, Y \in B) = P(X \in A) \cdot P(Y \in B)

      2. Expectation of Product

      E[XY]=E[X]E[Y]E[XY] = E[X] E[Y]

      Proof: E[XY]=xyxyp(x,y)=xyxypX(x)pY(y)=(xxpX(x))(yypY(y))=E[X]E[Y]E[XY] = \sum_x \sum_y xy \cdot p(x,y) = \sum_x \sum_y xy \cdot p_X(x) p_Y(y) = \left(\sum_x x p_X(x)\right)\left(\sum_y y p_Y(y)\right) = E[X]E[Y]

      3. Variance of Sum

      Var(X+Y)=Var(X)+Var(Y)\text{Var}(X + Y) = \text{Var}(X) + \text{Var}(Y)

      This follows from E[XY]=E[X]E[Y]E[XY] = E[X]E[Y] for independent variables.

      4. Functions of Independent Variables

      If XX and YY are independent, then g(X)g(X) and h(Y)h(Y) are also independent for any functions g,hg, h.

      Independence Does NOT Imply

      Common misconceptions:

      • Zero correlation \neq independence: Independent implies zero correlation, but the converse is false
      • Uncorrelated \neq independent: Zero covariance doesn’t guarantee independence

      Counterexample

      Let XX be uniform on {1,0,1}\{-1, 0, 1\} and Y=X2Y = X^2.

      Cov(X,Y)=E[XX2]E[X]E[X2]=E[X3]0=0\text{Cov}(X, Y) = E[X \cdot X^2] - E[X] E[X^2] = E[X^3] - 0 = 0

      But XX and YY are clearly not independent: knowing XX completely determines YY.

      Estimates from Data

      If we observe (Xi,Yi)(X_i, Y_i) pairs, we estimate:

      • Marginal of XX: distribution of XiX_i values alone
      • Marginal of YY: distribution of YiY_i values alone
      • Independence: check if joint empirical distribution factorises

      Mutual Independence

      X1,X2,,XnX_1, X_2, \ldots, X_n are mutually independent if:

      F(x1,,xn)=FX1(x1)FXn(xn)F(x_1, \ldots, x_n) = F_{X_1}(x_1) \cdots F_{X_n}(x_n)

      For all subsets, the joint factors into the product of marginals.

      Pairwise independence does NOT imply mutual independence.

      Summary

      ConditionStatement
      IndependenceJoint = product of marginals
      ImpliesE[XY]=E[X]E[Y]E[XY] = E[X]E[Y]
      ImpliesVar(X+Y)=Var(X)+Var(Y)\text{Var}(X+Y) = \text{Var}(X) + \text{Var}(Y)
      Zero correlationDoes NOT imply independence
    • Conditional Distributions

      Motivation

      Conditional distributions describe the distribution of one random variable given that another has a specific value. This is fundamental to regression, prediction, and Bayesian inference.

      Discrete Case

      Conditional PMF

      pYX(yx)=P(Y=yX=x)=p(x,y)pX(x)p_{Y|X}(y \mid x) = P(Y = y \mid X = x) = \frac{p(x, y)}{p_X(x)}

      provided pX(x)>0p_X(x) > 0.

      Properties

      For fixed xx with pX(x)>0p_X(x) > 0, pYX(yx)p_{Y|X}(y \mid x) is a valid PMF:

      • pYX(yx)0p_{Y|X}(y \mid x) \geq 0
      • ypYX(yx)=yp(x,y)pX(x)=pX(x)pX(x)=1\sum_y p_{Y|X}(y \mid x) = \frac{\sum_y p(x,y)}{p_X(x)} = \frac{p_X(x)}{p_X(x)} = 1

      Example: Dice Game

      Roll two dice: XX = first die, YY = second die. Joint: p(x,y)=136p(x,y) = \frac{1}{36}.

      Given X+Y=7X + Y = 7, what is the distribution of XX?

      Let S=X+YS = X + Y. We want pXS(x7)p_{X|S}(x \mid 7).

      Possible pairs with sum 7: (1,6),(2,5),(3,4),(4,3),(5,2),(6,1)(1,6), (2,5), (3,4), (4,3), (5,2), (6,1).

      P(S=7)=636=16P(S = 7) = \frac{6}{36} = \frac{1}{6}

      pXS(x7)=P(X=xS=7)=16 for x=1,,6p_{X|S}(x \mid 7) = P(X = x \mid S = 7) = \frac{1}{6} \text{ for } x = 1, \ldots, 6

      Given the sum is 7, the first die is equally likely to be any value 1 through 6.

      Continuous Case

      Conditional PDF

      fYX(yx)=f(x,y)fX(x)f_{Y|X}(y \mid x) = \frac{f(x, y)}{f_X(x)}

      provided fX(x)>0f_X(x) > 0.

      Interpretation

      fYX(yx)f_{Y|X}(y \mid x) gives the density of YY given that XX takes value xx.

      Example

      f(x,y)=2exe2yf(x, y) = 2e^{-x} e^{-2y} for x,y>0x, y > 0.

      We found fX(x)=exf_X(x) = e^{-x}.

      fYX(yx)=2exe2yex=2e2yf_{Y|X}(y \mid x) = \frac{2e^{-x} e^{-2y}}{e^{-x}} = 2e^{-2y}

      The conditional distribution of YY given X=xX = x is Exp(2)\text{Exp}(2), independent of xx. This confirms XX and YY are independent.

      Conditional Expectation

      The conditional expectation of YY given X=xX = x:

      E[YX=x]=yypYX(yx)(discrete)E[Y \mid X = x] = \sum_y y \cdot p_{Y|X}(y \mid x) \quad \text{(discrete)}

      E[YX=x]=yfYX(yx)dy(continuous)E[Y \mid X = x] = \int y \cdot f_{Y|X}(y \mid x) \, dy \quad \text{(continuous)}

      Example

      From the example above: E[YX=x]=E[Exp(2)]=12E[Y \mid X = x] = E[\text{Exp}(2)] = \frac{1}{2}.

      The conditional expectation is constant (doesn’t depend on xx) when XX and YY are independent.

      Law of Total Expectation

      E[Y]=E[E[YX]]E[Y] = E[E[Y \mid X]]

      More explicitly:

      E[Y]=xE[YX=x]pX(x)(discrete)E[Y] = \sum_x E[Y \mid X = x] \cdot p_X(x) \quad \text{(discrete)}

      E[Y]=E[YX=x]fX(x)dx(continuous)E[Y] = \int E[Y \mid X = x] \cdot f_X(x) \, dx \quad \text{(continuous)}

      Application

      This law lets us compute E[Y]E[Y] by conditioning on XX, often simplifying complex problems.

      Example

      XPois(λ)X \sim \text{Pois}(\lambda) and given X=nX = n, YBin(n,p)Y \sim \text{Bin}(n, p).

      Find E[Y]E[Y].

      By law of total expectation:

      E[Y]=E[E[YX]]=E[Xp]=pE[X]=pλE[Y] = E[E[Y \mid X]] = E[X \cdot p] = p E[X] = p \lambda

      Conditional Variance

      Var(YX=x)=E[Y2X=x](E[YX=x])2\text{Var}(Y \mid X = x) = E[Y^2 \mid X = x] - (E[Y \mid X = x])^2

      Summary

      ConceptDiscreteContinuous
      Conditional PMF/PDFp(x,y)pX(x)\frac{p(x,y)}{p_X(x)}f(x,y)fX(x)\frac{f(x,y)}{f_X(x)}
      Conditional expectation$\sum_y y \cdot p_{YX}(y
      Law of total expectation$E[E[YX]]$
    • Covariance

      Motivation

      Variance measures spread. But how do we measure the joint variability of two random variables? Do they tend to move together or in opposite directions?

      Definition

      The covariance of XX and YY is:

      Cov(X,Y)=E[(XE[X])(YE[Y])]\text{Cov}(X, Y) = E[(X - E[X])(Y - E[Y])]

      Computational Formula

      Cov(X,Y)=E[XY]E[X]E[Y]\text{Cov}(X, Y) = E[XY] - E[X]E[Y]

      Proof:

      E[(XE[X])(YE[Y])]=E[XYXE[Y]E[X]Y+E[X]E[Y]]E[(X - E[X])(Y - E[Y])] = E[XY - XE[Y] - E[X]Y + E[X]E[Y]] =E[XY]E[X]E[Y]E[X]E[Y]+E[X]E[Y]=E[XY]E[X]E[Y]= E[XY] - E[X]E[Y] - E[X]E[Y] + E[X]E[Y] = E[XY] - E[X]E[Y]

      Properties

      1. Symmetry

      Cov(X,Y)=Cov(Y,X)\text{Cov}(X, Y) = \text{Cov}(Y, X)

      2. Variance is Self-Covariance

      Cov(X,X)=E[X2]E[X]2=Var(X)\text{Cov}(X, X) = E[X^2] - E[X]^2 = \text{Var}(X)

      3. Linearity in Each Argument

      Cov(aX+b,Y)=aCov(X,Y)\text{Cov}(aX + b, Y) = a \cdot \text{Cov}(X, Y)

      Cov(X,Y+Z)=Cov(X,Y)+Cov(X,Z)\text{Cov}(X, Y + Z) = \text{Cov}(X, Y) + \text{Cov}(X, Z)

      4. Variance of Sum

      Var(X+Y)=Var(X)+Var(Y)+2Cov(X,Y)\text{Var}(X + Y) = \text{Var}(X) + \text{Var}(Y) + 2\text{Cov}(X, Y)

      General:

      Var(i=1nXi)=i=1nVar(Xi)+2i<jCov(Xi,Xj)\text{Var}\left(\sum_{i=1}^n X_i\right) = \sum_{i=1}^n \text{Var}(X_i) + 2\sum_{i < j} \text{Cov}(X_i, X_j)

      5. Independent Variables Have Zero Covariance

      If XX and YY are independent: Cov(X,Y)=0\text{Cov}(X, Y) = 0.

      Warning: Cov(X,Y)=0\text{Cov}(X, Y) = 0 does NOT imply independence.

      Interpretation

      CovarianceInterpretation
      Cov(X,Y)>0\text{Cov}(X, Y) > 0Positive relationship: XX and YY tend to move together
      Cov(X,Y)<0\text{Cov}(X, Y) < 0Negative relationship: XX and YY tend to move oppositely
      Cov(X,Y)=0\text{Cov}(X, Y) = 0No linear relationship

      Example

      Roll two dice. Let XX = first die, YY = second die, S=X+YS = X + Y.

      E[XS]=E[X(X+Y)]=E[X2]+E[XY]=916+494=E[X \cdot S] = E[X(X+Y)] = E[X^2] + E[XY] = \frac{91}{6} + \frac{49}{4} = \dots

      Since XX and YY independent: Cov(X,Y)=0\text{Cov}(X, Y) = 0.

      But Cov(X,S)=Cov(X,X+Y)=Var(X)+Cov(X,Y)=3512+0=3512>0\text{Cov}(X, S) = \text{Cov}(X, X + Y) = \text{Var}(X) + \text{Cov}(X, Y) = \frac{35}{12} + 0 = \frac{35}{12} > 0.

      XX and SS are positively correlated: higher XX tends to mean higher sum.

      Units

      Covariance has units of X×YX \times Y. If XX is in metres and YY in seconds, Cov(X,Y)\text{Cov}(X,Y) is in metre-seconds.

      This makes interpretation difficult. Correlation (below) normalises to be unitless.

      Example: Pair from Deck

      Draw two cards without replacement. XX = number of hearts in first, YY = number of hearts in second.

      Both XX and YY are Bernoulli with p=14p = \frac{1}{4}.

      By symmetry: E[X]=E[Y]=1352=14E[X] = E[Y] = \frac{13}{52} = \frac{1}{4}.

      E[XY]=P(X=1,Y=1)=P(X=1)P(Y=1X=1)=13521251=1562652E[XY] = P(X = 1, Y = 1) = P(X = 1) P(Y = 1 \mid X = 1) = \frac{13}{52} \cdot \frac{12}{51} = \frac{156}{2652}

      Cov(X,Y)=E[XY]E[X]E[Y]=1562652116=117116=1272\text{Cov}(X, Y) = E[XY] - E[X]E[Y] = \frac{156}{2652} - \frac{1}{16} = \frac{1}{17} - \frac{1}{16} = -\frac{1}{272}

      Negative covariance: drawing a heart first reduces the chance of drawing a heart second.

      Summary

      PropertyFormula
      DefinitionCov(X,Y)=E[(XE[X])(YE[Y])]\text{Cov}(X,Y) = E[(X-E[X])(Y-E[Y])]
      ComputationalCov(X,Y)=E[XY]E[X]E[Y]\text{Cov}(X,Y) = E[XY] - E[X]E[Y]
      Variance of sumVar(X+Y)=Var(X)+Var(Y)+2Cov(X,Y)\text{Var}(X+Y) = \text{Var}(X) + \text{Var}(Y) + 2\text{Cov}(X,Y)
      IndependentCov(X,Y)=0\Rightarrow \text{Cov}(X,Y) = 0
      ConverseCov(X,Y)=0⇏\text{Cov}(X,Y) = 0 \not\Rightarrow independent
    • Correlation

      Definition

      The correlation coefficient (Pearson correlation) is the normalised covariance:

      ρX,Y=Cov(X,Y)σXσY\rho_{X,Y} = \frac{\text{Cov}(X, Y)}{\sigma_X \sigma_Y}

      where σX=Var(X)\sigma_X = \sqrt{\text{Var}(X)} and σY=Var(Y)\sigma_Y = \sqrt{\text{Var}(Y)}.

      Properties

      1. Unitless

      Correlation has no units, making it comparable across different measurements.

      2. Range

      1ρX,Y1-1 \leq \rho_{X,Y} \leq 1

      Proof (Cauchy-Schwarz): Consider E[(a(XE[X])+b(YE[Y]))2]0E[(a(X-E[X]) + b(Y-E[Y]))^2] \geq 0.

      3. Interpretation

      ρ\rhoRelationship
      ρ=1\rho = 1Perfect positive linear relationship
      ρ=1\rho = -1Perfect negative linear relationship
      ρ=0\rho = 0No linear relationship
      ρ>0\rho > 0Positive linear association
      ρ<0\rho < 0Negative linear association

      4. Linear Transformation Invariant

      ρaX+b,cY+d=sign(ac)ρX,Y\rho_{aX+b, cY+d} = \text{sign}(ac) \cdot \rho_{X,Y}

      Correlation doesn’t change if we scale or shift XX and YY.

      Visual Interpretation

      Correlation scatter plots

      • ρ1\rho \approx 1: points cluster along a line with positive slope
      • ρ1\rho \approx -1: points cluster along a line with negative slope
      • ρ0\rho \approx 0: no linear pattern

      Proof of Range

      By Cauchy-Schwarz for random variables:

      E[UV]2E[U2]E[V2]E[UV]^2 \leq E[U^2] E[V^2]

      Let U=XE[X]U = X - E[X] and V=YE[Y]V = Y - E[Y]:

      Cov(X,Y)2Var(X)Var(Y)\text{Cov}(X, Y)^2 \leq \text{Var}(X) \cdot \text{Var}(Y)

      ρ2=Cov(X,Y)2Var(X)Var(Y)1\rho^2 = \frac{\text{Cov}(X,Y)^2}{\text{Var}(X)\text{Var}(Y)} \leq 1

      Thus ρ1|\rho| \leq 1.

      When is ρ=±1\rho = \pm 1?

      ρ=1\rho = 1 if and only if Y=aX+bY = aX + b for some a>0a > 0 (perfect positive linear).

      ρ=1\rho = -1 if and only if Y=aX+bY = aX + b for some a<0a < 0 (perfect negative linear).

      Independence vs Zero Correlation

      • Independent ρ=0\Rightarrow \rho = 0
      • ρ=0\rho = 0 does NOT \Rightarrow independent

      Counterexample

      Let XX be uniform on {1,0,1}\{-1, 0, 1\}, and Y=X2Y = X^2.

      Cov(X,Y)=E[X3]E[X]E[X2]=00=0\text{Cov}(X, Y) = E[X^3] - E[X]E[X^2] = 0 - 0 = 0

      ρ=0\rho = 0, but XX and YY are clearly dependent (knowing XX determines YY).

      The issue: correlation measures linear dependence only. Y=X2Y = X^2 is a perfect nonlinear relationship.

      Sample Correlation

      From data (X1,Y1),,(Xn,Yn)(X_1, Y_1), \ldots, (X_n, Y_n):

      r=(XiXˉ)(YiYˉ)(XiXˉ)2(YiYˉ)2r = \frac{\sum(X_i - \bar{X})(Y_i - \bar{Y})}{\sqrt{\sum(X_i - \bar{X})^2} \sqrt{\sum(Y_i - \bar{Y})^2}}

      Example

      From earlier: drawing cards, Cov(X,Y)=1272\text{Cov}(X, Y) = -\frac{1}{272}.

      Var(X)=1434=316\text{Var}(X) = \frac{1}{4} \cdot \frac{3}{4} = \frac{3}{16}, same for Var(Y)\text{Var}(Y).

      ρ=1/2723/163/16=1/2723/16=162723=151\rho = \frac{-1/272}{\sqrt{3/16} \cdot \sqrt{3/16}} = \frac{-1/272}{3/16} = -\frac{16}{272 \cdot 3} = -\frac{1}{51}

      Small negative correlation.

      Summary

      PropertyValue
      Definitionρ=Cov(X,Y)σXσY\rho = \frac{\text{Cov}(X,Y)}{\sigma_X \sigma_Y}
      Range[1,1][-1, 1]
      ρ=1\rho = 1Perfect positive linear
      ρ=1\rho = -1Perfect negative linear
      ρ=0\rho = 0No linear relationship
      LimitationDoesn’t capture nonlinear dependence
    • Sums of Random Variables

      Distribution of Sums

      If XX and YY are random variables, what is the distribution of X+YX + Y?

      Discrete Case

      The PMF of S=X+YS = X + Y:

      P(S=s)=xP(X=x,Y=sx)P(S = s) = \sum_x P(X = x, Y = s - x)

      If independent:

      P(S=s)=xP(X=x)P(Y=sx)P(S = s) = \sum_x P(X = x) P(Y = s - x)

      This is a convolution of the PMFs.

      Continuous Case

      The PDF of S=X+YS = X + Y:

      fS(s)=f(x,sx)dxf_S(s) = \int_{-\infty}^{\infty} f(x, s - x) \, dx

      If independent:

      fS(s)=fX(x)fY(sx)dxf_S(s) = \int_{-\infty}^{\infty} f_X(x) f_Y(s - x) \, dx

      Known Sums

      Sum of Independent Binomials (Same pp)

      XBin(n1,p),YBin(n2,p)X \sim \text{Bin}(n_1, p), \quad Y \sim \text{Bin}(n_2, p)

      X+YBin(n1+n2,p)X + Y \sim \text{Bin}(n_1 + n_2, p)

      Intuition: Adding two independent counts from Bernoulli trials with same pp.

      Sum of Independent Poissons

      XPois(λ1),YPois(λ2)X \sim \text{Pois}(\lambda_1), \quad Y \sim \text{Pois}(\lambda_2)

      X+YPois(λ1+λ2)X + Y \sim \text{Pois}(\lambda_1 + \lambda_2)

      Intuition: Merging two independent event streams.

      Sum of Independent Normals

      XN(μ1,σ12),YN(μ2,σ22)X \sim N(\mu_1, \sigma_1^2), \quad Y \sim N(\mu_2, \sigma_2^2)

      X+YN(μ1+μ2,σ12+σ22)X + Y \sim N(\mu_1 + \mu_2, \sigma_1^2 + \sigma_2^2)

      Intuition: Adding Gaussian noise gives Gaussian noise.

      Sum of Independent Exponentials (Same Rate)

      X1,,XnExp(λ) independentX_1, \ldots, X_n \sim \text{Exp}(\lambda) \text{ independent}

      i=1nXiGamma(n,λ)\sum_{i=1}^n X_i \sim \text{Gamma}(n, \lambda)

      Moment Computations

      Regardless of distribution:

      Expectation

      E[X+Y]=E[X]+E[Y]E[X + Y] = E[X] + E[Y]

      Always holds (no independence needed).

      Variance

      Var(X+Y)=Var(X)+Var(Y)+2Cov(X,Y)\text{Var}(X + Y) = \text{Var}(X) + \text{Var}(Y) + 2\text{Cov}(X, Y)

      If independent:

      Var(X+Y)=Var(X)+Var(Y)\text{Var}(X + Y) = \text{Var}(X) + \text{Var}(Y)

      Example: Sum of Dice

      Roll two fair dice. X,Y{1,,6}X, Y \in \{1, \ldots, 6\} uniform, independent.

      S=X+YS = X + Y has range {2,3,,12}\{2, 3, \ldots, 12\}.

      P(S=7)=x=16P(X=x)P(Y=7x)=x=161616=636=16P(S = 7) = \sum_{x=1}^{6} P(X = x) P(Y = 7 - x) = \sum_{x=1}^{6} \frac{1}{6} \cdot \frac{1}{6} = \frac{6}{36} = \frac{1}{6}

      P(S=2)=P(X=1)P(Y=1)=136P(S = 2) = P(X = 1) P(Y = 1) = \frac{1}{36}

      Convolution Visualisation

      The sum distribution is obtained by “sliding” one distribution past the other and multiplying.

      Convolution of distributions

      Linear Combinations

      For constants aa and bb:

      E[aX+bY]=aE[X]+bE[Y]E[aX + bY] = aE[X] + bE[Y]

      Var(aX+bY)=a2Var(X)+b2Var(Y)+2abCov(X,Y)\text{Var}(aX + bY) = a^2\text{Var}(X) + b^2\text{Var}(Y) + 2ab\text{Cov}(X, Y)

      If independent:

      Var(aX+bY)=a2Var(X)+b2Var(Y)\text{Var}(aX + bY) = a^2\text{Var}(X) + b^2\text{Var}(Y)

      Sum of I.I.D. Variables

      Let X1,,XnX_1, \ldots, X_n be i.i.d. with mean μ\mu and variance σ2\sigma^2.

      Define Sn=i=1nXiS_n = \sum_{i=1}^n X_i and Xˉ=Sn/n\bar{X} = S_n / n.

      E[Sn]=nμ,Var(Sn)=nσ2E[S_n] = n\mu, \quad \text{Var}(S_n) = n\sigma^2

      E[Xˉ]=μ,Var(Xˉ)=σ2nE[\bar{X}] = \mu, \quad \text{Var}(\bar{X}) = \frac{\sigma^2}{n}

      Averaging reduces variance proportionally to nn.

      Summary

      VariablesSum DistributionSum MeanSum Variance
      Binomial (same pp)Binomial(n1+n2)p(n_1+n_2)p(n1+n2)p(1p)(n_1+n_2)p(1-p)
      PoissonPoissonλ1+λ2\lambda_1 + \lambda_2λ1+λ2\lambda_1 + \lambda_2
      NormalNormalμ1+μ2\mu_1 + \mu_2σ12+σ22\sigma_1^2 + \sigma_2^2
      GeneralConvolutionE[X]+E[Y]E[X] + E[Y]Always additive if independent
  • Limit Theorems

    Inequalities, laws of large numbers, and the central limit theorem

    • Markov's Inequality

      Motivation

      Can we bound how often a non-negative random variable takes large values? Markov’s inequality gives a simple but powerful bound using only the mean.

      Statement

      If XX is a non-negative random variable (i.e., X0X \geq 0 with probability 1) with finite expectation E[X]E[X], then for any a>0a > 0:

      P(Xa)E[X]aP(X \geq a) \leq \frac{E[X]}{a}

      Proof

      Since X0X \geq 0:

      Xa1XaX \geq a \cdot \mathbb{1}_{X \geq a}

      where 1Xa\mathbb{1}_{X \geq a} is the indicator of the event {Xa}\{X \geq a\}.

      Taking expectations:

      E[X]aE[1Xa]=aP(Xa)E[X] \geq a \cdot E[\mathbb{1}_{X \geq a}] = a \cdot P(X \geq a)

      Therefore:

      P(Xa)E[X]aP(X \geq a) \leq \frac{E[X]}{a}

      Visual Intuition

      The area under the tail beyond aa cannot exceed E[X]/aE[X]/a, since otherwise the total area would exceed the mean.

      Markov's inequality visualisation

      Alternative Form

      For non-negative XX:

      P(XkE[X])1kP(X \geq k E[X]) \leq \frac{1}{k}

      Interpretation: At most 1/k1/k of the distribution lies at kk or more times the mean.

      Example

      If E[X]=10E[X] = 10, then:

      P(X30)=P(X3E[X])13P(X \geq 30) = P(X \geq 3 \cdot E[X]) \leq \frac{1}{3}

      At most one-third of values are at least 30.

      Examples

      Example 1: Mean 5

      A non-negative random variable has mean 5. What can we say about P(X10)P(X \geq 10)?

      P(X10)E[X]10=510=0.5P(X \geq 10) \leq \frac{E[X]}{10} = \frac{5}{10} = 0.5

      At most 50% of probability lies at or above 10.

      Example 2: Exam Scores

      Scores are non-negative with mean 70. What proportion score at least 90?

      P(X90)70900.78P(X \geq 90) \leq \frac{70}{90} \approx 0.78

      At most 78% can score 90 or higher. (The true proportion is likely much smaller, but this is the bound.)

      Example 3: Something True for Exponential

      If XExp(λ)X \sim \text{Exp}(\lambda), then E[X]=1/λE[X] = 1/\lambda.

      Markov: P(X1)=P(XλE[X])1/λP(X \geq 1) = P(X \geq \lambda E[X]) \leq 1/\lambda.

      Actual: P(X1)=eλλP(X \geq 1) = e^{-\lambda} \leq \lambda.

      For λ=1\lambda = 1: Markov gives P(X1)1P(X \geq 1) \leq 1. True but useless!

      Markov’s bound can be very loose.

      Corollary: Bounded Variables

      If XX is bounded in [0,M][0, M], then:

      P(XMa)ME[X]aP(X \leq M - a) \leq \frac{M - E[X]}{a}

      Or equivalently:

      P(XMa)E[X]+aMaP(X \geq M - a) \geq \frac{E[X] + a - M}{a}

      Limitations

      1. Only uses the mean: Much stronger bounds are possible with more information (like variance)
      2. Often loose: The bound can be far from the actual probability
      3. Non-negative only: Only applies to X0X \geq 0

      Why Useful?

      Despite being loose, Markov’s inequality is:

      • Simple to apply
      • Requires only the mean
      • Foundation for stronger bounds (Chebyshev)

      Summary

      PropertyStatement
      ConditionX0X \geq 0 with finite mean
      InequalityP(Xa)E[X]aP(X \geq a) \leq \frac{E[X]}{a}
      Scaled formP(XkE[X])1kP(X \geq k E[X]) \leq \frac{1}{k}
      LimitationCan be very loose
    • Chebyshev's Inequality

      Motivation

      Markov’s inequality uses only the mean. Chebyshev’s inequality uses both mean and variance to get stronger bounds on deviations.

      Statement

      For any random variable XX with finite mean μ\mu and finite variance σ2\sigma^2:

      P(Xμkσ)1k2P(|X - \mu| \geq k\sigma) \leq \frac{1}{k^2}

      for any k>0k > 0.

      Alternative Form

      P(Xμa)σ2a2P(|X - \mu| \geq a) \leq \frac{\sigma^2}{a^2}

      Proof

      Apply Markov’s inequality to (Xμ)2(X - \mu)^2, which is non-negative with mean σ2\sigma^2:

      P(Xμa)=P((Xμ)2a2)E[(Xμ)2]a2=σ2a2P(|X - \mu| \geq a) = P((X - \mu)^2 \geq a^2) \leq \frac{E[(X - \mu)^2]}{a^2} = \frac{\sigma^2}{a^2}

      Substitute a=kσa = k\sigma:

      P(Xμkσ)σ2k2σ2=1k2P(|X - \mu| \geq k\sigma) \leq \frac{\sigma^2}{k^2\sigma^2} = \frac{1}{k^2}

      Interpretation

      | kk | P(Xμkσ)P(|X - \mu| \geq k\sigma) | |-----|----------------------------| | 1 | 1\leq 1 (useless bound) | | 2 | 0.25\leq 0.25 | | 3 | 0.11\leq 0.11 |

      For ANY distribution (with finite variance), at most 25% of values lie beyond 2 standard deviations from the mean, and at most 11% beyond 3 standard deviations.

      Compare to normal: For N(μ,σ2)N(\mu, \sigma^2), P(Xμ2σ)0.05P(|X - \mu| \geq 2\sigma) \approx 0.05 and P(Xμ3σ)0.003P(|X - \mu| \geq 3\sigma) \approx 0.003. Chebyshev gives worst-case bounds.

      Visualisation

      Chebyshev's inequality

      Example

      Test scores have mean 70 and variance 100 (SD = 10). What proportion might score below 50 or above 90?

      X7020=2σ|X - 70| \geq 20 = 2\sigma.

      P(X7020)14P(|X - 70| \geq 20) \leq \frac{1}{4}

      At most 25% can be more than 20 points from the mean.

      For a normal distribution, this would be about 5%: Chebyshev is conservative.

      Example: Sample Mean

      Let Xˉn=1ni=1nXi\bar{X}_n = \frac{1}{n}\sum_{i=1}^n X_i where XiX_i are i.i.d. with mean μ\mu and variance σ2\sigma^2.

      E[Xˉn]=μE[\bar{X}_n] = \mu and Var(Xˉn)=σ2/n\text{Var}(\bar{X}_n) = \sigma^2/n.

      P(Xˉnμϵ)σ2/nϵ2=σ2nϵ2P\left(|\bar{X}_n - \mu| \geq \epsilon\right) \leq \frac{\sigma^2/n}{\epsilon^2} = \frac{\sigma^2}{n\epsilon^2}

      This decays as nn \to \infty: the sample mean concentrates around μ\mu.

      One-Sided Chebyshev

      For P(Xμa)P(X - \mu \geq a) (one direction only), we can use:

      P(Xμa)σ2σ2+a2P(X - \mu \geq a) \leq \frac{\sigma^2}{\sigma^2 + a^2}

      Better than two-sided Chebyshev of σ2/a2\sigma^2/a^2 when a/σ<1a/\sigma < 1.

      Comparison with Markov

      InequalityInformation RequiredBound
      MarkovE[X]E[X], X0X \geq 0P(Xa)E[X]/aP(X \geq a) \leq E[X]/a
      ChebyshevE[X]E[X], Var(X)\text{Var}(X)$P(

      Chebyshev is stronger but requires variance (and is symmetric about the mean).

      Application: Proving Convergence

      Given ϵ>0\epsilon > 0 and nn samples:

      P(Xˉnμϵ)σ2nϵ2P(|\bar{X}_n - \mu| \geq \epsilon) \leq \frac{\sigma^2}{n\epsilon^2}

      For any ϵ>0\epsilon > 0, choose N>σ2/ϵ2δN > \sigma^2/\epsilon^2 \cdot \delta to ensure P(Xˉnμϵ)<δP(|\bar{X}_n - \mu| \geq \epsilon) < \delta for all nNn \geq N.

      Summary

      PropertyStatement
      ConditionFinite μ\mu and σ2\sigma^2
      Inequality$P(
      Alternative$P(
      StrengthWorks for any distribution
      WeaknessOften conservative
    • Weak Law of Large Numbers

      Statement

      Let X1,X2,X_1, X_2, \ldots be i.i.d. random variables with finite mean μ\mu and finite variance σ2\sigma^2. Define the sample mean:

      Xˉn=1ni=1nXi\bar{X}_n = \frac{1}{n} \sum_{i=1}^n X_i

      Theorem (Weak Law of Large Numbers): For any ϵ>0\epsilon > 0:

      limnP(Xˉnμ>ϵ)=0\lim_{n \to \infty} P(|\bar{X}_n - \mu| > \epsilon) = 0

      The sample mean converges in probability to the true mean.

      Interpretation

      As we collect more data, the sample mean gets arbitrarily close to the true mean with high probability. This justifies using Xˉn\bar{X}_n to estimate μ\mu.

      “Power of Averaging”: Repeated samples allow us to estimate μ\mu with increasing precision.

      Proof (Using Chebyshev)

      E[Xˉn]=μ,Var(Xˉn)=σ2nE[\bar{X}_n] = \mu, \quad \text{Var}(\bar{X}_n) = \frac{\sigma^2}{n}

      By Chebyshev’s inequality:

      P(Xˉnμϵ)Var(Xˉn)ϵ2=σ2nϵ2P(|\bar{X}_n - \mu| \geq \epsilon) \leq \frac{\text{Var}(\bar{X}_n)}{\epsilon^2} = \frac{\sigma^2}{n\epsilon^2}

      As nn \to \infty: σ2nϵ20\frac{\sigma^2}{n\epsilon^2} \to 0.

      Therefore:

      limnP(Xˉnμϵ)=0\lim_{n \to \infty} P(|\bar{X}_n - \mu| \geq \epsilon) = 0

      Convergence in Probability

      The WLLN says XˉnPμ\bar{X}_n \xrightarrow{P} \mu (converges in probability).

      This means: for any ϵ>0,δ>0\epsilon > 0, \delta > 0, there exists NN such that for all nNn \geq N:

      P(Xˉnμ<ϵ)>1δP(|\bar{X}_n - \mu| < \epsilon) > 1 - \delta

      Example: Coin Flips

      Flip a fair coin nn times. Let Xi=1X_i = 1 if heads, 0 otherwise. μ=0.5\mu = 0.5.

      The sample proportion Xˉn\bar{X}_n estimates the true probability.

      For n=100n = 100:

      P(Xˉ1000.50.1)0.25100×0.01=0.251=0.25P(|\bar{X}_{100} - 0.5| \geq 0.1) \leq \frac{0.25}{100 \times 0.01} = \frac{0.25}{1} = 0.25

      At most 25% chance the sample proportion deviates by more than 0.1 from 0.5.

      For n=10000n = 10000:

      P(Xˉ100000.50.1)0.0025P(|\bar{X}_{10000} - 0.5| \geq 0.1) \leq 0.0025

      Only 0.25% chance of such deviation.

      What WLLN Does NOT Say

      1. Not “almost all” sequences: WLLN doesn’t say Xˉn\bar{X}_n will eventually stay close to μ\mu for almost every sequence (that’s the Strong Law)

      2. Doesn’t give rate: WLLN says probability goes to 0, but not how fast (CLT gives the rate)

      3. Requires finite variance: The proof using Chebyshev needs σ2<\sigma^2 < \infty (though WLLN holds with only finite mean)

      Visualisation

      As nn increases, the distribution of Xˉn\bar{X}_n becomes more concentrated around μ\mu.

      WLLN convergence

      Weaker Conditions

      WLLN holds under weaker conditions:

      • Finite mean suffices (proof more subtle)
      • Variance need not be finite

      Historical Quote

      “For even the most stupid of men, by some instinct of nature, by himself and without any instruction (which is a remarkable thing), is convinced that the more observations have been made, the less danger there is of wandering from one’s goal.” — Jacob Bernoulli (1655-1705)

      Summary

      PropertyStatement
      AssumptionsXiX_i i.i.d. with finite μ\mu, σ2\sigma^2
      ConclusionXˉnPμ\bar{X}_n \xrightarrow{P} \mu
      Rate$P(
      ApplicationJustifies sample mean as estimator
    • Strong Law of Large Numbers

      Statement

      Let X1,X2,X_1, X_2, \ldots be i.i.d. random variables with finite mean μ\mu. The Strong Law of Large Numbers states:

      P(limnXˉn=μ)=1P\left(\lim_{n \to \infty} \bar{X}_n = \mu\right) = 1

      where Xˉn=1ni=1nXi\bar{X}_n = \frac{1}{n}\sum_{i=1}^n X_i.

      Interpretation

      With probability 1, the sequence Xˉn\bar{X}_n converges to μ\mu and stays close forever.

      This is stronger than the Weak Law:

      • Weak Law: For any ϵ\epsilon, P(Xˉnμ>ϵ)0P(|\bar{X}_n - \mu| > \epsilon) \to 0
      • Strong Law: The probability that Xˉnμ\bar{X}_n \to \mu is 1

      Almost Sure Convergence

      The SLLN says Xˉna.s.μ\bar{X}_n \xrightarrow{a.s.} \mu (converges almost surely).

      This means: the set of outcomes where limnXˉn=μ\lim_{n \to \infty} \bar{X}_n = \mu has probability 1.

      Almost Surely vs In Probability

      TypeStatement
      In probabilityFor each ϵ\epsilon: $P(
      Almost surelyP(limnXˉn=μ)=1P(\lim_{n \to \infty} \bar{X}_n = \mu) = 1

      The difference:

      • In probability: for large nn, Xˉn\bar{X}_n is probably close to μ\mu (but may occasionally jump away)
      • Almost surely: with probability 1, Xˉn\bar{X}_n eventually stays close to μ\mu forever

      Analogy

      Think of Xˉn\bar{X}_n as a particle:

      • WLLN: At time nn, particle is probably near μ\mu
      • SLLN: Particle eventually stays near μ\mu forever (with probability 1)

      Why Stronger?

      Almost sure convergence implies convergence in probability, but not vice versa.

      In probability allows infinitely many “large” deviations, as long as their frequency goes to 0. Almost surely forces convergence with only finitely many large deviations.

      Example: Repeated Experiments

      Suppose we repeatedly estimate a probability by sampling. SLLN says:

      • With probability 1, our estimate sequence converges to the true probability
      • Eventually, our estimate “locks in” to the truth

      This is why long-run frequencies converge to probabilities.

      Intuition: Borel-Cantelli

      Under appropriate conditions, the event {Xˉnμ>ϵ}\{|\bar{X}_n - \mu| > \epsilon\} happens only finitely many times almost surely.

      Since for any ϵ>0\epsilon > 0:

      n=1P(Xˉnμ>ϵ)<\sum_{n=1}^{\infty} P(|\bar{X}_n - \mu| > \epsilon) < \infty

      By Borel-Cantelli: P(Xˉnμ>ϵ infinitely often)=0P(|\bar{X}_n - \mu| > \epsilon \text{ infinitely often}) = 0.

      What Conditions Are Needed?

      SLLN holds if either:

      1. E[Xi]<E[|X_i|] < \infty (finite mean suffices)
      2. Or: E[Xi2]<E[X_i^2] < \infty (finite variance, easier proof)

      The variance condition makes the proof simpler but isn’t necessary.

      No Guarantee of Rate

      Like WLLN, the SLLN doesn’t tell us how fast convergence occurs. For rate, use the CLT.

      Summary Table

      LawConvergenceStatement
      WLLNProbability$P(
      SLLNAlmost sureP(limXˉn=μ)=1P(\lim \bar{X}_n = \mu) = 1

      Key Takeaway

      Both laws justify using sample means as estimators. The Strong Law is conceptually stronger: it says our estimator will ultimately stabilise at the truth with certainty.

    • Central Limit Theorem

      Motivation

      The Laws of Large Numbers say Xˉn\bar{X}_n converges to μ\mu. But how fast, and what is the distribution of Xˉn\bar{X}_n for large nn?

      The CLT answers: it’s approximately normal.

      Statement

      Let X1,X2,X_1, X_2, \ldots be i.i.d. with mean μ\mu and variance σ2\sigma^2 (0<σ2<0 < \sigma^2 < \infty). Define:

      Xˉn=1ni=1nXi\bar{X}_n = \frac{1}{n}\sum_{i=1}^n X_i

      Central Limit Theorem:

      Xˉnμσ/ndN(0,1)\frac{\bar{X}_n - \mu}{\sigma/\sqrt{n}} \xrightarrow{d} N(0, 1)

      Equivalently:

      n(Xˉnμ)dN(0,σ2)\sqrt{n}(\bar{X}_n - \mu) \xrightarrow{d} N(0, \sigma^2)

      Or:

      i=1nXiN(nμ,nσ2)\sum_{i=1}^n X_i \approx N(n\mu, n\sigma^2)

      for large nn.

      Interpretation

      • The sample mean Xˉn\bar{X}_n is approximately normal
      • Mean: μ\mu
      • Variance: σ2/n\sigma^2/n (decreases with nn)
      • Standard error: σ/n\sigma/\sqrt{n}

      The ”n\sqrt{n} rate”: standard deviation shrinks as 1/n1/\sqrt{n}.

      Normal Approximation

      For large nn:

      P(aXˉnμσ/nb)Φ(b)Φ(a)P\left(a \leq \frac{\bar{X}_n - \mu}{\sigma/\sqrt{n}} \leq b\right) \approx \Phi(b) - \Phi(a)

      This works regardless of the original distribution of XiX_i.

      Conditions

      1. Independence: XiX_i are independent
      2. Identical distribution: XiX_i have the same distribution
      3. Finite variance: σ2<\sigma^2 < \infty

      The CLT works for most common distributions.

      Example: Coin Flips

      Flip fair coin n=100n = 100 times. Xi{0,1}X_i \in \{0, 1\} with μ=0.5\mu = 0.5, σ2=0.25\sigma^2 = 0.25.

      Total heads: S100=i=1100XiS_{100} = \sum_{i=1}^{100} X_i.

      By CLT: S100N(50,25)S_{100} \approx N(50, 25), so:

      P(S10060)=P(S10050560505)P(Z2)=0.0228P(S_{100} \geq 60) = P\left(\frac{S_{100} - 50}{5} \geq \frac{60 - 50}{5}\right) \approx P(Z \geq 2) = 0.0228

      Exact (binomial): P(S10060)=k=60100(100k)0.51000.028P(S_{100} \geq 60) = \sum_{k=60}^{100} \binom{100}{k} 0.5^{100} \approx 0.028.

      CLT approximation is close.

      Continuity Correction

      When approximating discrete distributions, add 0.5:

      P(Snk)P(Zk0.5nμσn)P(S_n \geq k) \approx P\left(Z \geq \frac{k - 0.5 - n\mu}{\sigma\sqrt{n}}\right)

      Using continuity correction in coin example:

      P(S10060)P(Z59.5505)=P(Z1.9)=0.0287P(S_{100} \geq 60) \approx P\left(Z \geq \frac{59.5 - 50}{5}\right) = P(Z \geq 1.9) = 0.0287

      Better approximation: 0.0287 vs exact 0.028.

      Visualisation

      As nn increases, the distribution of Xˉn\bar{X}_n becomes more bell-shaped and narrower.

      CLT convergence for different sample sizes

      Why Does It Work?

      Each XiX_i contributes a “small random perturbation”. The sum of many small independent random effects tends toward normality.

      This explains why many natural phenomena are normally distributed: they result from many small factors additive up.

      Application: Confidence Intervals

      Approximate 95% confidence interval for μ\mu:

      Xˉn±1.96σn\bar{X}_n \pm 1.96 \frac{\sigma}{\sqrt{n}}

      where σ\sigma is known, or replaced by sample standard deviation ss for large nn.

      Rate of Convergence

      CLT gives the rate: O(1/n)O(1/\sqrt{n}). The error in the CLT approximation is typically O(1/n)O(1/\sqrt{n}), quantified by the Berry-Esseen theorem.

      Example: Load Times

      A website has average page load time μ=2\mu = 2 seconds, SD σ=0.5\sigma = 0.5 seconds. For n=25n = 25 users:

      Xˉ25N(2,0.52/25)=N(2,0.01)\bar{X}_{25} \approx N(2, 0.5^2/25) = N(2, 0.01)

      P(Xˉ25>2.2)=P(Z>2.220.1)=P(Z>2)0.0228P(\bar{X}_{25} > 2.2) = P\left(Z > \frac{2.2 - 2}{0.1}\right) = P(Z > 2) \approx 0.0228

      Summary

      AspectStatement
      Conclusionn(Xˉnμ)dN(0,σ2)\sqrt{n}(\bar{X}_n - \mu) \xrightarrow{d} N(0, \sigma^2)
      RateO(1/n)O(1/\sqrt{n})
      ApproximationXˉnN(μ,σ2/n)\bar{X}_n \approx N(\mu, \sigma^2/n)
      Conditionsi.i.d., finite σ2\sigma^2
    • Comparing WLLN, SLLN, and CLT

      Overview

      These three theorems describe different aspects of how sample means behave as sample size grows.

      TheoremWhat It SaysType of Convergence
      WLLNXˉnμ\bar{X}_n \to \muIn probability
      SLLNXˉnμ\bar{X}_n \to \muAlmost surely
      CLTn(Xˉnμ)N(0,σ2)\sqrt{n}(\bar{X}_n - \mu) \to N(0, \sigma^2)In distribution

      Weak Law of Large Numbers (WLLN)

      Statement: P(Xˉnμ>ϵ)0P(|\bar{X}_n - \mu| > \epsilon) \to 0 as nn \to \infty.

      Meaning: For large nn, Xˉn\bar{X}_n is probably close to μ\mu.

      Key insight: Each fixed ϵ\epsilon bound gives a probability going to zero.

      Analogy: Like a particle that is probably near μ\mu at any large time nn, but might occasionally wander away.

      Strong Law of Large Numbers (SLLN)

      Statement: P(Xˉnμ as n)=1P(\bar{X}_n \to \mu \text{ as } n \to \infty) = 1.

      Meaning: With probability 1, Xˉn\bar{X}_n converges to μ\mu and stays there.

      Key insight: Almost all sequences converge and stay converged.

      Analogy: Like a particle that eventually settles at μ\mu and stays there forever.

      Central Limit Theorem (CLT)

      Statement: n(Xˉnμ)dN(0,σ2)\sqrt{n}(\bar{X}_n - \mu) \xrightarrow{d} N(0, \sigma^2).

      Meaning: The scaled deviation from μ\mu has a normal distribution.

      Key insight: Gives the distribution and rate, not just convergence.

      Analogy: Like knowing how the particle’s distance from μ\mu is distributed at each nn.

      Visual Comparison

      Comparison of WLLN, SLLN, CLT

      When to Use Each

      GoalUse
      Show estimator is consistentWLLN or SLLN
      показать “probably close”WLLN
      Show “eventually stays close”SLLN
      Compute approximate probabilitiesCLT
      Find confidence intervalsCLT
      Determine rate of convergenceCLT

      Mathematical Hierarchy

      Almost sure convergenceConvergence in probabilityConvergence in distribution\text{Almost sure convergence} \Rightarrow \text{Convergence in probability} \Rightarrow \text{Convergence in distribution}

      SLLN \Rightarrow WLLN is immediate.

      CLT is about distribution, not about Xˉn\bar{X}_n directly converging.

      Rate Information

      TheoremRate Information
      WLLNNone (just says probability → 0)
      SLLNNone (just says stays converged)
      CLTO(1/n)O(1/\sqrt{n}) (explicit distribution)

      Chebyshev gives WLLN rate: P(Xˉnμ>ϵ)σ2/(nϵ2)P(|\bar{X}_n - \mu| > \epsilon) \leq \sigma^2/(n\epsilon^2).

      CLT gives exact asymptotic distribution: n(Xˉnμ)N(0,σ2)\sqrt{n}(\bar{X}_n - \mu) \sim N(0, \sigma^2).

      Example: Estimating a Probability

      Estimate p=P(success)p = P(\text{success}) by sample proportion p^n\hat{p}_n.

      • WLLN: For large nn, p^n\hat{p}_n is probably near pp
      • SLLN: With probability 1, p^np\hat{p}_n \to p eventually
      • CLT: n(p^np)N(0,p(1p))\sqrt{n}(\hat{p}_n - p) \approx N(0, p(1-p))

      For confidence interval (CLT): p^n±1.96p^n(1p^n)n\hat{p}_n \pm 1.96\sqrt{\frac{\hat{p}_n(1-\hat{p}_n)}{n}}

      Example: Average Height

      Measure heights of random people.

      • WLLN: Sample average converges to population mean in probability
      • SLLN: Sample average eventually stabilises at population mean
      • CLT: For n=100n = 100, Xˉ100N(μ,σ2/100)\bar{X}_{100} \approx N(\mu, \sigma^2/100)

      Why All Three?

      They answer different questions:

      1. Does it converge? WLLN/SLLN
      2. Does it stay converged? SLLN
      3. What’s the distribution? CLT
      4. How fast? CLT

      Practical Takeaway

      • WLLN: Justifies using sample mean as point estimator
      • SLLN: Guarantees long-run stability of estimators
      • CLT: Enables probabilistic statements, confidence intervals, hypothesis tests

      Summary

      AspectWLLNSLLNCLT
      Convergence typeProbabilityAlmost sureDistribution
      RateImplicitNoneExplicit O(1/n)O(1/\sqrt{n})
      Distribution infoNoNoYes (normal)
      Use caseBasic justificationLong-run guaranteesProbability computation
    • Cauchy Distribution: Where Limit Theorems Fail

      The Cauchy Distribution

      The Cauchy distribution is a continuous probability distribution that serves as a cautionary example: neither the WLLN nor CLT apply.

      PDF

      f(x)=1π(1+x2),xRf(x) = \frac{1}{\pi(1 + x^2)}, \quad x \in \mathbb{R}

      Standard Cauchy has parameters x0=0x_0 = 0 (location) and γ=1\gamma = 1 (scale).

      CDF

      F(x)=12+1πarctan(x)F(x) = \frac{1}{2} + \frac{1}{\pi}\arctan(x)

      Heavy Tails

      The Cauchy distribution has very heavy tails. Compare to standard normal:

      limxP(Cauchy>x)P(Normal>x)=\lim_{x \to \infty} \frac{P(\text{Cauchy} > x)}{P(\text{Normal} > x)} = \infty

      The Cauchy tails decay like x2x^{-2}, much slower than the normal’s ex2/2e^{-x^2/2}.

      Cauchy vs Normal tails

      No Finite Mean

      The mean of Cauchy does not exist.

      Attempt to Compute Mean

      x1π(1+x2)dx=1πx1+x2dx\int_{-\infty}^{\infty} x \cdot \frac{1}{\pi(1+x^2)} dx = \frac{1}{\pi} \int_{-\infty}^{\infty} \frac{x}{1+x^2} dx

      This integral is principally undefined:

      0x1+x2dx=\int_{-\infty}^{0} \frac{x}{1+x^2} dx = -\infty

      0x1+x2dx=+\int_{0}^{\infty} \frac{x}{1+x^2} dx = +\infty

      We get \infty - \infty, which is undefined. Even the Cauchy principal value is 0, but this is not a proper expectation.

      No Finite Variance

      Without a finite mean, variance is also undefined. In fact, E[X2]=E[X^2] = \infty for Cauchy.

      Why WLLN and CLT Fail

      Both require finite mean and/or variance:

      • WLLN: Requires E[X]<E[X] < \infty
      • SLLN: Requires E[X]<E[X] < \infty
      • CLT: Requires E[X2]<E[X^2] < \infty (finite variance)

      Cauchy has neither finite mean nor finite variance.

      Average of Cauchy Variables

      If X1,X2,X_1, X_2, \ldots are i.i.d. Cauchy, then Xˉn\bar{X}_n is also Cauchy. It does not concentrate around any value as nn \to \infty.

      Intuition: Outliers are so extreme that they dominate the average, even as nn grows.

      Physical Interpretation

      The Cauchy distribution arises as the distribution of X=tan(θ)X = \tan(\theta) where θ\theta is uniform on (π/2,π/2)(-\pi/2, \pi/2).

      This models:

      • Light refracted at random angle
      • Ratio of two independent normals with mean 0
      • Resonance lines in spectroscopy

      Example: Averages Don’t Converge

      Generate Cauchy samples and compute running averages. The average will keep jumping around rather than settling to a value.

      Unlike normal or exponential samples where Xˉn\bar{X}_n converges, Cauchy averages are “sticky” to extreme values.

      Visually Comparing Averages

      • Normal: sample mean stays near 0 after moderate nn
      • Cauchy: sample mean can suddenly jump even for large nn

      Averages of Cauchy vs Normal samples

      Moral

      Limit theorems are powerful, but they have assumptions:

      • i.i.d. samples
      • Finite mean (WLLN, SLLN)
      • Finite variance (CLT, Chebyshev-based WLLN)

      The Cauchy distribution shows what happens when these assumptions fail.

      Summary

      PropertyCauchyNormal
      PDF tailsO(x2)O(x^{-2})O(ex2/2)O(e^{-x^2/2})
      MeanUndefined0
      VarianceUndefined1
      CLT appliesNoYes
      Sample meanAlso CauchyConcentrates
  • Estimation

    Estimators, bias, MSE, and online algorithms

    • Introduction to Estimators

      From Theory to Data

      Probability: given distribution, compute probabilities.

      Statistics: given data, infer distribution.

      Estimation is statistical inference: using data to estimate unknown parameters.

      Estimators

      An estimator θ^\hat{\theta} is a function of the data used to estimate an unknown parameter θ\theta.

      The estimate is the value computed from actual data.

      Example: Estimating Population Mean

      Parameter: μ\mu (unknown population mean)

      Data: X1,,XnX_1, \ldots, X_n (random sample)

      Estimator: μ^=Xˉ=1ni=1nXi\hat{\mu} = \bar{X} = \frac{1}{n}\sum_{i=1}^n X_i

      Estimate: 42.3 (actual value from data)

      Properties of Good Estimators

      Unbiasedness

      θ^\hat{\theta} is unbiased if E[θ^]=θE[\hat{\theta}] = \theta.

      The expected value of the estimator equals the true parameter.

      Low Variance

      Var(θ^)\text{Var}(\hat{\theta}) should be small.

      An estimator with low variance concentrates near its mean.

      Consistency

      θ^\hat{\theta} is consistent if θ^Pθ\hat{\theta} \xrightarrow{P} \theta as nn \to \infty.

      With more data, the estimator converges to the truth.

      Example: Sample Mean

      Xˉ\bar{X} as estimator for μ\mu:

      PropertyStatus
      UnbiasedYes: E[Xˉ]=μE[\bar{X}] = \mu
      Varianceσ2/n\sigma^2/n
      ConsistentYes (by WLLN)

      Example: Sample Variance

      Two versions:

      Sn2=1ni=1n(XiXˉ)2(biased)S_n^2 = \frac{1}{n}\sum_{i=1}^n(X_i - \bar{X})^2 \quad \text{(biased)}

      S2=1n1i=1n(XiXˉ)2(unbiased)S^2 = \frac{1}{n-1}\sum_{i=1}^n(X_i - \bar{X})^2 \quad \text{(unbiased)}

      Dividing by n1n-1 corrects for estimating μ\mu with Xˉ\bar{X}.

      Physical Analogy

      Estimator = Measuring instrument Parameter = True value Estimate = Measurement Sampling variation = Measurement error

      Measurement=True value+Error\text{Measurement} = \text{True value} + \text{Error}

      Point vs Interval Estimation

      • Point estimate: Single value (e.g., Xˉ=42.3\bar{X} = 42.3)
      • Interval estimate: Range (e.g., 95% CI: (40.1,44.5)(40.1, 44.5))

      Interval estimates convey uncertainty.

      Method of Moments

      Match sample moments to population moments:

      E[X]=XˉE[X] = \bar{X} E[X2]=1nXi2E[X^2] = \frac{1}{n}\sum X_i^2

      Solve for parameters.

      Maximum Likelihood

      Find parameter value maximising probability of observed data.

      θ^MLE=argmaxθL(θ)=argmaxθi=1nf(Xi;θ)\hat{\theta}_{MLE} = \arg\max_\theta L(\theta) = \arg\max_\theta \prod_{i=1}^n f(X_i; \theta)

      Summary

      ConceptDefinition
      EstimatorFunction of data to estimate parameter
      EstimateValue computed from actual data
      UnbiasedE[θ^]=θE[\hat{\theta}] = \theta
      Consistentθ^θ\hat{\theta} \to \theta as nn \to \infty
    • Bias of Estimators

      Definition

      The bias of an estimator θ^\hat{\theta} for parameter θ\theta is:

      Bias(θ^)=E[θ^]θ\text{Bias}(\hat{\theta}) = E[\hat{\theta}] - \theta

      Interpretation

      • Bias=0\text{Bias} = 0: unbiased
      • Bias>0\text{Bias} > 0: overestimates on average
      • Bias<0\text{Bias} < 0: underestimates on average

      Unbiased Estimators

      θ^\hat{\theta} is unbiased if E[θ^]=θE[\hat{\theta}] = \theta for all θ\theta.

      Example: Sample Mean

      E[Xˉ]=E[1ni=1nXi]=1ni=1nE[Xi]=μE[\bar{X}] = E\left[\frac{1}{n}\sum_{i=1}^n X_i\right] = \frac{1}{n}\sum_{i=1}^n E[X_i] = \mu

      Unbiased for population mean.

      Example: Sample Variance

      Sn2=1ni=1n(XiXˉ)2S_n^2 = \frac{1}{n}\sum_{i=1}^n(X_i - \bar{X})^2

      E[Sn2]=n1nσ2E[S_n^2] = \frac{n-1}{n}\sigma^2 (biased, underestimates).

      S2=1n1i=1n(XiXˉ)2S^2 = \frac{1}{n-1}\sum_{i=1}^n(X_i - \bar{X})^2

      E[S2]=σ2E[S^2] = \sigma^2 (unbiased).

      Why Unbiasedness Matters

      Unbiased estimators:

      • Average to the true value over repeated sampling
      • No systematic error
      • “Fair” on average

      But being unbiased doesn’t guarantee good performance:

      • A fair coin estimator averaged with a biased one might be worse
      • An unbiased estimator with huge variance is useless

      Bias-Variance Trade-off

      Sometimes a slightly biased estimator has much lower variance.

      MSE=Bias2+Variance\text{MSE} = \text{Bias}^2 + \text{Variance}

      Minimising MSE may tolerate some bias for greatly reduced variance.

      Example: Ridge Regression

      Shrinking coefficients introduces bias but reduces variance.

      Overall prediction error decreases.

      Asymptotic Unbiasedness

      θ^n\hat{\theta}_n is asymptotically unbiased if:

      limnE[θ^n]=θ\lim_{n \to \infty} E[\hat{\theta}_n] = \theta

      Sn2S_n^2 is asymptotically unbiased: E[Sn2]=n1nσ2σ2E[S_n^2] = \frac{n-1}{n}\sigma^2 \to \sigma^2.

      Summary

      EstimatorBias
      Xˉ\bar{X}0 (unbiased)
      Sn2S_n^2σ2/n-\sigma^2/n (biased)
      S2S^20 (unbiased)
    • Mean Squared Error

      Definition

      The mean squared error (MSE) of an estimator θ^\hat{\theta} for parameter θ\theta is:

      MSE(θ^)=E[(θ^θ)2]\text{MSE}(\hat{\theta}) = E[(\hat{\theta} - \theta)^2]

      Bias-Variance Decomposition

      MSE(θ^)=Var(θ^)+Bias(θ^)2\text{MSE}(\hat{\theta}) = \text{Var}(\hat{\theta}) + \text{Bias}(\hat{\theta})^2

      Proof:

      E[(θ^θ)2]=E[((θ^E[θ^])+(E[θ^]θ))2]E[(\hat{\theta} - \theta)^2] = E[((\hat{\theta} - E[\hat{\theta}]) + (E[\hat{\theta}] - \theta))^2]

      =E[(θ^E[θ^])2]+(E[θ^]θ)2+2E[(θ^E[θ^])(E[θ^]θ)]= E[(\hat{\theta} - E[\hat{\theta}])^2] + (E[\hat{\theta}] - \theta)^2 + 2E[(\hat{\theta} - E[\hat{\theta}])(E[\hat{\theta}] - \theta)]

      The cross-term vanishes: the second bracket is constant.

      =Var(θ^)+Bias(θ^)2= \text{Var}(\hat{\theta}) + \text{Bias}(\hat{\theta})^2

      Interpretation

      MSE measures total error:

      • Variance: Random error from sampling
      • Bias2^2: Systematic error from estimator design

      A good estimator balances both.

      For Unbiased Estimators

      If θ^\hat{\theta} is unbiased (Bias=0\text{Bias} = 0):

      MSE(θ^)=Var(θ^)\text{MSE}(\hat{\theta}) = \text{Var}(\hat{\theta})

      MSE equals variance.

      Example: Sample Mean

      Xˉ\bar{X} is unbiased for μ\mu:

      MSE(Xˉ)=Var(Xˉ)=σ2n\text{MSE}(\bar{X}) = \text{Var}(\bar{X}) = \frac{\sigma^2}{n}

      Example: Sample Variance Variants

      Sn2=1n(XiXˉ)2S_n^2 = \frac{1}{n}\sum(X_i - \bar{X})^2: biased, lower variance.

      S2=1n1(XiXˉ)2S^2 = \frac{1}{n-1}\sum(X_i - \bar{X})^2: unbiased, higher variance.

      Which has lower MSE? For normal distribution, Sn2S_n^2 often wins.

      Root Mean Squared Error

      RMSE=MSE\text{RMSE} = \sqrt{\text{MSE}}

      RMSE is in the same units as θ\theta, making it more interpretable.

      Consistent Estimators

      If θ^n\hat{\theta}_n is consistent, then MSE(θ^n)0\text{MSE}(\hat{\theta}_n) \to 0 as nn \to \infty.

      Consistency requires vanishing MSE.

      Optimality

      Among unbiased estimators, the one with minimum variance (and hence minimum MSE) is called efficient or minimum variance unbiased estimator (MVUE).

      Summary

      QuantityFormula
      MSEE[(θ^θ)2]E[(\hat{\theta} - \theta)^2]
      DecompositionVar(θ^)+Bias2\text{Var}(\hat{\theta}) + \text{Bias}^2
      RMSEMSE\sqrt{\text{MSE}}
    • Unbiased Estimators for Mean and Variance

      Sample Mean

      Xˉ=1ni=1nXi\bar{X} = \frac{1}{n}\sum_{i=1}^n X_i is unbiased for μ\mu.

      E[Xˉ]=μE[\bar{X}] = \mu

      Variance: Var(Xˉ)=σ2n\text{Var}(\bar{X}) = \frac{\sigma^2}{n}

      Sample Variance (Biased)

      Sn2=1ni=1n(XiXˉ)2S_n^2 = \frac{1}{n}\sum_{i=1}^n(X_i - \bar{X})^2

      This is biased: E[Sn2]=n1nσ2E[S_n^2] = \frac{n-1}{n}\sigma^2.

      Proof

      E[Sn2]=E[1nXi2Xˉ2]E[S_n^2] = E\left[\frac{1}{n}\sum X_i^2 - \bar{X}^2\right]

      =E[X2](E[X])2Var(Xˉ)= E[X^2] - (E[X])^2 - \text{Var}(\bar{X})

      =σ2σ2n=n1nσ2= \sigma^2 - \frac{\sigma^2}{n} = \frac{n-1}{n}\sigma^2

      Sample Variance (Unbiased)

      S2=1n1i=1n(XiXˉ)2S^2 = \frac{1}{n-1}\sum_{i=1}^n(X_i - \bar{X})^2

      This is unbiased: E[S2]=σ2E[S^2] = \sigma^2.

      Why n-1?

      Degrees of freedom: Estimating μ\mu with Xˉ\bar{X} uses one degree of freedom before estimating variance.

      n1n - 1 corrects for this.

      Standard Error

      SE=SnSE = \frac{S}{\sqrt{n}}

      Estimated standard deviation of Xˉ\bar{X}.

      Example: Heights

      n=100n = 100 heights: Xˉ=170\bar{X} = 170 cm, S=10S = 10 cm.

      Unbiased estimate of population variance: S2=100S^2 = 100 cm2^2.

      Standard error: SE=1010=1SE = \frac{10}{10} = 1 cm.

      Summary

      EstimatorFormulaUnbiased?
      Sample meanXˉ=1nXi\bar{X} = \frac{1}{n}\sum X_iYes
      Sample var (n)Sn2=1n(XiXˉ)2S_n^2 = \frac{1}{n}\sum(X_i - \bar{X})^2No
      Sample var (n-1)S2=1n1(XiXˉ)2S^2 = \frac{1}{n-1}\sum(X_i - \bar{X})^2Yes
    • Method of Moments

      Idea

      Match sample moments with population moments to estimate parameters.

      Moments

      • First moment: E[X]E[X] (mean)
      • Second moment: E[X2]E[X^2]
      • kkth moment: E[Xk]E[X^k]

      Sample Moments

      • Xˉ=1ni=1nXi\bar{X} = \frac{1}{n}\sum_{i=1}^n X_i (first sample moment)
      • 1ni=1nXi2\frac{1}{n}\sum_{i=1}^n X_i^2 (second sample moment)

      Method

      1. Express population moments in terms of parameters
      2. Solve by matching with sample moments

      Example: Normal Distribution

      XN(μ,σ2)X \sim N(\mu, \sigma^2). Parameters: μ,σ\mu, \sigma.

      First moment: E[X]=μ=XˉE[X] = \mu = \bar{X}

      Second moment: E[X2]=μ2+σ2=1nXi2E[X^2] = \mu^2 + \sigma^2 = \frac{1}{n}\sum X_i^2

      Solution:

      • μ^=Xˉ\hat{\mu} = \bar{X}
      • σ^2=1nXi2Xˉ2=Sn2\hat{\sigma}^2 = \frac{1}{n}\sum X_i^2 - \bar{X}^2 = S_n^2

      Example: Exponential

      XExp(λ)X \sim \text{Exp}(\lambda). Parameter: λ\lambda.

      E[X]=1λ=XˉE[X] = \frac{1}{\lambda} = \bar{X}

      λ^=1Xˉ=nXi\hat{\lambda} = \frac{1}{\bar{X}} = \frac{n}{\sum X_i}

      Example: Uniform

      XUnif[0,θ]X \sim \text{Unif}[0, \theta]. Parameter: θ\theta.

      E[X]=θ2=XˉE[X] = \frac{\theta}{2} = \bar{X}

      θ^=2Xˉ\hat{\theta} = 2\bar{X}

      Properties

      • Simple to compute
      • Consistent (moment estimators converge)
      • Not always efficient
      • May not work if moments don’t exist

      Summary

      StepAction
      1Write population moments in parameters
      2Equate to sample moments
      3Solve for parameters
    • Maximum Likelihood Estimation

      Intuition

      Choose the parameter value that makes the observed data most probable.

      Likelihood Function

      For data X1,,XnX_1, \ldots, X_n and parameter θ\theta:

      L(θ)=i=1nf(Xi;θ)L(\theta) = \prod_{i=1}^n f(X_i; \theta)

      where f(x;θ)f(x; \theta) is the PMF or PDF.

      Log-Likelihood

      (θ)=logL(θ)=i=1nlogf(Xi;θ)\ell(\theta) = \log L(\theta) = \sum_{i=1}^n \log f(X_i; \theta)

      Easier to work with: products become sums.

      MLE Definition

      θ^MLE=argmaxθL(θ)=argmaxθ(θ)\hat{\theta}_{MLE} = \arg\max_\theta L(\theta) = \arg\max_\theta \ell(\theta)

      Example: Bernoulli

      XiBern(p)X_i \sim \text{Bern}(p). Data: x1,,xnx_1, \ldots, x_n.

      L(p)=i=1npxi(1p)1xi=pxi(1p)nxiL(p) = \prod_{i=1}^n p^{x_i}(1-p)^{1-x_i} = p^{\sum x_i}(1-p)^{n-\sum x_i}

      (p)=(xi)logp+(nxi)log(1p)\ell(p) = (\sum x_i)\log p + (n - \sum x_i)\log(1-p)

      Differentiate and set to 0:

      xipnxi1p=0\frac{\sum x_i}{p} - \frac{n - \sum x_i}{1-p} = 0

      p^=1ni=1nxi=Xˉ\hat{p} = \frac{1}{n}\sum_{i=1}^n x_i = \bar{X}

      Example: Normal Mean (Known Variance)

      XiN(μ,σ2)X_i \sim N(\mu, \sigma^2) with σ\sigma known.

      (μ)=n2log(2πσ2)12σ2(xiμ)2\ell(\mu) = -\frac{n}{2}\log(2\pi\sigma^2) - \frac{1}{2\sigma^2}\sum(x_i - \mu)^2

      Maximise by minimising (xiμ)2\sum(x_i - \mu)^2:

      μ^=Xˉ\hat{\mu} = \bar{X}

      Properties of MLE

      1. Consistent: θ^MLEPθ\hat{\theta}_{MLE} \xrightarrow{P} \theta
      2. Asymptotically normal: n(θ^MLEθ)dN(0,I1)\sqrt{n}(\hat{\theta}_{MLE} - \theta) \xrightarrow{d} N(0, I^{-1})
      3. Asymptotically efficient: Achieves minimum variance among all estimators
      4. Invariant: If θ^\hat{\theta} is MLE of θ\theta, then g(θ^)g(\hat{\theta}) is MLE of g(θ)g(\theta)

      Summary

      StepAction
      1Write likelihood L(θ)L(\theta)
      2Take log (optional but easier)
      3Differentiate, set to 0
      4Solve for θ^\hat{\theta}
    • Confidence Intervals

      Definition

      A 100(1α)%100(1-\alpha)\% confidence interval for parameter θ\theta is a random interval (L,U)(L, U) such that:

      P(L<θ<U)=1αP(L < \theta < U) = 1 - \alpha

      Interpretation

      If we repeated the sampling procedure many times, about 100(1α)%100(1-\alpha)\% of the computed intervals would contain the true parameter.

      Not: There is a (1α)(1-\alpha) probability that θ\theta lies in this interval. (θ\theta is fixed, the interval is random.)

      CI for Mean (Known Variance)

      X1,,XnX_1, \ldots, X_n from population with known σ2\sigma^2:

      Xˉ±zα/2σn\bar{X} \pm z_{\alpha/2} \frac{\sigma}{\sqrt{n}}

      where zα/2=Φ1(1α/2)z_{\alpha/2} = \Phi^{-1}(1 - \alpha/2).

      Derivation: By CLT, Xˉμσ/nN(0,1)\frac{\bar{X} - \mu}{\sigma/\sqrt{n}} \approx N(0,1).

      P(zα/2<Xˉμσ/n<zα/2)1αP\left(-z_{\alpha/2} < \frac{\bar{X} - \mu}{\sigma/\sqrt{n}} < z_{\alpha/2}\right) \approx 1 - \alpha

      CI for Mean (Unknown Variance)

      Use tt-distribution with n1n-1 degrees of freedom:

      Xˉ±tn1,α/2Sn\bar{X} \pm t_{n-1, \alpha/2} \frac{S}{\sqrt{n}}

      For large nn, tn1zt_{n-1} \approx z.

      Common Confidence Levels

      Confidence Levelα\alphazα/2z_{\alpha/2}
      90%0.101.645
      95%0.051.96
      99%0.012.576

      Example: Heights

      n=25n = 25 heights with Xˉ=170\bar{X} = 170 cm, S=10S = 10 cm.

      95% CI: 170±1.96×1025=170±3.92170 \pm 1.96 \times \frac{10}{\sqrt{25}} = 170 \pm 3.92

      95% CI: (166.08,173.92)(166.08, 173.92) cm.

      Interpretation

      We are 95% confident that the true mean height lies between 166.08 cm and 173.92 cm.

      “Confident” refers to the procedure, not the probability of this specific interval.

      Summary

      ParameterCI Formula
      Mean (σ\sigma known)Xˉ±zα/2σ/n\bar{X} \pm z_{\alpha/2}\sigma/\sqrt{n}
      Mean (σ\sigma unknown)Xˉ±tn1,α/2S/n\bar{X} \pm t_{n-1, \alpha/2}S/\sqrt{n}
    • Population Estimation and Secretary Problem

      Tank Problem (German Tank Problem)

      Suppose we observe nn serial numbers from a population numbered 1,2,,N1, 2, \ldots, N (unknown NN). Estimate NN.

      Model

      Serial numbers drawn uniformly without replacement from {1,,N}\{1, \ldots, N\}.

      MLE

      N^MLE=max(X1,,Xn)\hat{N}_{MLE} = \max(X_1, \ldots, X_n)

      This maximises likelihood, but is biased downward.

      Unbiased Estimator

      N^=n+1nmaxiXi1\hat{N} = \frac{n+1}{n} \max_i X_i - 1

      Example

      Observed serial numbers: 7,3,10,46,147, 3, 10, 46, 14.

      max=46\max = 46, n=5n = 5.

      N^=65×461=54.2\hat{N} = \frac{6}{5} \times 46 - 1 = 54.2

      Estimate: N54N \approx 54 or 5555.

      Secretary Problem

      We interview nn candidates sequentially. After each interview, must accept or reject. Cannot recall rejected candidates. Goal: maximise chance of hiring the best.

      Optimal Strategy

      Reject the first r=n/er^* = \lfloor n/e \rfloor candidates, then choose the first one better than all seen so far.

      For large nn: rn/e0.368nr^* \approx n/e \approx 0.368n.

      Probability of Success

      With optimal strategy: 1/e0.368\approx 1/e \approx 0.368 (surprisingly high).

      Proof Idea

      The optimal rr balances:

      • Seeing enough candidates to know what “good” looks like
      • Not waiting so long that the best is already rejected

      Computer simulations verify the 1/e1/e rule.

      Example

      100 candidates. Reject first 37, then hire the first better than all previous.

      Dice Game Problem

      Roll a fair die nn times. Stop at the last 6 rolled to win.

      Optimal Strategy

      Stop as soon as we see a 6 after some threshold kk.

      Threshold: k=k = smallest integer satisfying Pk(win)>0.5P_k(\text{win}) > 0.5.

      For n=10n = 10: threshold around throw 5.

      Summary

      ProblemKey Idea
      Tank estimationUse max + correction
      Secretary problemReject first n/en/e, then choose best yet
      Dice gameThreshold-based stopping
  • Other Resources

    • Examinable Formulas and Results

      Foundational Formulas

      Probability Axioms

      • P(Ω)=1P(\Omega) = 1, P()=0P(\emptyset) = 0
      • P(Ac)=1P(A)P(A^c) = 1 - P(A)
      • P(AB)=P(A)+P(B)P(AB)P(A \cup B) = P(A) + P(B) - P(A \cap B)

      Conditional Probability

      • P(AB)=P(AB)P(B)P(A \mid B) = \frac{P(A \cap B)}{P(B)} for P(B)>0P(B) > 0
      • Bayes’ theorem: P(AB)=P(BA)P(A)P(B)P(A \mid B) = \frac{P(B \mid A) P(A)}{P(B)}
      • Law of total probability: P(A)=iP(AFi)P(Fi)P(A) = \sum_i P(A \mid F_i) P(F_i) for partition {Fi}\{F_i\}

      Independence

      • Events: P(AB)=P(A)P(B)P(A \cap B) = P(A) P(B)
      • Random variables: F(x,y)=FX(x)FY(y)F(x, y) = F_X(x) F_Y(y)

      Discrete Distributions

      DistributionPMFE[X]E[X]Var(X)\text{Var}(X)
      Bernoulli(pp)px(1p)1xp^x(1-p)^{1-x}ppp(1p)p(1-p)
      Binomial(n,pn,p)(nk)pk(1p)nk\binom{n}{k}p^k(1-p)^{n-k}npnpnp(1p)np(1-p)
      Poisson(λ\lambda)λkeλk!\frac{\lambda^k e^{-\lambda}}{k!}λ\lambdaλ\lambda
      Geo(pp)(1p)k1p(1-p)^{k-1}p1p\frac{1}{p}1pp2\frac{1-p}{p^2}
      NegBin(r,pr,p)(n1r1)(1p)nrpr\binom{n-1}{r-1}(1-p)^{n-r}p^rrp\frac{r}{p}r(1p)p2\frac{r(1-p)}{p^2}
      Hyp(N,n,mN,n,m)(mi)(Nmni)(Nn)\frac{\binom{m}{i}\binom{N-m}{n-i}}{\binom{N}{n}}nmN\frac{nm}{N}nmN(1mN)NnN1\frac{nm}{N}(1-\frac{m}{N})\frac{N-n}{N-1}
      Unif{1,,N}\{1,\ldots,N\}1N\frac{1}{N}N+12\frac{N+1}{2}N2112\frac{N^2-1}{12}

      Continuous Distributions

      DistributionPDFE[X]E[X]Var(X)\text{Var}(X)
      Unif[a,b][a,b]1ba\frac{1}{b-a}a+b2\frac{a+b}{2}(ba)212\frac{(b-a)^2}{12}
      Exp(λ\lambda)λeλx\lambda e^{-\lambda x}1λ\frac{1}{\lambda}1λ2\frac{1}{\lambda^2}
      N(μ,σ2)N(\mu, \sigma^2)1σ2πe(xμ)22σ2\frac{1}{\sigma\sqrt{2\pi}}e^{-\frac{(x-\mu)^2}{2\sigma^2}}μ\muσ2\sigma^2

      Distribution Properties

      Memoryless Distributions

      • Discrete: Geometric
      • Continuous: Exponential

      Sum of Independent Variables

      • Bin(n1,pn_1, p) + Bin(n2,pn_2, p) = Bin(n1+n2,pn_1 + n_2, p)
      • Pois(λ1\lambda_1) + Pois(λ2\lambda_2) = Pois(λ1+λ2\lambda_1 + \lambda_2)
      • N(μ1,σ12)N(\mu_1, \sigma_1^2) + N(μ2,σ22)N(\mu_2, \sigma_2^2) = N(μ1+μ2,σ12+σ22)N(\mu_1 + \mu_2, \sigma_1^2 + \sigma_2^2)
      • n×n \times Exp(λ\lambda) = Gamma(n,λn, \lambda)

      Poisson Limit

      Bin(n,pn, p) \to Pois(λ\lambda) as nn \to \infty, npλnp \to \lambda

      Inequalities

      Markov’s Inequality

      For X0X \geq 0: P(Xa)E[X]aP(X \geq a) \leq \frac{E[X]}{a}

      Chebyshev’s Inequality

      P(Xμkσ)1k2P(|X - \mu| \geq k\sigma) \leq \frac{1}{k^2}

      Jensen’s Inequality

      For convex gg: E[g(X)]g(E[X])E[g(X)] \geq g(E[X])

      For concave gg: E[g(X)]g(E[X])E[g(X)] \leq g(E[X])

      Limit Theorems

      Weak Law of Large Numbers

      XˉnPμ\bar{X}_n \xrightarrow{P} \mu

      Strong Law of Large Numbers

      P(Xˉnμ)=1P(\bar{X}_n \to \mu) = 1

      Central Limit Theorem

      n(Xˉnμ)dN(0,σ2)\sqrt{n}(\bar{X}_n - \mu) \xrightarrow{d} N(0, \sigma^2)

      Equivalently: Xˉnμσ/ndN(0,1)\frac{\bar{X}_n - \mu}{\sigma/\sqrt{n}} \xrightarrow{d} N(0, 1)

      Joint Distributions

      Covariance

      Cov(X,Y)=E[XY]E[X]E[Y]\text{Cov}(X, Y) = E[XY] - E[X]E[Y]

      Correlation

      ρX,Y=Cov(X,Y)σXσY\rho_{X,Y} = \frac{\text{Cov}(X,Y)}{\sigma_X \sigma_Y}

      Variance of Sum

      Var(X+Y)=Var(X)+Var(Y)+2Cov(X,Y)\text{Var}(X + Y) = \text{Var}(X) + \text{Var}(Y) + 2\text{Cov}(X, Y)

      If independent: Var(X+Y)=Var(X)+Var(Y)\text{Var}(X + Y) = \text{Var}(X) + \text{Var}(Y)

      Estimation

      Bias

      Bias(θ^)=E[θ^]θ\text{Bias}(\hat{\theta}) = E[\hat{\theta}] - \theta

      MSE

      MSE(θ^)=E[(θ^θ)2]=Var(θ^)+Bias2\text{MSE}(\hat{\theta}) = E[(\hat{\theta} - \theta)^2] = \text{Var}(\hat{\theta}) + \text{Bias}^2

      Sample Mean

      Xˉ=1ni=1nXi\bar{X} = \frac{1}{n}\sum_{i=1}^n X_i, unbiased for μ\mu

      Sample Variance

      S2=1n1i=1n(XiXˉ)2S^2 = \frac{1}{n-1}\sum_{i=1}^n(X_i - \bar{X})^2, unbiased for σ2\sigma^2

      Confidence Interval (mean, known σ\sigma)

      Xˉ±zα/2σn\bar{X} \pm z_{\alpha/2} \frac{\sigma}{\sqrt{n}}

      Confidence Interval (mean, unknown σ\sigma)

      Xˉ±tn1,α/2Sn\bar{X} \pm t_{n-1, \alpha/2} \frac{S}{\sqrt{n}}

      Standard Normal Values

      zzΦ(z)\Phi(z)
      1.6450.95
      1.960.975
      2.5760.995

      Empirical Rule

      • μ±σ\mu \pm \sigma: ~68%
      • μ±2σ\mu \pm 2\sigma: ~95%
      • μ±3σ\mu \pm 3\sigma: ~99.7%