Pointwise Mutual Information › Deriving the PMI Formula

Michael BrenndoerferUpdated March 21, 20266 min read
Language AI HandbookAll chapters
Part 3 of 67Distributional Semantics
Chapter 17Pointwise Mutual Information › Deriving the PMI Formula
Reading section 3 of 13 · Deriving the PMI Formula · 6 minSection 3 of 13 · 6 min

Book contents

Section 3 of 13 · 6 min read

Pointwise Mutual Information › Deriving the PMI FormulaOne section · Sections in this chapter3 / 13 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

PMI comes from information theory, specifically from the concept of mutual information between random variables. Mutual information asks how much knowing one variable tells you about another. It quantifies the reduction in uncertainty about one variable when you know the value of another. Pointwise mutual information applies this question to a specific pair of outcomes rather than to entire distributions.

Think of each word occurrence as a random event. When you sample a position in the corpus at random, you draw a word. Define:

  • P(w)P(w): the probability of randomly sampling word ww from the corpus
  • P(c)P(c): the probability of randomly sampling context word cc
  • P(w,c)P(w, c): the probability of observing the word pair (w,c)(w, c) together in a co-occurrence event

If ww and cc were completely independent, we would expect their joint probability to equal the product of their marginal probabilities:

P(w,c)independent=P(w)⋅P(c)P(w, c)_{\text{independent}} = P(w) \cdot P(c)

This is simply the definition of statistical independence. Two events are independent if and only if their joint probability factors into the product of the marginals. If you know that "bank" and "deposit" are independent, then knowing "bank" appeared tells you nothing about whether "deposit" appeared nearby.

PMI measures the log-ratio of the observed joint probability to this independent baseline:

PMI(w,c)=log⁡2P(w,c)P(w)⋅P(c)\text{PMI}(w, c) = \log_2 \frac{P(w, c)}{P(w) \cdot P(c)}

where:

  • P(w,c)P(w, c): the observed probability of word ww appearing with context cc
  • P(w)P(w): the marginal probability of word ww across all contexts
  • P(c)P(c): the marginal probability of context cc across all co-occurrences
  • log⁡2\log_2: logarithm base 2, so PMI values are expressed in bits

When the observed probability equals the expected probability under independence, the ratio is 1 and log⁡2(1)=0\log_2(1) = 0. When the words co-occur more than chance predicts, the ratio exceeds 1 and PMI is positive. When words co-occur less than chance predicts, the ratio falls below 1 and PMI is negative.

The logarithm serves several important roles. First, it converts the ratio from a multiplicative scale to an additive one, which is easier to work with mathematically and algorithmically. Second, it gives PMI a natural interpretation in information theory: a PMI of 1 bit means that observing ww doubles your probability estimate for cc. Third, the logarithm makes PMI symmetric in the sense that PMI(w,c)=PMI(c,w)\text{PMI}(w, c) = \text{PMI}(c, w), which you can verify algebraically since the joint probability and the product of marginals are both symmetric.

Pointwise Mutual Information (PMI)

PMI quantifies the association between a word ww and a context cc by comparing their observed co-occurrence probability against the probability expected if they were statistically independent:

PMI(w,c)=log⁡2P(w,c)P(w)⋅P(c)\text{PMI}(w, c) = \log_2 \frac{P(w, c)}{P(w) \cdot P(c)}

PMI equals zero when the words are independent, is positive when they associate more than chance, and is negative when they co-occur less than chance.

Estimating Probabilities from Counts

In practice, we estimate these probabilities from a co-occurrence matrix. Given a corpus with NN total co-occurrence events:

  • P(w)=count(w)NP(w) = \dfrac{\text{count}(w)}{N}, where count(w)\text{count}(w) is the total number of co-occurrence events involving word ww
  • P(c)=count(c)NP(c) = \dfrac{\text{count}(c)}{N}, where count(c)\text{count}(c) is the total number of co-occurrence events involving context cc
  • P(w,c)=count(w,c)NP(w, c) = \dfrac{\text{count}(w, c)}{N}, where count(w,c)\text{count}(w, c) is the number of times ww and cc co-occur within the context window

Substituting these into the PMI formula and simplifying:

PMI(w,c)=log⁡2P(w,c)P(w)⋅P(c)=log⁡2count(w,c)Ncount(w)N⋅count(c)N=log⁡2count(w,c)⋅Ncount(w)⋅count(c)\begin{aligned} \text{PMI}(w, c) &= \log_2 \frac{P(w, c)}{P(w) \cdot P(c)} \\[6pt] &= \log_2 \frac{\dfrac{\text{count}(w, c)}{N}}{\dfrac{\text{count}(w)}{N} \cdot \dfrac{\text{count}(c)}{N}} \\[6pt] &= \log_2 \frac{\text{count}(w, c) \cdot N}{\text{count}(w) \cdot \text{count}(c)} \end{aligned}

This final form is what you implement in code: multiply the raw co-occurrence count by the total event count NN, then divide by the product of the two marginal counts. The logarithm converts this ratio into an additive scale where zero means independence. Notice that NN cancels from the marginal probabilities but remains in the joint probability, which is why it appears in the numerator of the count-based formula. The ratio count(w,c)⋅N\text{count}(w,c) \cdot N in the numerator can be understood as the observed count scaled up to match the units of the denominator count(w)⋅count(c)\text{count}(w) \cdot \text{count}(c).

Interpreting PMI Values

PMI values have clear, intuitive meanings that map directly onto the concept of statistical association:

  • PMI = 0: The words appear together exactly as often as chance predicts. No evidence of association beyond their individual frequencies.
  • PMI > 0: The words appear together more than chance predicts. Higher values mean stronger, more specific association. A PMI of 2 bits means the pair co-occurs four times more often than chance.
  • PMI < 0: The words appear together less than chance predicts. They tend to avoid each other, though this is often an artifact of data sparsity rather than actual repulsion.
  • PMI approaching +∞+\infty: Occurs when two words almost always appear together but one or both are very rare. This can happen with highly specialized terminology or named entities in small corpora.
  • PMI =−∞= -\infty: Occurs when count(w,c)=0\text{count}(w, c) = 0. The words never co-occur, making the log of zero undefined.

The −∞-\infty case is a serious practical problem. Many word pairs never co-occur, especially in large vocabularies with limited data. A vocabulary of 50,000 words yields a matrix with 2.5 billion cells, but even a large corpus might only fill a small fraction of them. This leads directly to the concept of Positive PMI.

A caveat is that PMI values for rare words can be very high even when based on flimsy evidence. If two words each appear only twice in the corpus but always together, their PMI is very high. That sounds like strong evidence, but two observations are not enough to establish an association. This statistical fragility for low-frequency pairs is one of PMI's main practical weaknesses and motivates the smoothing and thresholding strategies discussed later.

The Information-Theoretic Connection

PMI is grounded in mutual information rather than being an ad hoc normalization. It has a direct connection to mutual information, one of the foundational quantities in information theory. Mutual information between two random variables WW and CC is defined as:

I(W;C)=∑w∑cP(w,c)⋅log⁡2P(w,c)P(w)⋅P(c)I(W; C) = \sum_{w} \sum_{c} P(w, c) \cdot \log_2 \frac{P(w, c)}{P(w) \cdot P(c)}

This is exactly a weighted average of PMI values, where the weights are the joint probabilities P(w,c)P(w, c). Mutual information measures the total statistical dependency between WW and CC across all possible word and context pairs. Pointwise mutual information zooms in on a single pair (w,c)(w, c) and reports the contribution of that specific combination to the overall mutual information.

This connection matters for two reasons. First, it means PMI has a well-founded theoretical interpretation, rather than a purely heuristic one. Second, it means that maximizing PMI for specific pairs is related to, though not identical to, maximizing mutual information across all pairs, which is the objective of many representation learning algorithms.