scikit-bio is back in active development! Check out our announcement of revitalization.

skbio.diversity.alpha.shannon#

skbio.diversity.alpha.shannon(counts, base=2)[source]#

Calculate Shannon’s diversity index, default in bits.

Shannon’s diversity index, \(H'\), a.k.a., Shannon index, or Shannon- Wiener index, is defined as

\[H' = -\sum_{i=1}^s\left(p_i\log_2 p_i\right)\]

where \(s\) is the number of taxa and \(p_i\) is the proportion of the sample represented by taxon \(i\).

Parameters:
counts1-D array_like, int

Vector of counts.

basescalar, optional

Logarithm base to use in the calculation.

Returns:
double

Shannon’s diversity index.

Notes

Shannon’s diversity index was originally proposed in [1] as a measure of entropy.

The default logarithm base used here is 2 instead of \(e\).

References

[1]

Shannon, C. E. (1948). A mathematical theory of communication. The Bell system technical journal, 27(3), 379-423.