The Shannon entropy of a discrete XX with p(x)=P(X=x)p(x)=\mathbb{P}(X=x) is

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

with the convention 0log0=00\log 0=0. The value may be ++\infty. Unless stated otherwise, log\log denotes the natural logarithm; changing its base rescales HH by a constant factor.

Equivalent characterizations

Equivalently, H(X)H(X) is the of logp(X)-\log p(X) under the distribution of XX.

Remarks

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.