Lexical Diversity Calculator — TTR, MTLD, HD-D
Paste an essay, transcript or language sample and get eight published lexical diversity indices at once — including the three that do not collapse as the text gets longer: MTLD, MATTR and HD-D. Every count runs in your browser; nothing is uploaded.
Analyse a text sample
The eight indices
| Index | Value | Length behaviour | Reading |
|---|---|---|---|
| Type-Token RatioTTR = V / N | — | length-dependent | — |
| Root TTR (Guiraud)RTTR = V / sqrt(N) | — | length-dependent | — |
| Corrected TTR (Carroll)CTTR = V / sqrt(2N) | — | partly corrected | — |
| Herdan's CC = log(V) / log(N) | — | partly corrected | — |
| Maas a²a² = (log N - log V) / (log N)² | — | partly corrected | — |
| MSTTRmean TTR of consecutive W-token segments | — | length-robust | — |
| MATTRmean TTR over all N-W+1 sliding windows | — | length-robust | — |
| MTLDN / factors, forward and backward averaged | — | length-robust | — |
| HD-D (vocd-D)sum of P(type in 42-token sample) / 42 | — | length-robust | — |
MTLD passes: —. Bands are rules of thumb for English prose at the default settings, not normative cut-offs — only the MTLD anchor near 72 comes from a published corpus mean (McCarthy & Jarvis 2010). Compare texts with each other, using identical settings.
MATTR across the text
How each index is computed
Tokens are the running word forms of the text; types are the distinct lowercased forms among them. Everything below is derived from those two counts, or from the token sequence itself.
The ratio family (length-dependent)
Plain TTR is types over tokens. It has one fatal property: it falls as the text grows, because function words recur while new content words arrive ever more slowly. Two texts are only comparable by TTR if they have the same token count. Root TTR (Guiraud, 1954) and Corrected TTR (Carroll, 1964) divide by the square root of N and of 2N to damp that decline; Herdan's C (1960) and Maas (1972) apply logarithmic transformations for the same reason. All of them reduce the length effect without removing it.
The window family (MSTTR and MATTR)
MSTTR chops the text into consecutive non-overlapping segments of W tokens (default 50), computes TTR in each and averages them; any leftover tokens shorter than one full segment are discarded, so MSTTR ignores up to W-1 tokens at the end. MATTR (Covington & McFall, 2010) instead slides a window of W tokens one token at a time and averages the TTR of all N-W+1 windows, which uses every token and gives a smooth series you can plot — that is the sparkline above.
MTLD
MTLD (McCarthy & Jarvis, 2010) measures the mean number of tokens it takes for the running TTR to fall to the factor threshold of 0.720. The algorithm walks through the tokens keeping running type and token counts; when the running TTR reaches the threshold, one factor is recorded and both counters reset. Whatever is left over at the end contributes a partial factor. The whole procedure is run forward and then over the reversed token list, and the two results are averaged.
Because MTLD counts how far the text travels before diversity decays, it is expressed in tokens: a value of 80 means the running TTR survives roughly 80 tokens before dropping to 0.720. If a text never reaches the threshold (very short or entirely unique wording) no full factor exists and MTLD cannot be computed — the tool says so rather than inventing a number.
HD-D
HD-D (McCarthy & Jarvis, 2007) replaces the random sampling of vocd-D with the exact hypergeometric probability. For every type t with frequency f, it computes the chance that at least one of its tokens lands in a random draw of 42 tokens from the text, weights that probability by 1/42, and sums over all types. The 42-token sample is the midpoint of the 35-to-50 range used by the original vocd-D curve fit, which is why HD-D reproduces vocd-D deterministically.
The binomial coefficients would overflow double precision for texts of a few hundred words, so this page evaluates them in log space with a Lanczos log-gamma: log C(n,k) = lgamma(n+1) - lgamma(k+1) - lgamma(n-k+1), and the ratio is recovered with a single exponential. Any type frequent enough that N - f is below 42 is certain to appear, contributing exactly 1/42.
Sample-size limits
- HD-D is undefined below 42 tokens — a 42-token sample cannot be drawn.
- MATTR and MSTTR need at least one full window; below that the tool falls back to plain TTR and flags it.
- Below roughly 50 tokens all window-based and hypergeometric indices are unstable; below 100 tokens treat MTLD as indicative only.
- Stopword removal and inflection normalisation both change N and V, so their results are not comparable to published norms. Use them only to compare texts processed the same way.