Probability and Federalist Papers
Probabilistic Models and the Multinomial Distribution
Normal Distribution Review
The normal distribution is one of the most important continuous probability distributions. Its probability density function (PDF) has the classic bell-shaped curve. The cumulative distribution function (CDF), denoted F(x)=P(X≤x), is monotonic increasing.
The key formula for computing probabilities with a normal random variable X with mean μ and variance σ2 is:
where Φ is the CDF of the standard normal (mean 0, variance 1). The standard normal CDF is pre-computed and available in tables or computer functions.
Example: Server Capacity Planning for Singles Day
A real-world problem illustrates how to work backwards using the normal CDF. Alibaba's Singles Day (11/11) is their busiest shopping day. Assume the number of requests in the busiest minute follows a Gaussian distribution with mean μ=106 and standard deviation σ=104. Each server can handle 10,000 requests. The goal is to buy enough servers so that the probability of not dropping any requests is greater than 0.99999.
Let R be the number of requests; we want r such that P(R<r)=0.99999. Using the normal CDF:
Apply the inverse Phi function (quantile function) on both sides:
Then solve for r:
Number of servers needed = ⌈r/10,000⌉=⌈103.719⌉=104 servers.
Key insight: For continuous random variables, P(R≤r)=P(R<r) because the probability of any exact value is zero. This equality does not hold for discrete variables.
Logarithms and Counting Review
Logarithm Properties
The natural logarithm ln(x) (or simply log(x)) is the inverse of the exponential function: log(ey)=y and elogx=x. Important properties for probability calculations:
log(a⋅b)=loga+logb (product becomes sum)
log(a/b)=loga−logb
log(ab)=b⋅loga
These properties are crucial in computer science because multiplying many small probabilities (e.g., from a chain of events) leads to underflow — the computer cannot represent numbers that are extremely close to zero. Working in log-space (adding log probabilities) avoids this issue and is standard practice in probabilistic models.
Multinomial Counting
A counting problem that will appear in the multinomial distribution: Given n distinct objects, the number of ways to put n1 into bucket 1, n2 into bucket 2, ..., nr into bucket r is:
This is also the number of distinct permutations of a multiset (e.g., the letters in "MISSISSIPPI").
💡 Introduction to Probabilistic Models
So far, course topics have focused on single random variables. Many interesting real-world problems involve multiple random variables simultaneously. For example, WebMD® uses symptoms (headache, dizziness) and diseases (migraine, stroke) — many random variables interacting.
Joint Probability Mass Function (PMF)
For two discrete random variables X and Y, the joint probability mass function is:
This gives the probability of a specific joint assignment — both variables taking particular values simultaneously. If you know the joint PMF, you can answer any probabilistic question about X and Y.
Example: Dice Roll
Roll two fair six-sided dice. Let X be the outcome of the first die, Y of the second. The joint PMF is constant:
pX,Y(x,y)=361 for all x,y∈{1,2,3,4,5,6}.
Example: Student Year and Relationship Status
Real data from a CS109 class:
Year ↓ / Status → | Single | Relationship | Complicated |
|---|---|---|---|
Freshman | 0.02 | 0.08 | 0.01 |
Sophomore | 0.05 | 0.13 | 0.02 |
Junior | 0.10 | 0.10 | 0.03 |
Senior | 0.08 | 0.09 | 0.02 |
5th year+ | 0.15 | 0.05 | 0.07 |
Each cell is the probability that a randomly selected student belongs to that year and that status. The sum of all 15 entries equals 1.
Properties of a joint PMF:
Each entry is a probability (0≤p≤1).
Sum over all possible (x,y) combinations equals 1.
Entries are mutually exclusive (a student cannot be both a freshman and a senior).
Marginalization
Suppose we want the probability that a student is in a relationship — we don't care about their year. From the joint table, we sum over all years:
This is called marginalization. The resulting distribution for a single variable (ignoring the others) is the marginal distribution.
Formally, for discrete X and Y:
The name "marginal" comes from the historical practice of writing the sums in the margins of the joint table.
Connection to Law of Total Probability: The law of total probability is the theoretical justification for marginalization. If {Bi} partition the sample space, then P(A)=∑iP(A∩Bi). Here A corresponds to "X = x" and Bi to "Y = y_i".
The Curse of Dimensionality: Large Joint Tables
Joint tables become exponentially large as the number of random variables grows. For example, with 3 variables:
D (disease): 2 values (0 or 1)
S (smell symptom): 2 values (no, yes)
F (fever status): 3 values (none, low, high)
Number of entries: 2×2×3=12. That's manageable. But for a realistic model like WebMD with 10 variables each taking 5 values, the table has 510=9,765,625 entries — too many for a scientist to manually specify probabilities.
With 100 variables, 5100 is astronomical. Therefore, we need more efficient representations of the joint distribution, often by making simplifying assumptions (e.g., conditional independence).
📊 The Multinomial Distribution
The multinomial distribution is the generalization of the binomial distribution from 2 outcomes to m outcomes. It models the counts of each outcome in n independent trials, where each trial has m possible results with probabilities p1,p2,…,pm (summing to 1).
Definition
Let X1,X2,…,Xm be the random variables representing the number of times outcome i occurs. Then the joint PMF is:
where ∑i=1mci=n and ci≥0.
The multinomial coefficient c1!⋯cm!n! counts the number of distinct sequences (orderings) of the n trials that produce exactly c1 of outcome 1, c2 of outcome 2, etc.
Relation to Binomial
The binomial distribution is a special case with m=2: X1 = number of successes, X2=n−X1, and p2=1−p1. Then
which matches the binomial PMF.
Example: Rolling 7 Dice
Roll 7 fair dice (each outcome probability =61). Observe: one 1, one 2, zero 3's, two 4's, zero 5's, three 6's. The probability of this specific count vector is:
The multinomial coefficient accounts for the different orderings of the dice rolls.
Application: Natural Language Processing
Documents can be modeled as multinomial draws from a "word dice". Each word in the document is a trial; there are as many outcomes as unique words in the vocabulary (≈ 1 million for English). The probability of each word is the relative frequency of that word in the language (or in a specific author's writing).
For a document of n words, the multinomial gives the probability of that exact word count vector under a given word probability distribution.
Example: Spam Detection
A spam email might contain the words "Viagra", "free", "click", "credit". The probability of seeing a particular multiset of words can be computed:
where cw is the count of word w in the document, and pw is the probability of word w according to a "spam language model" or a "normal English model". Comparing these probabilities helps classify the email.
🏛️ Application: Authorship of The Federalist Papers
The Federalist Papers (85 essays) were written under the pseudonym Publius by Alexander Hamilton, James Madison, and John Jay. Some essays have disputed authorship; particularly, Paper 53 was claimed by both Hamilton and Madison. The goal is to determine, based on word usage, who wrote it.
Data
Hamilton's known essays: a collection of text (counts of words)
Madison's known essays: another collection
Unknown.txt: Federalist Paper 53
We can estimate the probability that Hamilton (or Madison) would use a particular word by taking the relative frequency from their known works.
Probabilistic Model
We want P(Hamilton∣document) — the probability that Hamilton wrote the document given the observed word counts.
From Bayes' theorem:
Similarly for Madison. The term P(D∣H) is the probability of the observed word counts under Hamilton's word distribution — exactly the multinomial PMF.
To avoid computing P(D) (the normalization constant), we can compare the ratio:
With equal priors (P(H)=P(M)=0.5), this simplifies to:
If this ratio > 1, Hamilton is more likely; if < 1, Madison is more likely.
Furthermore, the multinomial coefficients cancel because they are identical for the same document:
where pH,w is the probability Hamilton writes word w, and cw is the count of word w in the unknown document.
The Problem: Zero Probabilities
When students computed these probabilities, both P(D∣H) and P(D∣M) came out as zero. This is because many words in the unknown document might not appear in the training data for that author, leading to pw=0 for some word. Multiplying by zero yields zero overall probability.
Key issue: The multinomial model cannot handle unseen words unless smoothing or other techniques are applied.
Preview of Solution
The mystery will be resolved on the next lecture day (Friday), likely by discussing smoothing (e.g., Laplace smoothing) to assign small non-zero probabilities to words not seen in the training data, allowing the product to be non-zero. This makes the model robust for real text analysis.

Ask anything
We've read this whole study set, so questions about it get the best answers.