# What is the Shannon diversity index?

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.

- Page: https://www.acalculator.org/biology/shannon-diversity-index-calculator
- JSON spec: https://www.acalculator.org/biology/shannon-diversity-index-calculator.json
- Version: a9a5ea99e722

## Default answer

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.

## Inputs

| Key | Label | Description |
| --- | --- | --- |
| n | Individuals of each species | How many individuals of each species were counted (or each one’s cover or proportion), separated by commas, spaces or new lines. |
| b | Logarithm | The base of the logarithm: natural log (nats, the usual choice), base 2 (bits) or base 10. |

## Outputs

| Key | Label | Description |
| --- | --- | --- |
| h | Shannon diversity index (H) | −Σ p log p over the species, in the chosen base. |
| evenness | Evenness (H ÷ Hmax) | H divided by its largest possible value, log S; from 0 to 1. |
| hmax | Largest possible H (log S) | H when all S species are equally common. |
| richness | Species (S) | The number of species with a count above 0. |
| total | Total (N) | The sum of all the counts. |

## 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.

## Assumptions

- 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

1. n = 25 or 15, b = e gives h = 1.319545, evenness = 0.951851, hmax = 1.386294, richness = 4, total = 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).
2. n = 5 or 5, b = 2 gives h = 2, evenness = 1, hmax = 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).
3. n = 90 or 5, b = e gives h = 0.394398, evenness = 0.358996, richness = 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).
4. n = 10 or 0, b = 10 gives h = 0.30103, evenness = 1, richness = 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).

## FAQ

### 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.

## Sources

- NIST, Dataplot Reference Manual, SHANNON DIVERSITY INDEX: H = −Σ p_i log(p_i), or [n log n − Σ f_i log f_i] ÷ n for counts; the maximum is log k; the Shannon equitability index E_H = H ÷ log k; proportions 0.25, 0.15, 0.40, 0.20 give 1.319545 and 0.9518508. https://www.itl.nist.gov/div898/software/dataplot/refman2/auxillar/shannon.htm (retrieved 2026-10-18)
- Shannon, C. E. (1948), A Mathematical Theory of Communication, Bell System Technical Journal 27, 379–423 and 623–656: the entropy H = −K Σ p_i log p_i, in bits for base 2. https://doi.org/10.1002/j.1538-7305.1948.tb01338.x
