Modelintro
Zipf's law
Also called Zipf distribution of term frequencies.
The frequency of the i-th most common term in a collection is roughly proportional to 1/i.
Zipf's law is an empirical law about text: if the terms of a collection are ranked by how often they occur, the collection frequency of the term of rank is roughly proportional to . It is a regularity that people fit to data, not a theorem, and on real collections it holds only roughly, with the largest errors at the top and the bottom ranks. George Kingsley Zipf described it in 1949. In information retrieval it is the standard model of how skewed term frequencies are, and it is used to estimate the effect of stop word removal, the length of posting lists and, through Heaps' law, the growth of the vocabulary.
The machine
Ranks and frequencies. A collection is a sequence of tokens over a vocabulary of distinct terms. The collection frequency of a term is the number of its tokens, so . Sort the terms by frequency, , so that is the frequency of the term of rank .
The law. In the form of Manning, Raghavan and Schuetze,
for a constant of the collection. The general form is a power law , with near 1 for word counts. On a plot of against , the law is a straight line, , so and are fitted by linear regression on the log-log points. The fit depends on the method: a plain least-squares line is pulled by the many rare terms at the end of the ranking, so fits often give weights to the points.
The random text model. To reason with the law, model the text as independent draws from a discrete distribution over the ranks, with
For the sum must stop at a finite vocabulary size , and , the -th harmonic number. For the vocabulary can be infinite, and , the Riemann zeta function. The expected frequency of rank is , which is the law with .
On the toy collection. The toy collection of the information retrieval pages has 79 tokens and 50 terms. The most frequent are "a" with 8 tokens, "sorted" with 5, and "array", "posting", "list", "of" and "the" with 3 each. With the law predicts 4 for rank 2 and about 2.7 for rank 3. The data is far too small for a fit, but the shape is there: one term is much more common than the rest, and most terms are rare.
What it counts
- Parameters. The exponent and the constant , or, in the random text model, and the vocabulary size .
- Data. The frequencies of the terms of one collection, after a fixed tokenization. Case folding, numbers and stemming change the counts and so the fitted constants.
- What it predicts. The share of the tokens that the top ranks cover, which is for ; the number of terms with a given frequency; and the length of the posting list of a term of rank , which is at most .
- What it leaves out. Which terms are frequent, how the tokens of a term spread over documents, and any order of the tokens. Two collections with the same rank and frequency curve can have very different posting lists.
Relation to other models
- Heaps' law describes the number of distinct terms as a function of the number of tokens. The two laws are fitted to different measurements of the same text: the frequencies at one size, and the vocabulary as the size grows.
- Two-Poisson model. Zipf's law is about totals over the whole collection. The two-Poisson model is about the counts of one term across documents, and it models how the tokens of a content word gather in few documents.
- Codes for skewed data. A Huffman code of the terms, or a variable length code of the gaps of posting lists, gets its gain from this skew: a few terms and many small gaps are very common.
- Other power laws. The same form fits many rank and size data outside text. The model here is only the one for term counts.
Known results in the model
- The fit on Reuters-RCV1 (measured). Manning, Raghavan and Schuetze fit a line of slope to the log-log plot of RCV1 by weighted least squares and get the intercept 6.95 in base 10, which is million. They describe the fit as not particularly good, but good enough to serve as a model for their calculations of index size.
- The share of the top ranks (derived, then measured). With and the RCV1 vocabulary of terms after case folding, the 30 most frequent terms cover of the tokens, and the top 150 cover about 0.416. The token counts of Table 5.1 of the same book drop from 179,158,204 to 121,857,825 when the 30 most common words are removed, and to 94,516,599 for 150 words: 32 and 47 percent. So the law gets the size right, and it predicts too little for the very top ranks. The book states the same fact as the rule of 30: the 30 most common words account for about 30 percent of the tokens of written text.
- The number of rare terms (derived). If exactly, the terms with frequency at least are the ranks up to , so about terms have frequency exactly , out of about terms in all. So half of the terms occur once and one sixth occur twice. On the toy collection, 35 of 50 occur once and 8 occur twice.
- Finite against infinite vocabulary (derived). With the sum diverges, so the law can only hold up to a finite vocabulary size; this is part (i) of Exercise 5.13 of Manning, Raghavan and Schuetze. With the sum converges, and the model allows an unbounded vocabulary that grows with as Heaps' law says.
- Vocabulary growth (derived). In the random text model with , the expected number of distinct terms in tokens grows as a constant times . The derivation, and the published results on finite collections, are on the page of Heaps' law.
References
- Christopher D. Manning, Prabhakar Raghavan and Hinrich Schuetze, Introduction to Information Retrieval, Cambridge University Press, 2008, Chapter 5, Section 5.1.2 (the law cf_i proportional to 1/i, the power law form, Figure 5.2 with the weighted least-squares fit on Reuters-RCV1 and its intercept 6.95, and the remark that the fit is not particularly good but good enough to serve as a model), Section 5.1 (Table 5.1 and the rule of 30), Exercise 5.13, and Section 5.4 (the references to Zipf 1949 and to Witten and Bell 1990 on the quality of the fit)
- George Kingsley Zipf, Human Behavior and the Principle of Least Effort, Addison-Wesley, 1949, the rank and frequency relation of words, proposed as an empirical regularity of language, as cited in Section 5.4 of Manning, Raghavan and Schuetze
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag 961PYC Edit this page History Report an error Markdown