The Question

When a probability model becomes more spread out, does its entropy always increase? And what happens when the model assigns the wrong probabilities?

Use three experiments to separate uncertainty in discrete outcomes, differential entropy for continuous variables, and cross-entropy after a common binning rule. No Python installation or account is required.

Open the Explorer

Open the full-page probability and entropy lab

The full-page view is recommended for the comparison tables and cross-entropy matrix. Within each table, scroll horizontally to inspect additional columns.

If the embedded lab is unavailable, follow the worked values below. Formula rendering uses MathJax from an external CDN; the numerical explorer itself runs locally in your browser.

Experiment 1: A Coin’s Uncertainty

Choose Detailed explorer, then Bernoulli. Before moving the success probability, predict whether a fair coin or an almost-certain outcome has greater entropy.

Compare p = 0, p = 0.5, and p = 1. The deterministic endpoints have entropy zero. The fair coin has entropy approximately 0.693147 nats, equivalent to 1 bit. The lab uses natural logarithms for its nats values.

The uncertainty concerns which outcome occurs, not whether the numerical outcome is large. A high probability of success is not the same thing as high entropy.

Experiment 2: Continuous Spread and Measurement Units

Select Normal. Hold the mean at zero and change the standard deviation from 1 to 2.

The differential entropy changes from approximately 1.418939 to 2.112086 nats: an increase of ln(2). Changing only the mean leaves this quantity unchanged. A rescaling can describe a different physical spread or merely a different measurement unit, so the number is not an absolute uncertainty score across arbitrary units.

Then select Uniform, with bounds 0 and 0.5. Its differential entropy is approximately -0.693147 nats. This is valid; it is not the entropy of a discrete coin and should not be compared with one directly.

The compact view also reports quantized entropy. That is entropy of the resulting bin labels, not the original continuous variable’s differential entropy. Keep the bin settings fixed when comparing distributions and check whether aggregated tails hide differences.

Experiment 3: Paying for a Mismatched Model

Choose Cross-entropy matrix. Keep the default bin width 1 and default center-index range so outcomes 0 and 1 occupy different bins. Select the Bernoulli row and Bernoulli column. Set the reference probability to p = 0.5 and the prediction probability to p = 0.9.

Quantity Expected result, nats
Reference entropy H(P) 0.693147
Cross-entropy H(P,Q) 1.203973
KL divergence D(P || Q) 0.510826

Here cross-entropy is reference entropy plus the mismatch penalty. Set the two probabilities equal: KL becomes zero. Reverse reference and prediction and observe that KL is generally different.

Finally, keep the reference at 0.5 but set the prediction to 1. The prediction assigns zero probability to an outcome the reference can produce, so cross-entropy and KL become infinite. In this case infinity is the mathematical result, not a failed calculation.

Practice:

Record the parameters and bin settings for one example of each:

  • Zero discrete entropy.
  • Negative differential entropy.
  • Zero KL divergence between matching quantized distributions.
  • Infinite cross-entropy caused by a zero predicted bin probability.
Check your reasoning

Bernoulli with probability zero is deterministic. Uniform on an interval of width 0.5 has differential entropy ln(0.5), which is negative. Matching Bernoulli probabilities on the same bins give zero KL. A fair Bernoulli reference compared with prediction probability one gives positive reference mass where the prediction has none, hence infinite cross-entropy. If coarse bins merge both Bernoulli outcomes, the last contrast disappears: quantization has changed what is measured.

Limits and Next Step

This is an educational numerical explorer, not a statistical inference package or a fitted model. Some calculations use numerical approximations and truncated negligible tails; extreme parameters deserve independent verification. The integration checks selected identities and examples, not every parameter combination. Changing bin width, center range, or tail aggregation changes the discrete quantities being compared.

For the underlying definitions, consult SciPy’s entropy documentation and differential-entropy documentation. Their documentation is a reference, not a runtime dependency of this lab.

Next, explore the AI for Econometricians course to connect probability models with likelihood, prediction, and neural-network objectives, or return to the Academy lesson library.