Shannon Entropy Calculator
Shannon entropy quantifies the average information content (or uncertainty) of a probability distribution. Given a set of outcomes with associated probabilities that sum to 1, the entropy H equals the negative sum of p(i) times log2(p(i)) over all outcomes. The result is measured in bits when the base-2 logarithm is used. Enter outcome probabilities as comma-separated values (they should sum to 1), and the calculator returns the Shannon entropy in bits, the maximum possible entropy for the same number of outcomes, and the normalized entropy (ratio of actual to maximum).
Shannon entropy formula
H(X) = -∑ p(i) × log2(p(i))
Where the sum runs over all outcomes i with p(i) greater than 0. By convention, 0 times log2(0) = 0. Maximum entropy for n equally likely outcomes is log2(n) bits. Normalized entropy is H divided by log2(n).
Entropy examples
- Fair coin (p = 0.5, 0.5): H = 1.00 bit. Maximum possible for 2 outcomes.
- Biased coin (p = 0.9, 0.1): H = 0.469 bits. Lower uncertainty due to bias.
- Fair die (6 sides, p = 1/6 each): H = 2.585 bits.
- Single certain outcome (p = 1.0): H = 0.00 bits. No uncertainty.
- Fair 256-outcome source: H = 8.00 bits (one byte of entropy).
Shannon entropy calculator: frequently asked questions
What is Shannon entropy?
Shannon entropy, introduced by Claude Shannon in 1948, measures the average amount of information (in bits) produced by a probability distribution. Higher entropy means more uncertainty or unpredictability. A fair coin has 1 bit of entropy; a biased coin has less.
How is Shannon entropy calculated?
H = negative sum of p(i) times log2(p(i)) for all outcomes i with nonzero probability. Each term p(i) times log2(p(i)) represents the contribution of outcome i to the total entropy. The result is in bits when base-2 logarithm is used.
What is maximum entropy for a given number of outcomes?
Maximum entropy occurs when all outcomes are equally probable. For n equally probable outcomes, maximum entropy is log2(n) bits. A fair six-sided die has entropy log2(6) = 2.585 bits. Any non-uniform distribution has less entropy.
How is entropy used in cryptography and security?
In cryptography, entropy measures the unpredictability of a key or password. A random 128-bit key has 128 bits of entropy. An attacker trying to guess it must try on average 2^127 values. Low-entropy keys generated from predictable sources (such as weak random number generators) are vulnerable to attack.
What is the difference between Shannon entropy and password entropy?
Shannon entropy H applies to any probability distribution. Password entropy estimates the number of bits needed to represent all possible passwords in a given schema: for a random password with charset size C and length L, entropy = L times log2(C). Both measure unpredictability but in different contexts.
Official sources
- NIST SP 800-90B Recommendation for the Entropy Sources Used for Random Bit Generation: csrc.nist.gov.
- Shannon, C.E. (1948) A Mathematical Theory of Communication, Bell System Technical Journal: doi.org/10.1002/j.1538-7305.1948.tb01338.x.
Reviewed by the CalculatorHub team, edited by James Graham, 15 June 2026. See our methodology.