Skip to content

Shannon Diversity Index Calculator

Paste your species counts and get the Shannon diversity index H′ with your choice of logarithm base, Pielou's evenness J′, and the effective number of species. For whole-number counts it also gives a bias-corrected value and a standard error. The working is shown line by line. Runs entirely in your browser. Free, no sign-up.

For example “Oak 25”, one per line. Zero counts are ignored. Counts can be abundances, biomass or cover; whole numbers also give the bias-corrected value and standard error.

Logarithm base

Results

6

Species (S)

70

Individuals (N)

1.5573

Shannon index H′ (nats)

0.8691

Pielou's evenness J′ = H′ ÷ H′max

4.7458

Effective number of species, exp(H′)

1.7918

Maximum H′max = log S (nats)

0.791

Effective number ÷ S

1.593

Miller–Madow corrected H′ (nats)

0.0749

Standard error of H′ (nats)

Species

Speciesnp = n ÷ Nlog p−p × log p
Oak250.3571-1.02960.3677
Beech180.2571-1.35810.3492
Birch120.1714-1.76360.3023
Hazel80.1143-2.16910.2479
Rowan50.0714-2.63910.1885
Holly20.0286-3.55530.1016

The working

  • H′ = −Σ p × log p = 1.5573 nats
  • J′ = H′ ÷ log S = 1.5573 ÷ 1.7918 = 0.8691
  • exp(H′) = 4.7458

How to Use the Shannon Diversity Index Calculator

  1. 1. Enter the counts. One species per line, the name and then its number of individuals (Oak 25), or paste just the numbers. Zero counts are ignored.
  2. 2. Choose the logarithm base. Natural log (ln) is the usual choice in ecology and gives nats. Base 2 gives bits, as in information theory, and base 10 gives hartleys. Use the base your course or paper uses.
  3. 3. Read H′ and J′. H′ is the diversity; J′ says how evenly the individuals are spread over the species, from 0 to 1.
  4. 4. Use the effective number. exp(H′) turns the index into a number of equally common species, which is easier to interpret and to compare.

The Formulas

Shannon's measure of information (1948), borrowed by ecologists, treats a randomly drawn individual as a message: the more species there are, and the more evenly they share the individuals, the harder it is to predict which species you will pick, and the larger H′ is. With p = n ÷ N for each species:

Shannon index

H′ = −Σ p × ln p

Maximum

H′max = ln S, when all S species are equally common

Pielou's evenness

J′ = H′ ÷ H′max = H′ ÷ ln S

Effective number

exp(H′), or 2^(H′ in bits), or 10^(H′ in hartleys)

Miller–Madow

H′ + (S − 1) ÷ (2N), in nats

The base changes only the unit: dividing H′ in nats by ln 2 gives bits. J′ and the effective number are the same whatever base you pick, provided the same base is used for H′ and H′max. The plug-in value of H′ is biased low for small samples, because rare species are often missed, and the Miller–Madow term (S − 1) ÷ 2N is the standard first-order correction. The standard error uses the approximation given by Hutcheson (1970), Var(H′) = (Σ p ln²p − (Σ p ln p)²) ÷ N + (S − 1) ÷ 2N², and works for whole-number counts.

Worked Example

A woodland sample has six tree species with 25, 18, 12, 8, 5 and 2 individuals, so N = 70. These are the calculator's default inputs.

  • The shares are 0.3571, 0.2571, 0.1714, 0.1143, 0.0714 and 0.0286. Their terms −p ln p are 0.3677, 0.3492, 0.3023, 0.2479, 0.1885 and 0.1016.
  • H′ = 1.5573 nats, which is 2.2467 bits.
  • The maximum for six species is ln 6 = 1.7918, so J′ = 1.5573 ÷ 1.7918 = 0.8691.
  • The effective number is exp(1.5573) = 4.7458 species, 79.1% of the 6 present.
  • The Miller–Madow value is 1.5930 nats and the standard error of H′ is 0.0749.

A second sample of 100 individuals with counts of 40, 30, 15, 10 and 5 has H′ = 1.3923 nats, J′ = 0.8651 and an effective number of 4.0242. Five equally common species would give H′ = ln 5 = 1.6094, J′ = 1 and an effective number of exactly 5. A community of 100 individuals in which one species has 96 and four have 1 each has H′ = 0.2234 and J′ = 0.1388: five species on paper, but about 1.25 effective species.

Interpreting and Comparing

  • There is no good or bad H′. It rises with the number of species, so compare communities sampled in the same way. Reported values often fall between about 1.5 and 3.5, but a value only means something against another sample.
  • Richness and evenness are mixed. A rich but uneven community can match a poorer but even one. J′ separates the two, and reporting S, H′ and J′ together is clearest.
  • Rare species count more here than in Simpson's index. If you want an index dominated by the common species, use the Simpson's Diversity Index Calculator.
  • Two samples can be compared with a t-test. Hutcheson's test uses t = (H′₁ − H′₂) ÷ √(SE₁² + SE₂²), with the degrees of freedom given in Hutcheson's paper, using the variances above.
  • Keep the base the same. An H′ in bits and one in nats are not comparable until converted.

Frequently Asked Questions

What is the formula for the Shannon diversity index?
H′ = −Σ pᵢ ln pᵢ, where pᵢ is the proportion of individuals that belong to species i, summed over all species. Using ln gives nats; using log₂ gives bits. The result is zero for one species and ln S for S equally common species.
What is a good Shannon diversity index value?
There is no universal threshold. Values above about 3 are usually thought to show a diverse community and values under 1 a very simple one, but H′ depends on how many species you sampled and how. Use it to compare sites studied in the same way.
What is Pielou's evenness?
J′ = H′ ÷ ln S, the Shannon index as a fraction of its maximum for the number of species. It runs from 0, where one species dominates, to 1, where all species are equally common. It is undefined for a single species.
Should I use ln, log base 2 or log base 10?
Use whichever your course, journal or comparison dataset uses; ecology usually uses the natural log. The choice changes the numbers by a constant factor but not the ranking of communities, and J′ and the effective number are identical for every base.
What is the effective number of species?
It is exp(H′), the number of equally common species that would give the same Shannon index. It puts diversity on an easy scale: a community with H′ = 1.5573 behaves like one with 4.75 equally common species. It is the Hill number of order 1.
How is Shannon different from Simpson?
Both combine richness and evenness. Shannon gives relatively more weight to rare species, while Simpson gives more to the abundant ones. Their effective numbers, exp(H′) and 1 ÷ D, are both Hill numbers and are usually close, with the Shannon one a little larger.

Related Tools

More in Science & Lab Calculators

See all Science & Lab Calculators