FINAL TOOLBOX
04 // Interactive Formula Compendium // STATISTICSH(X) = −∑ p_i · log₂(p_i), C = B · log₂(1 + S/N)

Shannon Information Entropy & Channel Capacity Formula

Binary Shannon entropy H(p) = −p·log₂(p) − (1−p)·log₂(1−p) measures expected surprise in bits per symbol, peaking at 1.000 bit when p = 0.50 and dropping to 0 bits for deterministic outcomes.

Formula Reference
Main Formula
H(X) = −∑ p_i · log₂(p_i), C = B · log₂(1 + S/N)
Rearranged Forms
H_binary(p) = −p·log₂(p) − (1−p)·log₂(1−p)
D_KL(P ∥ Q) = ∑ p_i · log₂(p_i / q_i)
Variables & Units
Variables & Units — Shannon Information Entropy & Channel Capacity Formula
SymbolNameUnit
HBinary Entropy H(p)bits / symbol
pSymbol Probability p0–1
MEquiprobable Alphabet Size M (info log₂M)symbols
Inputs & Parameters
[0–1]
[symbols]
Calculated Result (Binary Entropy H(p))
H =0.811278bits / symbol

Formula Notes & Background

  • Claude Shannon (1948) proved H(X) = −∑ p_i log₂(p_i) is the unique continuous, symmetric, additive functional measuring uncertainty up to a logarithmic base factor.
  • Base-2 logarithms yield 'bits' (shannons); natural logarithms yield 'nats' (1 nat = 1/ln2 ≈ 1.4427 bits).

Step-by-Step Examples

#1: Binary source emitting '1' with probability p = 0.25 and '0' with probability 0.75.
p = 0.251 − p = 0.75
H = −0.25·log₂(0.25) − 0.75·log₂(0.75) = 0.500 + 0.3113
→ H = 0.8113 bits/symbol (compresses ~18.9% below 1 raw bit/symbol)
#2: Shannon-Hartley capacity of a B = 20 MHz wireless channel at SNR = 31 (≈ 14.9 dB).
B = 20 MHzS/N = 31
C = 20 × 10⁶ × log₂(1 + 31) = 20 × 10⁶ × 5
→ C = 100 Mbps theoretical error-free limit
Was this tool helpful?

Frequently Asked Questions

Why do we define 0 · log₂(0) = 0 in Shannon's formula?+

By L'Hôpital's rule, lim_{p→0⁺} p·log₂(p) = 0; impossible events contribute zero expected information.

When is discrete entropy H(X) maximized over M outcomes?+

Strictly when all M outcomes are equiprobable (p_i = 1/M), giving H_max = log₂(M) bits.

How does cross-entropy loss in machine learning relate to Shannon entropy?+

Cross-entropy H(P,Q) = H(P) + D_KL(P ∥ Q), so minimizing cross-entropy against true labels P directly minimizes Kullback-Leibler divergence D_KL.