Shannon diversity index calculator
Type how many individuals of each species you counted in a sample. The calculator gives the Shannon diversity index, its maximum and the evenness, plus Simpson's index of dominance and its common variants.
Runs in your browser: nothing you enter is sent anywhere.
How to use
- Type the count of individuals for each species, for example 40, 25, 20, 10, 5.
- Choose the logarithm for H: natural log is the usual choice in ecology, base 2 gives bits.
- Read H and evenness at the top, then Simpson’s indices, richness S and total N.
- pᵢ = nᵢ ÷ N
- Shannon: H = −Σ pᵢ ln pᵢ (divide by ln 2 or ln 10 for the other bases); Hmax = ln S
- Pielou’s evenness: J = H ÷ Hmax
- Simpson: D = Σ nᵢ(nᵢ − 1) ÷ (N(N − 1)); diversity 1 − D; reciprocal 1/D
- Effective number of species: e^H (H in natural logs)
Worked example
Counts 40, 25, 20, 10, 5 (N = 100, S = 5): the shares are 0.4, 0.25, 0.2, 0.1 and 0.05. H = 0.3665 + 0.3466 + 0.3219 + 0.2303 + 0.1498 = 1.415. Hmax = ln 5 = 1.6094, so J = 1.415 ÷ 1.6094 = 0.8792. Simpson’s D = (40·39 + 25·24 + 20·19 + 10·9 + 5·4) ÷ (100·99) = 2650 ÷ 9900 = 0.2677, 1 − D = 0.7323, 1/D = 3.7358. The effective number of species is e^1.415 = 4.12.
With base 2, H = 2.0414 bits and Hmax = 2.3219.
Tips
- Compare indices only when they use the same logarithm base and similar sampling effort; H rises with sample size as rare species turn up.
- Use whole counts of individuals for Simpson’s D; for cover or biomass data use H and J.
- A species counted as 0 is not part of S — remove it or leave it, the result is the same.
Frequently asked questions
How is the Shannon index calculated?
H = −Σ pᵢ ln pᵢ, where pᵢ is the share of species i in all individuals. It grows with the number of species and with how evenly individuals are spread among them. With base 2 the same value is in bits, with base 10 in decimal units.
What is evenness?
Pielou's evenness J = H ÷ ln S compares the observed H with the maximum possible for S species, reached when all species are equally common. J is 1 for a perfectly even community and drops towards 0 when one species dominates. It does not depend on the logarithm base.
Which Simpson index is shown?
D = Σ nᵢ(nᵢ − 1) ÷ (N(N − 1)) — the probability that two individuals picked at random without replacement belong to the same species. 1 − D is the chance they differ (a diversity measure) and 1/D is the reciprocal form. Some texts use Σpᵢ² instead, which is slightly different for small samples.
What is the effective number of species?
e^H (with H in natural logs) is the number of equally common species that would give the same Shannon index. It is easier to compare than H itself: a community with e^H = 4 is as diverse as one with four equally abundant species.