Zipf’s Law Rank-Frequency (f_r = f₁ / r^s) & Generalized Harmonic Number Calculator

Predict rank-r frequency f_r = f₁ / r^s and cumulative corpus share across N items.

Predicted Frequency at Rank #10 10,000 occurrences
Generalized Harmonic Number H_{V,s} 7.486 H
Corpus Share of Rank #10 1.336 %
Estimated Total Corpus Occurrences 748,547.086 total
Inputs
Try:
count
Frequency of the #1 top-ranked item (f₁).
rank r
Rank r of the item to evaluate (r ≥ 1).
s
Zipf characterization exponent s (classic linguistic Zipf law s ≈ 1.0).
items N
Total number of distinct ranked items N in the system.
Results & Graph
Predicted Frequency at Rank #10
10,000 occurrences
Generalized Harmonic Number H_{V,s}
7.486 H
Corpus Share of Rank #10
1.336 %
Estimated Total Corpus Occurrences
748,547.086 total

Predicted Frequency at Rank #10

Graph 1 • How the inputs feed Zipf’s Law Rank-Frequency
Zipf’s Law Rank-Frequency (f_r = f₁ / r^s) & Generalized Harmonic Number Calculator • Custom Domain Schematic (Econometrics & Regression) rank1ToptargetItZipf’s Law Rank-Freque Rank1 Top Frequency F1: 100.0k count • Target Item Rank R: 10 rank r PREDICTED FREQUENCY AT RAN 10,000 occurrences • Generalized Harmonic N: 7.486 H • Corpus Share of Rank #: 1.336 % Eq: f(r) = f_1 / r^s; Probability(
Graph 2 • Predicted Frequency at Rank #10 as Rank1 Top Frequency F1 changes (40% to 160% of current)
0 occurr 8.8k occurr 17.6k occurr 4.0k 40.0kcount 6.0k 60.0kcount 8.0k 80.0kcount 10.0k 100.0kcount 12.0k 120.0kcount 14.0k 140.0kcount 16.0k 160.0kcount
Graph 3 • Rank1 Top Frequency F1 and Target Item Rank R together Compares Predicted Frequency at Rank #10 when Target Item Rank R is shifted +25% (solid) vs. −25% (dashed).
0 occurr 7.2k occurr 14.3k occurr --- Target Item Rank R @ 75% 7.0k -30% 8.5k -15% 10.0k +0% 11.5k +15% 13.0k +30%
Summary: Under Zipf’s Law (s=1, f₁=100,000), Rank #10 has predicted frequency 10000 and accounts for 1.336% of total corpus volume (H_1000 = 7.485).
Summary: Under Zipf’s Law (s=1, f₁=100,000), Rank #10 has predicted frequency 10000 and accounts for 1.336% of total corpus volume (H_1000 = 7.485).
Interactive chart & math engine powered by CalculatorGraph

Formula: Zipf’s Law Rank-Frequency Formula

f(r) = f1 / rs
Probability(r) = (1 / rs) / Σk=1..N (1 / ks)
f(r) = f_1 / r^s; Probability(r) = (1 / r^s) / Σ_{k=1..N} (1 / k^s)
  • rank1TopFrequencyF1: Rank1 Top Frequency F1 (count)
  • targetItemRankR: Target Item Rank R (rank r)
  • zipfExponentS: Zipf Exponent S (s)
  • totalVocabularySizeV: Total Vocabulary Size V (items N)

Frequently Asked Questions

What is the generalized harmonic number in plain terms?

It is the sum of 1 over k to the power s for every rank k from 1 to N. Under Zipf's law it is the total of all the relative frequencies, so dividing any single rank's value by it turns that value into a share of the whole. At the defaults it is about 7.486.

Why does the summary say 7.485 while the supporting line says 7.486?

The underlying value for 1,000 items at s equal to 1 is about 7.4855, close to the rounding boundary. Rounded to three places that is 7.485, which the interpretation text shows correctly; the supporting line's 7.486 is a display rounding slip. The share and the corpus total are computed from the unrounded value, so neither display affects them. Use either for reading, not for further arithmetic.

Does the predicted frequency depend on vocabulary size?

No. The count at rank r is f1 divided by r to the power s, which does not involve N. Changing the vocabulary from 1,000 to 10,000 leaves rank 10 at 10,000 occurrences. Only the harmonic number, the corpus share and the estimated total change. The count is fixed by f1, r and s alone.

How do I estimate s from my own data?

Sort your items by frequency, take the logarithm of both rank and frequency, and fit a straight line through the points. The exponent is the negative of the slope. Fitting only the middle ranks often gives a more stable value than including the very top and the long tail, where real data tends to bend.

What does the estimated total corpus occurrences mean?

It is f1 multiplied by the harmonic number: the sum of the predicted counts for every rank from 1 to N. At the defaults it is 748,547.086. It only counts the N items in your vocabulary, so if your real data has more distinct items the true total will be larger.

Can s be less than 1?

Yes. Values below 1 give a flatter curve where rare items carry more of the total. At s equal to 0.8, the flatter preset, the harmonic number for 1,000 items is 15.47 and rank 10 holds 1.025% of the corpus. The engine accepts any value above 0 up to 5. Very low values approach an even spread across all ranks.

Why does a bigger exponent give rank 10 a bigger share?

A steeper curve shrinks rank 10's count, but it shrinks the long tail even more. At s equal to 1.2 the harmonic number falls to 4.336, so the total corpus is much smaller and rank 10's slice of it rises to 1.455%. The effect reverses for very deep ranks, which lose share as s grows.

What share do the top ten items hold at the defaults?

Add the first ten terms of the harmonic sum, which come to 2.929, and divide by the full sum of 7.486. That gives about 39%. The page does not show this cumulative figure directly, but you can get it by running the calculator with N set to 10 to read the partial sum.

Is there a maximum vocabulary size?

Yes, one million items, and the page shows an error above that rather than silently reducing it. That is far larger than most frequency lists people paste in. At s equal to 1 you can also approximate H for any big vocabulary as the natural log of N plus 0.577, which gives about 12.09 for one hundred thousand items.

What happens if I ask for a rank beyond the vocabulary?

The page shows an error and asks for a vocabulary at least as large as the rank. A rank of two thousand in a 1,000 item list does not exist, so there is nothing sensible to compute. Increase the vocabulary size to cover the rank, or pick a rank inside your list.

Does Zipf's law fit city sizes and web traffic too?

It is often used for them, which is why the calculator mentions them, but the exponent and the quality of fit vary. Some datasets follow a straight log-log line over a wide range; others curve. Check your own data before assuming a value of s, and treat predictions far outside the fitted range with caution.

Rank 10 out of a thousand words: the default case

The calculator starts with a small imaginary vocabulary of 1,000 distinct items. The most common item, rank 1, appears 100,000 times. The Zipf exponent is 1, the classic value for word frequencies, and the item being asked about is rank 10.

Under those settings rank 10 is predicted to appear 10,000 times. The generalized harmonic number for 1,000 items at s equal to 1 is about 7.486, the tenth item holds 1.336% of the whole corpus, and the corpus as a whole is estimated at 748,547.086 occurrences.

Each of those numbers comes from one of two formulas. The first is the rank-frequency rule on its own: f(r) equals f1 divided by r to the power s. With s equal to 1 that is just 100,000 divided by 10. The second uses the normaliser H(N,s), the sum of 1 over k to the power s for every rank k from 1 to N. Dividing 1 over r to the power s by that sum gives the share of rank r, and multiplying f1 by the sum gives the total size of the corpus.

Building H(N,s) by hand for ten items

The harmonic number sounds abstract, but for a small N you can add it up on paper. Set the vocabulary to 10 and keep s at 1. The terms are 1, 0.5, 0.333, 0.25, 0.2, 0.167, 0.143, 0.125, 0.111 and 0.1. Their sum is 2.929, which is exactly what the page reports for N equal to 10.

With that normaliser in hand, the share of each rank is its own term divided by 2.929. Rank 1 takes 34.1%, rank 2 takes 17.1% and rank 10 takes 3.414%. The calculator returns that last figure when you leave the target rank at 10 and shrink the vocabulary.

For large N at s equal to 1, the sum grows very slowly, roughly as the natural logarithm of N plus 0.577. The logarithm of 1,000 is about 6.908, so H is about 7.485, matching the default. This slow growth is why the share of the top item falls only gradually as the vocabulary gets bigger.

Above s equal to 1 the sum converges. At s equal to 2 it approaches pi squared over 6, about 1.645, and the page shows 1.644 for 1,000 items. Adding more rare items barely changes the total any more.

Why changing f1 leaves the percentage alone

Try changing only the top frequency. Halve f1 to 50 thousand and rank 10 is predicted at 5 thousand occurrences; double it and rank 10 doubles too. The estimated corpus total moves in exactly the same proportion, because it is f1 multiplied by the harmonic number.

The corpus share stays at 1.336% whatever f1 you type. That is not a coincidence. The share is the ratio of rank 10's term to the sum of all terms, and f1 multiplies both the top and the bottom, so it cancels. The harmonic number, 7.486 at the defaults, does not involve f1 at all.

This gives a useful way to read the page. The exponent and the vocabulary size set the shape of the distribution: how quickly frequency falls and how much of the total sits in the head. The top frequency only sets the scale, turning those proportions into raw counts. That is why the presets on this page vary s rather than f1: the s presets are the ones that change the shape.

How the exponent reshapes the curve

The exponent s controls how steeply frequency falls with rank, and small changes have large effects. The flatter preset, s equal to 0.8, predicts rank 10 at 15,848.932 occurrences with a 1.025% share, and the harmonic number climbs to 15.47. The estimated corpus grows to 1,546,981.038, about double the default. The tail is heavier, so the top item holds a smaller fraction of a larger total.

The steeper preset, s equal to 1.2, drops rank 10 to 6,309.573, the harmonic number to 4.336 and the corpus total to 433,576.48. The share of rank 10 rises to 1.455%. The head is now more dominant, so even a mid ranking item gets a larger slice of a smaller corpus.

At s equal to 2 the curve is very steep. Rank 10 appears only 1,000 times and holds 0.608% of the corpus, while the harmonic number shrinks to 1.644. Most of the mass is in the first handful of ranks.

If you are fitting real data, s is usually estimated as the negative slope of log frequency against log rank. Different kinds of data, such as words, city sizes or website visits, can give different slopes, and the slope can change between the head and the tail of the same dataset. Treat a single s as an approximation over the range you care about.

Vocabulary size changes the share, not the count

The predicted frequency at rank r ignores N entirely, because it is just f1 over r to the power s. What N does affect is the normaliser, and therefore the share and the corpus total.

Raising the vocabulary from 1,000 to 10,000 keeps rank 10 at 10,000 occurrences but lifts H to 9.788 and drops the share to 1.022%. The nine thousand extra rare items each add very little, but together they increase the size of the corpus and dilute every rank's percentage.

This is the main reason to set N carefully. If you only count the items you have actually observed, the share of a common item will look higher than it would in a fuller sample. If you guess a very large N, the share falls. Neither choice changes the count the page predicts for your target rank.

Rank 1 and rank 2 under the classic law

Setting the target rank to 1 is a quick sanity check. The predicted frequency is simply f1, 100,000, and the share is 13.359%. In other words, with a 1,000 item vocabulary at s equal to 1, the single most common item makes up a little over an eighth of everything.

Rank 2 is predicted at half of rank 1, and its share is 6.68%. Rank 3 would be a third, rank 4 a quarter, and so on. That simple halving and thirding pattern is the usual way Zipf's law is described for words, and it only holds exactly when s is 1.

Comparing the shares of ranks 1, 2 and 10 shows how concentrated a Zipf distribution is. The top 10 items together hold about 39% of the corpus at the default settings, since the first ten terms add to 2.929 out of 7.486.

Reading the 1.336% share as a probability

The corpus share line is also the probability that a randomly chosen occurrence belongs to your target rank. At the defaults, if you picked one token at random from the whole modelled corpus, there is a 1.336% chance it would be the tenth most common item. Put another way, you would expect to see it about once every 75 tokens.

That reading is handy for sampling questions. If you want to see rank 10 at least a few dozen times before trusting its count, you need a sample of a few thousand tokens. Rank 1, at 13.359%, turns up roughly once every 7.5 tokens, so even a short sample gives a stable count for it.

Deep ranks are the opposite. Their shares are tiny, so their observed counts in a small sample are noisy and often zero. That is one reason real frequency lists look ragged in the tail even when the underlying process is close to Zipf.

Input ranges the Zipf engine accepts

The calculator checks its inputs and shows an error rather than guessing. The top frequency must be above zero. The target rank must be a whole number of 1 or more. The vocabulary must be a whole number at least as large as the rank and no larger than one million items. The exponent must be above 0 and no more than 5.

The rank rule matters most in practice. Asking for rank two thousand in a 1,000 item vocabulary is a contradiction, so the page refuses it instead of quietly enlarging the vocabulary. Raise N first if the item really exists in your list.

Large vocabularies are fine. At s equal to 1, raising N to one hundred thousand gives a harmonic number of 12.09 and drops rank 10's share to 0.827%. An exponent of exactly 0 is rejected because it would mean every rank is equally common, which is no longer a Zipf curve; small positive values such as 0.3 are allowed.

When a Zipf estimate is useful and when it is not

The page is most useful for rough planning: guessing how often a mid ranking word will appear in a corpus of a known size, how much traffic a tenth most popular page might get relative to the top page, or how big a vocabulary has to be before a given share of text is covered.

It is a model, not a measurement. Real frequency lists often bend away from a straight Zipf line at the very top and in the long tail of rare items. A predicted 10,000 for rank 10 is the count you would expect if the law held exactly with your chosen s. Compare it with real counts for a few ranks before using the predictions for anything that matters, and refit s if the fit is poor.