What is the Shannon diversity index?
Type how many individuals of each species you counted. The Shannon diversity index calculator gives H = −Σ p ln p, its evenness (equitability) H ÷ ln S, and the largest H possible for that many species.
- Shannon diversity index (H)
- 1.31955
The Shannon diversity index is H = 1.31955 for 4 species.
- Evenness (H ÷ Hmax)
- 0.951851
- Largest possible H (log S)
- 1.38629
- Species (S)
- 4
- Total (N)
- 100
Shannon diversity index (H): 1.31955. The Shannon diversity index is H = 1.31955 for 4 species.
How to calculate
Computes the Shannon diversity index H = −Σ p ln p from the number of individuals of each species, with the evenness (equitability) H ÷ ln S and the species count, in natural log, base 2 or base 10.
Example with the default inputs (Individuals of each species [25, 15, 40, 20], Logarithm ln (base e)): The Shannon diversity index is H = 1.31955 for 4 species.
Method: p = n ÷ N for each species; H = −Σ p ln p (divided by ln 2 or ln 10 for base 2 or 10); evenness = H ÷ ln S, the same in any base.
- Each count is the number of individuals of one species (or its cover or proportion); N is their sum and S the number of species with a count above 0.
- Species with a count of 0 are left out: p ln p is taken as 0 for them.
- Natural logarithms are the usual choice in ecology; base 2 gives H in bits.
Worked examples
Each example is checked against the calculator on every build.
- Individuals of each species 25, 15, 40, 20, Logarithm ln (base e) gives Shannon diversity index (H) 1.319545, Evenness (H ÷ Hmax) 0.951851, Largest possible H (log S) 1.386294, Species (S) 4, Total (N) 100.Source: NIST, Dataplot Reference Manual, SHANNON DIVERSITY INDEX (H = −Σ p_i log p_i; maximum log k; equitability E_H = H ÷ log k; proportions 0.25, 0.15, 0.40, 0.20 give 1.319545 and 0.9518508; Shannon 1948), https://www.itl.nist.gov/div898/software/dataplot/refman2/auxillar/shannon.htm (retrieved 2026-10-18)
- Individuals of each species 5, 5, 5, 5, Logarithm log₂ gives Shannon diversity index (H) 2, Evenness (H ÷ Hmax) 1, Largest possible H (log S) 2.Source: Shannon, C. E. (1948), A Mathematical Theory of Communication, Bell System Technical Journal 27, 379–423 and 623–656 (H = −K Σ p_i log p_i; the base sets the unit: 2 gives bits), https://doi.org/10.1002/j.1538-7305.1948.tb01338.x; NIST, Dataplot Reference Manual, SHANNON DIVERSITY INDEX (H = −Σ p_i log p_i; maximum log k; equitability E_H = H ÷ log k; proportions 0.25, 0.15, 0.40, 0.20 give 1.319545 and 0.9518508; Shannon 1948), https://www.itl.nist.gov/div898/software/dataplot/refman2/auxillar/shannon.htm (retrieved 2026-10-18)
- Individuals of each species 90, 5, 5, Logarithm ln (base e) gives Shannon diversity index (H) 0.394398, Evenness (H ÷ Hmax) 0.358996, Species (S) 3.Source: NIST, Dataplot Reference Manual, SHANNON DIVERSITY INDEX (H = −Σ p_i log p_i; maximum log k; equitability E_H = H ÷ log k; proportions 0.25, 0.15, 0.40, 0.20 give 1.319545 and 0.9518508; Shannon 1948), https://www.itl.nist.gov/div898/software/dataplot/refman2/auxillar/shannon.htm (retrieved 2026-10-18)
- Individuals of each species 10, 0, 10, Logarithm log₁₀ gives Shannon diversity index (H) 0.30103, Evenness (H ÷ Hmax) 1, Species (S) 2.Source: NIST, Dataplot Reference Manual, SHANNON DIVERSITY INDEX (H = −Σ p_i log p_i; maximum log k; equitability E_H = H ÷ log k; proportions 0.25, 0.15, 0.40, 0.20 give 1.319545 and 0.9518508; Shannon 1948), https://www.itl.nist.gov/div898/software/dataplot/refman2/auxillar/shannon.htm (retrieved 2026-10-18)
How it works
Let n be the count of each species, N = Σ n the total, and S the number of species with n above 0. Each species’ proportion is p = n ÷ N. Then
H = −Σ p ln p
summed over the species with n above 0 (a count of 0 adds nothing). With base 2 or base 10, H is divided by ln 2 or ln 10, giving H in bits or in decimal digits.
- Largest possible H = log S, in the chosen base: the value when all S species are equally common.
- Evenness (Shannon equitability, Pielou’s J) = H ÷ log S = (−Σ p ln p) ÷ ln S. It is the same in every base, and it is not shown when S = 1 (log 1 = 0).
Rules. Type 1 to 1,000 counts. Counts may be decimals (cover, biomass or proportions) but not negative, and at least one must be above 0. A total above about 1.8 × 10³⁰⁸ (too large for a 64-bit float) has no answer. The proportions are exact fractions of the typed counts; the logarithms are worked in floating point. For a species with more than half of the total, ln p is worked as ln(1 − q) from the exact rest q = 1 − p, so H keeps its digits when one species dominates. A share too small for a 64-bit float still adds its term. When one species makes up almost all of the total, an H or evenness above 0 but below about 10⁻³²³ (too small for a 64-bit float) has no answer.
Output format. H, the evenness and the largest H show 6 significant figures; S is a whole number.
Worked examples by hand
NIST’s example as 100 individuals (the default). Counts 25, 15, 40, 20, so p = 0.25, 0.15, 0.40, 0.20. The terms −p ln p are 0.346574, 0.284568, 0.366516 and 0.321888, so H = 1.31955 (NIST: 1.319545). ln 4 = 1.38629, and the evenness is 1.31955 ÷ 1.38629 = 0.951851 (NIST: 0.9518508).
Four equal species, in bits. Counts 5, 5, 5, 5: each p = 0.25 and log₂ 0.25 = −2, so H = −4 × 0.25 × (−2) = 2 bits. log₂ 4 = 2, so the evenness is 1.
One dominant species. Counts 90, 5, 5: H = −(0.9 ln 0.9 + 2 × 0.05 ln 0.05) = 0.094825 + 0.299573 = 0.394398. ln 3 = 1.09861, so the evenness is 0.358996.
Two equal species and an empty one, in base 10. Counts 10, 0, 10: the 0 is left out, so S = 2 and H = −2 × 0.5 × log₁₀ 0.5 = log₁₀ 2 = 0.30103, with evenness 1.
Other questions people ask
How do I calculate the Shannon diversity index?
Divide each species’ count by the total to get its proportion p. Multiply each p by ln p, add the results and change the sign: H = −Σ p ln p. For proportions 0.25, 0.15, 0.40 and 0.20: H = 0.3466 + 0.2846 + 0.3665 + 0.3219 = 1.3195.
How do I calculate Shannon evenness?
Divide H by ln S, the largest value H can take with S species (when all are equally common). The four species above have ln 4 = 1.3863, so the evenness is 1.3195 ÷ 1.3863 = 0.952. It runs from 0 to 1, and 1 means every species is equally common.
What is a good Shannon diversity index?
There is no fixed scale, and the value depends on the log base and on how many species were found. Compare sites sampled the same way: a higher H means more species, more evenly spread. H is 0 for a single species and ln S for S equally common species.
Should I use ln, log₂ or log₁₀?
The natural log, ln, is the usual choice, and NIST’s examples use it. Shannon’s paper used base 2, which gives H in bits, and base 10 is also seen. Use the base of the study you compare with; the evenness is the same in every base.
Is the Shannon index the same as the Shannon-Wiener index?
Yes. The same formula is also called the Shannon-Wiener or Shannon-Weaver index, written H or H′. It is the entropy of the species proportions.
Can I use percent cover or biomass instead of counts?
Yes. Only the proportions matter, so any measure of how much of each species there is works, such as cover or biomass, typed with decimals if needed.