# skbio.diversity.alpha.shannon

`skbio.diversity.alpha.``shannon`(counts, base=2)

  Calculate Shannon entropy of counts, default in bits.

  State: Experimental as of 0.4.0.

  Shannon-Wiener diversity index is defined as:

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

  where \(s\) is the number of OTUs and \(p_i\) is the proportion of the community represented by OTU \(i\).

  Parameters:

  counts : 1-D array_like, int

  > Vector of counts.

  base : scalar, optional

  > Logarithm base to use in the calculations.

  Returns:

  double

  > Shannon diversity index H.

  Notes

  The implementation here is based on the description given in the SDR-IV online manual [R46] except that the default logarithm base used here is 2 instead of \(e\).

  References

  [R46] | (1, 2) http://www.pisces-conservation.com/sdrhelp/index.html