Modelintro
Heaps' law
Also called Herdan's law.
The number of distinct terms in a collection of T tokens grows as k T^b with b near one half.
Heaps' law is an empirical law about text: a collection of tokens has about distinct terms, with constants and that are fitted to the collection, and is usually near one half. It is a fit to measured data, not a theorem, but under a random model of text it can be derived from Zipf's law. H. S. Heaps stated it in 1978, and in information retrieval it is used to estimate the size of the dictionary of an inverted index as the collection grows. The law says that the vocabulary never stops growing: new documents keep bringing new names, numbers and spelling errors.
The machine
Vocabulary growth. Read the tokens of a collection in order. After tokens, let be the number of distinct terms seen so far. The law is
so on a log-log plot the growth curve is a straight line with slope , and and are fitted by linear regression on the log-log points. Manning, Raghavan and Schuetze give the typical ranges and for English text. The order of the documents matters for a short prefix of the collection, and little for a long one.
The random text model. For the derived results, model the text as independent draws from a distribution over the ranks of the terms. Rank is in the vocabulary after draws unless all draws miss it, so by linearity of expectation
With equal probabilities this is the count of filled bins in balls into bins, and the time until all terms are seen is the coupon collector problem. Heaps' law comes from the case of a Zipf distribution .
On the toy collection. The toy collection of the information retrieval pages, read document by document, gives these pairs of tokens and terms: (9, 8), (19, 15), (29, 24), (39, 28), (49, 34), (59, 39), (69, 46), (79, 50). A least-squares line through the log-log points has slope and . So short texts have near 1, because most of their words are new; the exponent near one half shows only after millions of tokens.
What it counts
- Parameters. The two constants and of one collection and one tokenization. They are fits: other text, other tokenization, or another range of gives other values.
- Data. The pairs for prefixes of the collection.
- What it predicts. The number of distinct terms, and so the size of the dictionary and the number of posting lists, for a collection larger than the one measured. With , the vocabulary grows more slowly than the text, but without a bound.
- What it leaves out. Which terms are new, and how often each term occurs; that is the job of Zipf's law.
Relation to other models
- Zipf's law is a law about frequencies at one size of the collection. Heaps' law is about the vocabulary as the size grows. In the random text model the first implies the second, with ; see below.
- The two are fitted separately. For English, fits give a Zipf exponent near 1 and a Heaps exponent near 0.5, which the relation of independent draws cannot both match. Real text is not a sequence of independent draws from one fixed distribution: topics change, and names come in bursts.
- Balls into bins and the coupon collector problem are the case of equal probabilities, where the vocabulary fills up and stops at terms. Zipf probabilities with and an infinite vocabulary give growth without a bound.
Known results in the model
- The fit on Reuters-RCV1 (measured). Manning, Raghavan and Schuetze fit to RCV1 for by least squares, which is and . For the first 1,000,020 tokens it predicts terms, and the collection has 38,365. With the unrounded the prediction is about 38,019. They note that case folding and stemming lower the growth, and numbers and spelling errors raise it.
- Heaps from Zipf (derived). Let with over an infinite vocabulary. For small , , and replacing the sum by an integral over the rank gives
by the substitution and an integration by parts. This is Heaps' law with and . For , . Against the exact sum, the approximation is off by about 1.1 percent at and by 0.04 percent at for , and by at most 0.4 percent for at these sizes.
- The case (derived). With the vocabulary must be finite, of some size , and for every . So the model gives growth that slows down and stops, not a power law forever. This is the point of Exercise 5.13 of Manning, Raghavan and Schuetze, which asks to show that the vocabulary is finite under Zipf's law and infinite under Heaps' law, and whether one law can be derived from the other.
- Finite collections (published). Lü, Zhang and Zhou (2010) show that Heaps' law is a derivative phenomenon of Zipf's law, that the approximate exponent relation holds asymptotically for infinite systems, and that for finite systems the Heaps exponent depends on the size of the system.
References
- Christopher D. Manning, Prabhakar Raghavan and Hinrich Schuetze, Introduction to Information Retrieval, Cambridge University Press, 2008, Chapter 5, Section 5.1.1 (the law M = kT^b, the typical ranges 30 to 100 for k and about 0.5 for b, the least-squares fit log10 M = 0.49 log10 T + 1.64 on Reuters-RCV1, and the prediction of 38,323 terms for the first 1,000,020 tokens against 38,365 observed), Exercise 5.13, and Section 5.4 (Heaps 1978 and the study of vocabulary growth by Williams and Zobel 2005)
- H. S. Heaps, Information Retrieval, Computational and Theoretical Aspects, Academic Press, 1978, the growth of the vocabulary as a power of the size of the text, as cited in Section 5.4 of Manning, Raghavan and Schuetze
- Linyuan Lü, Zi-Ke Zhang and Tao Zhou, Zipf's law leads to Heaps' law, Analyzing their relation in finite-size systems, PLoS ONE 5(12), e14139, 2010, Heaps' law as a derivative phenomenon of Zipf's law, the approximate exponent of Heaps' law as an asymptotic result for infinite systems, and its dependence on the size of a finite system
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 Q84HKV Edit this page History Report an error Markdown