Shannon entropy

A measure of uncertainty of a discrete random variable, defined from its probability mass function.
Shannon entropy

A Shannon entropy is a number H(X)H(X) associated to a discrete XX with probability mass function p(x)=P(X=x)p(x)=\mathbb{P}(X=x), defined by

H(X)  =  xp(x)logp(x), H(X) \;=\; -\sum_x p(x)\,\log p(x),

with the convention 0log0=00\log 0=0. (Unless stated otherwise, log\log denotes the natural logarithm; changing the base rescales HH by a constant factor.)

Equivalently, H(X)H(X) is the of logp(X)-\log p(X) under the distribution of XX. Shannon entropy is closely related to and is a central quantity in information theory.

Examples:

  • If XBernoulli(p)X\sim\mathrm{Bernoulli}(p), then H(X)=plogp(1p)log(1p)H(X)=-p\log p-(1-p)\log(1-p).
  • If XX is uniform on {1,2,3,4,5,6}\{1,2,3,4,5,6\}, then H(X)=log6H(X)=\log 6.