Home › Calculators › Shannon Entropy Calculator

Shannon Entropy Calculator

Measure the average information, or uncertainty, of a source. Paste text, a list of values, raw counts or a probability distribution and get the Shannon entropy in bits, nats or hartleys, plus maximum entropy, efficiency, perplexity and a full symbol frequency table with the formula worked out.

Last updated:

Input type

Each character (or word) is a symbol; its probability is how often it appears.

Decimals, fractions (1/4) or percentages (25%), separated by commas, spaces or new lines. Optional labels: A: 0.5

Raw tallies such as 10, 5, 5, or one 'label: count' per line.

Values separated by commas, semicolons, tabs or new lines (or spaces if there is no other separator). Identical values are counted together.

Enter your values to see the result.
Advertisement
Advertisement

How to use the Shannon Entropy Calculator

  1. Pick the input type: text, probabilities, counts or a data list.
  2. Enter your data: paste text, or type values separated by commas or new lines (labels like A: 0.5 are optional).
  3. Choose the unit: bits for computing and compression, nats for math and physics, hartleys for base-10 work.
  4. Press Calculate entropy (results also update as you type).
  5. Read the table: see each symbol's probability, self-information and share of the total entropy, then copy the results or download the CSV.

The Shannon entropy formula

For a source with outcomes whose probabilities are p1, p2, …, pn (adding up to 1), the Shannon entropy is

H = −Σ pi · logb(pi)

The base b sets the unit: b = 2 gives bits, b = e gives nats and b = 10 gives hartleys. Each term −p · log p is a symbol's contribution; the quantity −log p alone is its self-information or "surprise": a symbol that appears half the time carries 1 bit, one that appears 1/8 of the time carries 3 bits. Outcomes with probability 0 are skipped, because p · log p tends to 0 as p tends to 0.

When you start from counts (or from a text or data list), each probability is simply pi = counti ÷ total. This is the "plug-in" estimate; with small samples it tends to slightly underestimate the entropy of the underlying source.

Reference values

SourceDistributionEntropy (bits)Entropy (nats)
Certain outcome100
Biased coin0.9 / 0.10.4690.325
Fair coin0.5 / 0.510.693
Four outcomes1/2, 1/4, 1/8, 1/81.751.213
DNA base, all equal4 × 1/421.386
Fair six-sided die6 × 1/62.5851.792
Random letter A–Z26 × 1/264.7003.258
Random digit 0–910 × 1/103.3222.303
Random byte256 × 1/25685.545

Tips for reading the results

  • Compare with the maximum. Entropy alone depends on how many symbols there are; normalized entropy (H ÷ log n) lets you compare a 4-symbol and a 20-symbol distribution on the same 0–1 scale.
  • Characters or words? Character entropy of ordinary English text is usually around 4 to 4.5 bits per character when counted this way; word-level entropy is higher per symbol because the vocabulary is much larger.
  • Case and spaces matter. Treating "A" and "a" as different symbols, or counting spaces, changes the distribution. Choose the option that matches what you want to measure.
  • Ecology and diversity. The Shannon diversity index H′ used for species counts is the same formula with natural logs, so pick nats and enter the counts per species. Evenness (Pielou's J) equals the normalized entropy.
  • Total information. Entropy per symbol × number of symbols gives the order-0 information content, a lower bound for coding each symbol independently.

Frequently asked questions

What is Shannon entropy?

Shannon entropy, introduced by Claude Shannon in 1948, is the average amount of information produced by a random source. For outcomes with probabilities p1 … pn it is H = −Σ pi log(pi). It is highest when all outcomes are equally likely and zero when one outcome is certain.

What is the difference between bits, nats and hartleys?

They are the same quantity measured with a different logarithm base: base 2 gives bits, base e (natural log) gives nats, and base 10 gives hartleys (also called dits or bans). 1 nat ≈ 1.4427 bits and 1 hartley ≈ 3.3219 bits.

How is the entropy of a string calculated?

Each distinct character (or word) is treated as a symbol. Its probability is its count divided by the total number of symbols, and those probabilities go into H = −Σ p log₂ p. For example, "hello world" has 8 distinct characters among 11 and an entropy of about 2.845 bits per character.

What is the maximum possible entropy?

With n possible outcomes, entropy is largest when every outcome has probability 1/n, giving Hmax = log(n). A fair coin has 1 bit, a fair six-sided die log₂ 6 ≈ 2.585 bits, and 256 equally likely byte values give 8 bits.

What do normalized entropy and perplexity mean?

Normalized entropy (efficiency) is H divided by Hmax, a 0 to 1 score of how evenly spread the distribution is; redundancy is 1 minus that. Perplexity is 2 raised to the entropy in bits, the number of equally likely choices that would have the same uncertainty.

Does the entropy of a text tell me how well it compresses?

It gives the order-0 limit: the fewest bits per symbol an ideal code could use if each symbol were coded independently with these frequencies. Real compressors such as ZIP also exploit repeated patterns and context, so they can do better on long text, while very short inputs carry overhead.

Is character entropy the same as password strength?

No. The entropy of a single string's own character frequencies is not the same as password entropy, which depends on how the password was chosen (the size of the pool and the number of random picks). Use it as a rough indicator of variety only.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

Probability CalculatorFind and, or, not, conditional and at-least-once probabilities from P(A) and P(B).Logarithm CalculatorCalculate log in any base, ln, log10, log2 and antilog with change-of-base steps.Frequency Table GeneratorMake a frequency, relative and cumulative frequency table from numbers or categories.Letter Frequency CounterCount how often each letter appears, compare with English frequencies and see top bigrams.Weighted Average CalculatorCalculate a weighted mean from values and weights, step by step.Average CalculatorMean, weighted average, median, sum, min and max of any list.Standard Deviation CalculatorStandard deviation, variance, mean, median, mode and quartiles.A/B Test Significance CalculatorCheck if your A/B test result is statistically significant.Z-Score CalculatorZ-score from a value, mean and SD, plus percentile and p-value; or the value from z.Permutation and Combination CalculatorCalculate nPr and nCr, with or without repetition, as exact big numbers.Mean Median Mode CalculatorFind the mean, median, mode, range, min, max, sum and count of a list of numbers.Confidence Interval CalculatorConfidence interval and margin of error for a mean or a proportion, with steps.Sample Size CalculatorHow many survey responses you need for a given confidence level and margin of error.Percentile CalculatorValue at any percentile, percentile rank of a score, quartiles, IQR and outliers.Correlation Coefficient CalculatorPearson r and Spearman rank correlation with significance and interpretation.Average Order Value CalculatorAverage order value from revenue and orders, plus the revenue impact of raising AOV.Binomial Distribution CalculatorBinomial probabilities P(X = k), at most, at least or between, with mean, variance and chart.Normal Distribution CalculatorNormal probabilities P(X < x), between two values and inverse percentiles, on a shaded bell curve.Poisson Distribution CalculatorPoisson probabilities for a rate λ: exactly k, at most, at least or between, with a chart.T-Test CalculatorOne-sample, two-sample (Welch/pooled) and paired t-tests with p-value and CI.Chi-Square CalculatorChi-square goodness-of-fit and independence tests with p-value and expected counts.P-Value CalculatorOne- or two-tailed p-values from z, t, chi-square or F statistics, with critical values.Variance CalculatorSample and population variance and standard deviation with a step-by-step deviations table.Five Number Summary CalculatorMin, Q1, median, Q3, max, IQR and fences of a data set, with a box plot.Outlier CalculatorFind outliers with 1.5×/3× IQR fences, z-scores or modified z-scores; get the cleaned data.Geometric Mean CalculatorGeometric, harmonic, arithmetic and quadratic means compared, or average growth from % changes.Expected Value CalculatorExpected value, variance and standard deviation from outcomes and their probabilities.One-Way ANOVA CalculatorOne-way ANOVA for 2-10 groups: SS, df, MS, F statistic, p-value, effect size and full table.Bayes Theorem CalculatorPosterior P(A|B) from P(A), P(B|A) and P(B|not A), with a probability tree and table.Box Plot MakerPaste data to draw box-and-whisker plots with quartiles, IQR and outliers. Download PNG or SVG.Coefficient of Variation CalculatorCV % from a dataset (sample or population) with mean, SD and a two-dataset comparison.Critical Value CalculatorCritical values of z, t, chi-square and F for any alpha, tails and degrees of freedom.Dice Probability CalculatorOdds of rolling a sum (exactly, at least, at most) with any dice, plus the full distribution.Effect Size Calculator (Cohen's d)Cohen's d, Hedges' g and Glass's delta from two means, SDs and sample sizes, with CI.Histogram MakerPaste numbers, choose bins and get a histogram, frequency table and PNG download.Margin of Error CalculatorSurvey margin of error from sample size, confidence and proportion, with population correction.Moving Average CalculatorSimple, exponential and weighted moving averages of a data series, with table and line chart.Odds Ratio and Relative Risk CalculatorOdds ratio, relative risk, risk difference, 95% CIs and p-values from a 2x2 table.Grouped Data CalculatorMean, median, mode, variance and standard deviation from class intervals and frequencies.Inverse Normal Distribution CalculatorinvNorm: find the x or z value for a left, right, central or two-tail area, with a shaded curve.Permutations GeneratorList all permutations of letters, words or items, with k-permutations and repeats, and export them.Statistical Power CalculatorPower or required sample size for t-tests, proportions and correlations, with a power curve.T Distribution CalculatorStudent's t probabilities and critical values for any df, with the area shaded on the curve.T-Table (Student's t Distribution)Interactive t-table: critical t-values for any df and α, p-values, and a printable full table.Z-Test CalculatorOne-sample, two-sample and proportion z-tests with z, p-value, decision and shaded curve.Standard Error CalculatorStandard error of the mean from data or SD and n, plus SE of a proportion, with CIs.Descriptive Statistics CalculatorPaste data and get mean, median, mode, quartiles, SD, skewness, kurtosis and a histogram.Empirical Rule Calculator68-95-99.7 rule ranges from a mean and standard deviation, with a shaded bell curve.Z-Table (Standard Normal Table)Interactive z-table: find the area for any z-score, or the z-score for a probability.Average Rate of Change CalculatorAverage rate of change of f(x), two points or a data table over [a, b], with the secant line.Binomial Expansion CalculatorExpand (a + b)^n with the binomial theorem: every term, Pascal coefficients and any specific term.Combinations GeneratorList every k-combination of your items, with or without repetition, and copy or export them.Covariance CalculatorSample and population covariance of paired X and Y data, with a step table and scatter plot.
See all 52 Statistics & Probability Calculators →