Overview

Shannon entropy measures how mixed or uncertain a set of categories is. It's used for biodiversity, information theory and survey answers.

Enter a count or share for each category.

Worked examples

InputsResult
Share or count for each category35, 25, 20, 12, 8Shannon entropy (H): 1.49Simpson diversity (1-D): 0.75Inverse Simpson: 4.07
Show 2 more examples
Share or count for each category20, 20, 20, 20, 20Shannon entropy (H): 1.61Simpson diversity (1-D): 0.8Inverse Simpson: 5
Share or count for each category90, 5, 5, 0, 0Shannon entropy (H): 0.39Simpson diversity (1-D): 0.19Inverse Simpson: 1.23

How it works

Each category's share p is its count ÷ the total. Entropy, H, is −Σ p × ln p, in natural log units. It's 0 when everything is in one category, and largest, ln of the number of categories, when they're all equal. Simpson's diversity and the inverse Simpson index are shown too.

The formula

H = −Σ pᵢ ln pᵢ

Practical tips

  • Shares of 35, 25, 20, 12 and 8 give H ≈ 1.49.
  • Five equal categories give the maximum, ln 5 ≈ 1.61.
  • For entropy in bits, divide by ln 2, about 0.693.

Frequently asked questions

What is evenness?

H divided by its maximum, ln k. It runs from 0 to 1.

Shannon or Simpson?

Shannon gives more weight to rare categories. Simpson is driven by the common ones.

Does the unit matter?

Natural log gives 'nats', and log base 2 gives 'bits'.