Binary cross-entropy 2026-10-14
Let follow a Bernoulli distribution with true event probability , and let the model report event probability . The binary cross-entropy is its expected logarithmic loss:For , it is minimized at , where the value is binary entropy . An individual outcome has loss when and when ; the binary cross-entropy averages those two cases using the true probabilities.
For , truthful reporting gives bits. Reporting gives one bit. Reporting givesBoth and select zero if one predicts only the more likely binary outcome. Their predicted probabilities are very different, however, and cross-entropy reveals the cost of underestimating the event that occurs a quarter of the time. Endpoint losses are computed using the realized outcome rather than multiplying zero by an undefined logarithm.
The expected logarithmic loss is minimized by reporting the true event probability
. The true Bernoulli distribution has parameter . The blue curve averages the orange event loss and gray nonevent loss with weights and . Its minimum is at , while both endpoint limits diverge because both outcomes have positive probability. These are calculated expectations, rather than measurements. Details. Cross-entropy 2026-10-14
Cross-entropy measures the average logarithmic loss incurred when outcomes follow one probability distribution , but a model assigns probabilities using another probability distribution . For a finite alphabet, write their probability mass functions as and . With base-two logarithms,The expectation is under the true or stipulated source law , rather than the model . Terms with contribute nothing. If but for any outcome, the cross-entropy is : the model rules out an event that can occur. The result is measured in bits; natural logarithms give nats.
The useful identity is cross-entropy equals entropy plus relative entropy:The source's information entropy is the baseline uncertainty. The Kullback-Leibler divergence is the extra average cost of a mismatched model, with the true law first and model second. Thus optimizing for a fixed reduces the mismatch, rather than changing the source's own uncertainty. For finite alphabets, the minimum is , attained exactly at .
Take a three-symbol source with . A matched binary prefix code assigns , , , with lengths . A mismatched prefix code instead assigns , , , with lengths , corresponding to . Both prefix codes decode exactly, but the most common symbol is shorter in the matched code. Under the same source ,The mismatched code costs an extra (1/4) bit per source symbol on average. No information is lost; the penalty is inefficient representation of this source. The mismatch penalty in lossless coding explains when this coding interpretation is exact.
Cross-entropy is also useful when evaluating a predictive distribution. A report that places tiny probability on the realized outcome receives a large logarithmic loss, even when it usually predicts the most common outcome correctly. The loss convention is the negative of the reward convention in the logarithmic scoring rule. Its expected loss is uniquely minimized by the correct probability distribution, making it a strictly proper scoring rule. Strictly Proper Scoring Rules, Prediction, and Estimation by Tilmann Gneiting and others treats this connection in §3.1, Example 3; its discussion uses rewards, so the signs are reversed for the losses here.[ref]
I. J. Good's Rational Decisions by I. J. Good appeared in 1952. Its published summary describes a method for encouraging accurate probability estimates and a connection with information theory. Strictly Proper Scoring Rules, Prediction, and Estimation by Tilmann Gneiting and others traces the logarithmic scoring rule at least as far back as this 1952 paper.[ref]
For finite probability mass functions, with whenever , subtract the two expectations of logarithmic loss:The Gibbs inequality makes the difference nonnegative and zero exactly when . If assigns zero probability to an outcome with positive probability under , both the cross-entropy and the Kullback-Leibler divergence are infinite. The finite information entropy still leaves the displayed identity valid in the extended sense. In more general settings, undefined differences such as cannot be used as a derivation.
Empirical cross-entropy 2026-10-14
For observations of a categorical variable, empirical cross-entropy is the average logarithmic loss under the reported probability mass function . Writing the empirical distribution as givesUnder independent and identically distributed observations from and a fixed model with positive probability for each possible outcome, the law of large numbers gives convergence to . A finite empirical distribution is an estimate of , rather than the true source law; unobserved outcomes need not be impossible. If the same data are used to choose , evaluating the resulting empirical cross-entropy on that data need not estimate its prediction performance on fresh observations without bias.
Logarithmic scoring rule Created 2026-10-07 Updated 2026-10-14
The logarithmic scoring rule rewards the natural logarithm of the reported probability mass or probability density at the observed outcome. The title uses the reward convention. For a binary report , its negative is the logarithmic loss:For this is ; for it is . At an endpoint, use these outcome-specific forms: assigning zero probability to the outcome incurs infinite loss, while assigning it probability one gives zero. The natural logarithm therefore makes a confidently wrong binary forecast far more costly than the bounded Brier score does.
Under the stipulated Bernoulli distribution with , the expected logarithmic loss isIts unique minimum is at , where the expected loss is approximately . At it is approximately . More generally, the excess expected logarithmic loss over truthful reporting is the Kullback-Leibler divergence in the order true law first, reported law second:For , this Kullback-Leibler divergence is nonnegative and vanishes only at , explaining why the logarithmic scoring rule is a strictly proper scoring rule. The same Kullback-Leibler divergence identity applies to probability density functions relative to a common measure when the truthful expected logarithmic loss is finite and the comparison expected value is well defined.[ref]
Strictly Proper Scoring Rules, Prediction, and Estimation by Tilmann Gneiting and others. Section 3.1, Example 3, and Section 4.1
For sequential forecasts, the existing prequential log score identity explains how logarithmic rewards add over observations. Relative entropy to a product law 2026-10-14
Let be a joint probability distribution on a finite product alphabet, with marginals . Compare it with a product model , assuming wherever . Adding and subtracting the logarithm of givesThe first term is the unavoidable error from discarding dependence; the other terms are errors in the individual marginal probability distributions. Averaging a term that depends only on under is the same as averaging it under , which proves the identity directly.
Among product laws, the choice minimizes this relative entropy, leaving exactly total correlation. The related cross-entropy equals entropy plus relative entropy identity interprets this as extra average logarithmic loss from using the independent model. It is a statement about a specified joint law and loss function, not a claim that fitting a finite sample automatically recovers that law.
Strictly proper scoring rule Created 2026-10-07 Updated 2026-10-14
A strictly proper scoring rule is a proper scoring rule for which the true probability distribution is the unique optimizer of the expected value. Equivalently, any different admissible probability distribution gives strictly larger expected loss. For probability density functions, two densities that agree almost everywhere represent the same probability distribution. Ordinary propriety permits ties: the constant reward is a proper scoring rule, because every report ties, but it is not a strictly proper scoring rule and elicits no information.
Strict propriety concerns expectation, not guaranteed success on each observation or each realized dataset. With the stipulated Bernoulli distribution , suppose the outcome is . The honest report then has Brier score loss , while has loss . The logarithmic loss similarly gives losses and . The honest forecast loses this comparison on that draw, which occurs with probability in the stipulated statistical model.
Individual outcomes can favor a different report even though the expected Brier score and logarithmic loss are uniquely minimized at
. Details. The loss curves favor , and the loss curves favor . Their weighted average, with weights and , favors . Choosing a report after observing would use information unavailable at forecast time. Even an average loss on a finite dataset can rank an honest forecast below a competing forecast through outcome variation; strict propriety guarantees the ranking in expected value under the specified information and true predictive distribution.


