Probabilistic Brain & Generative Models
Probability, Entropy, and Divergence: Foundational Concepts for Generative Modeling
Probability Distributions
A probability distribution is a function that maps each possible state of a system to a number between 0 and 1, reflecting the degree of belief that the state will occur. The probabilities of all possible states must sum to 1.
Two main interpretations of probability exist:
Frequentist: Probability is the long-run proportion of outcomes from repeated trials (e.g., rolling a die many times gives probability 1/6 for each face).
Bayesian: Probability is a degree of belief. This handles events that cannot be repeated, like "probability of rain tomorrow is 0.7" — it expresses 70% certainty, not a frequency.
All probability assignments must obey the law of total probability: for a set of mutually exclusive and exhaustive states, ∑iP(statei)=1.
Distributions can be:
Discrete: e.g., uniform distribution for a fair die, each outcome has probability 1/6.
Continuous: e.g., Gaussian (bell-curve) distribution for adult heights. The distribution integrates to 1 (the area under the curve equals 1). This is conceptually the same as summation if you view the continuous variable as many tiny discrete bins.
Distributions can also be multivariate. For example, states that include both height and weight occupy a 2D plane — each point corresponds to a particular combination and has a probability value. In machine learning, we often work with very high-dimensional spaces; for instance, all possible 100×100 pixel images live in a 10,000-dimensional space (one axis per pixel value). We assign a probability to every point in that space.
Sampling
Sampling is the process of generating an outcome from a probability distribution. Rolling a die gives a sample from its distribution. In generative AI, if we can draw samples from a high-dimensional distribution that captures the structure of natural images, we can generate new realistic images — unlike random independent pixel values, which always produce noise.
Sampling from a learned distribution is the core mechanism behind generative models.
Surprise
Surprise (or surprisal) quantifies how unexpected an event is. It should:
Be a positive number.
Be larger for less probable events.
Approach zero as probability approaches 1 (certain events are not surprising).
Be additive for independent events: if you predict the outcomes of three dice rolls correctly, you are about three times as surprised as for one die. Since independent probabilities multiply, surprise should add — this is achieved by using the logarithm:
This function assigns high surprise to rare events and low surprise to common ones.
Entropy
Entropy is the average surprise of a probability distribution. It measures the inherent uncertainty or randomness of that distribution. For a discrete distribution P, entropy is:
Or equivalently H(P)=−∑xP(x)logP(x).
Example: A "thick coin" lands heads 49%, tails 49%, and on its side 2%. Surprise for heads/tails: log(1/0.49)≈0.7; surprise for side: log(1/0.02)≈4. The average surprise (entropy) is:
A fair coin (50/50) has lower entropy (H=1 nit if using natural log). The thick coin has more inherent uncertainty because rare "side" outcomes increase average surprise.
Entropy depends only on the true probability distribution. In real-world scenarios, this true distribution is usually unknown and complex; we instead have an internal model — our belief about the distribution.
Cross-Entropy
Cross-entropy measures the average surprise you expect when observing outcomes from a true distribution P but using your model Q to assign probabilities. It is defined as:
Cross-entropy combines two sources of surprise:
The inherent uncertainty of P itself.
The discrepancy between Q and P.
Key property: H(P,Q)≥H(P), with equality only when Q=P. Using an imperfect model can only increase average surprise — never decrease it.
Asymmetry: Swapping P and Q gives very different results.
Example 1 (believe fair, actually rigged): True P is rigged coin (heads 99%, tails 1%); model Q is fair (50/50). Cross-entropy:
Example 2 (believe rigged, actually fair): True P is fair; model Q is rigged (heads 99%, tails 1%). Cross-entropy:
The second value is much larger because whenever tails occurs (half the time), surprise is extreme under the wrong model.
Kullback-Leibler (KL) Divergence
KL divergence measures the extra surprise caused by using model Q instead of the true distribution P — it isolates the penalty for model inaccuracy. It is defined as:
KL divergence = cross-entropy (total surprise) minus entropy (inherent surprise). It quantifies the inefficiency of using Q to approximate P.
Properties:
DKL(P∥Q)≥0 (Gibbs' inequality), with equality only when P=Q.
Not symmetric: DKL(P∥Q)=DKL(Q∥P).
KL divergence is the natural objective for learning a model Q that approximates the true data distribution P.
Application to Machine Learning
In generative modeling, the goal is to learn a probability distribution that approximates the true distribution of data (e.g., all possible cat images). We parameterize a model Qθ (e.g., a neural network) and optimize its parameters θ to make Qθ as close to P as possible.
Why minimize cross-entropy instead of KL divergence? The KL divergence objective is:
But H(P) is a constant determined only by the true data distribution — it does not depend on θ. Therefore, minimizing DKL is equivalent to minimizing H(P,Qθ) (cross-entropy). The entropy term just shifts the loss by a fixed amount. In practice, we minimize cross-entropy because it is simpler and computationally cheaper (no need to estimate the entropy of the training data).
Minimizing cross-entropy is the practical way to minimize KL divergence between model and data.
This principle underlies many machine learning algorithms, especially in generative models (e.g., variational autoencoders, diffusion models). Additional techniques like variational bounds extend this idea to cases where direct maximum likelihood is intractable, but the core remains: learning a distribution means minimizing the cross-entropy (or equivalently KL divergence) between the model and the true data distribution.
Summary: The concepts of probability distributions, surprise, entropy, cross-entropy, and KL divergence form the language of uncertainty. They allow us to quantify how well a model captures data, providing the mathematical foundation for training generative models that can create realistic new samples.

Ask anything
We've read this whole study set, so questions about it get the best answers.