Surprise
The topic What generative modeling is left us one quantity computable from samples alone, the average log-likelihood, and Multivariate Gaussians taught us to sample noise and compute a log-density. To fit a model distribution to a target distribution we still need a number that says how far is from . The standard first choice is the Kullback–Leibler divergence. It is built from a simpler idea: how surprised we are by an outcome.
Take two boards with ten marks each. Board A has 5 noughts and 5 crosses; board B has 9 noughts and 1 cross. Drawing an X is clearly more surprising on board B, where , than on board A, where . So surprise must grow as the probability falls.
A first guess, , ranks the boards correctly but fails on a certain event: a coin that always lands heads gives , although heads should not surprise us at all. Taking the logarithm fixes this. The surprise, or self-information, of an outcome is
It equals when and grows without bound as .
The logarithm also makes surprise additive. For independent events the probability of a sequence is a product, and the logarithm of a product is a sum, so the surprise of a sequence is the sum of the surprises of its parts.
Units. gives bits and gives nats, with bit nats. One fair binary choice carries exactly bit. The base never changes a comparison, only the unit; a plain means either, as long as one base is used throughout.