Module 8. Maximum entropy, exponential models, and KL regularization
How to read this module. The main route is §§8.1–8.9. Sections 8.1–8.5 build the MaxEnt principle from the modeling problem to conditional log-linear models; §§8.6–8.9 show the same variational mechanism in softmax, energy-based models, and LLM post-training. Section 8.10 is a self-contained mathematical deepening on exponential families, their main distributions, and sufficient statistics and can be saved for a second pass.
8.1. From partial knowledge to a distribution
Until now, a distribution usually appeared in the statement of the problem. We were given and computed its entropy; given and , we evaluated KL; given a channel, we studied its capacity. The distribution itself must now become the answer.
Consider an ordinary six-sided die. We have not observed its rolls, but we know that its mean is . That is plainly insufficient to recover all six probabilities. For example, both
and
have mean . Infinitely many other distributions lie between them. The constraint cuts down the simplex but does not select a single point.
This situation appears throughout ML.
- We know empirical feature averages and want a conditional class distribution.
- A network has produced logits, and we need to turn a system of scores into probabilities.
- We have a reference policy and a reward function; we want to improve behavior without destroying everything the model learned before.
- An energy-based model can score states but still has to reconcile those scores into one normalized distribution.
In every case, part of the structure is known, while the complete probability law must still be filled in.
The maximum entropy principle (MaxEnt), formulated by Edwin Jaynes as a rule of inference from incomplete information, gives a simple answer: among the distributions satisfying the explicitly stated constraints, choose the one with largest entropy.
On a finite state space,
The substance of the principle is not the slogan “choose the most random distribution.” It is a more careful discipline:
Do not introduce distinctions among admissible states for which the problem statement provides no basis.
If a reference distribution is already available, the question changes. We should not return to uniformity; we should modify the reference only as much as the new constraints require. This gives the relative form of MaxEnt:
where is the set of distributions compatible with the known moments. If is uniform on a finite set, then
so minimum KL and ordinary MaxEnt have the same solution.

This relative formulation is especially useful in ML. The reference can be a pretrained language model, a prior distribution, an earlier policy, or a natural measure on the state space rather than an abstract uniform law.
Before deriving anything, however, three modeling choices must be named explicitly.
- State space. What counts as one elementary outcome: a success count, a binary configuration, a class, or an entire token sequence?
- Reference. Relative to which distribution or measure is departure being assessed?
- Constraints. Which averages are actually known, and why are they the relevant ones?
MaxEnt does not guess the “true distribution” beyond these choices. It does something more modest and more useful: once the model of the problem is fixed, it removes arbitrariness from the completion.
One construction will recur throughout this module:
In MaxEnt, the tilt is determined by moment constraints. In softmax, by logits and temperature. In an energy-based model, by negative energy. In a KL-regularized policy, by reward relative to a reference model. These are not four names for one theorem; they are four optimization problems whose optima are built by the same mathematical operation.
8.2. Exponential tilting and information projection
Consider a finite space and a strictly positive reference
Suppose the means of functions are known:
We solve
subject to normalization and these linear constraints.
Lagrange-multiplier derivation
The Lagrangian can be written as
At an interior solution ,
Rearranging and reading the result on the log-probability scale gives
The constraints change log probability linearly. Exponentiating yields
where
is the partition function.
That is the entire mechanism of exponential tilting. The reference retains the original relative mass of states, while amplifies or suppresses it according to the constraints. With a uniform reference,
The sign convention depends on the language of the problem. Statistics often uses a positive score ; physics introduces an energy and writes . The distribution is the same—the interpretation of the function in the exponent changes.
The partition function as a computational object
Let
Then
and
These two lines turn an elegant distributional form into a working method. To satisfy the constraints, solve
The gradient reports the current model moments, and the Hessian describes how they change with the parameters. Because the Hessian is a covariance matrix, is convex. If the features are linearly redundant, the parameter may not be unique; after redundant directions are removed, the corresponding convexity is strict.
The form should already look familiar. In softmax, becomes logsumexp; in an exponential family, it is the log-partition function; in a KL-regularized policy, it becomes a soft value of the reference policy. The same function both normalizes the distribution and stores its moments in its derivatives.
The exact KL gap
Let satisfy the constraints and have the form above. For every other feasible ,
This is the Pythagorean identity for an information projection (I-projection). Its short proof shows why the result is stronger than a stationarity condition. Since
we have
The same expression is obtained with because the two distributions have the same feature means. Therefore the difference equals .
In words: every other way of satisfying the same constraints departs from the reference by exactly an additional KL distance to the optimum. The MaxEnt solution is not merely feasible; it is the closest feasible point to the reference in this KL direction.
Why maximum entropy is not an arbitrary recipe
There is also a combinatorial way to feel the result. Under a uniform reference, the number of length- sequences with empirical distribution has order
High-entropy types are realized by more microscopic sequences. Under a general i.i.d. reference , the probability of observing type has exponential order
After conditioning on the constraints, the type with minimum KL to the reference dominates. The same information projection now appears as the most probable macroscopic configuration of a long sample.
Conditions that belong next to the formula
The main result is strong, but it is not unconditional.
- The constraints must be compatible.
- If lies on the boundary of the convex hull of the feature values, the optimum may contain zeros and some components of may diverge.
- In continuous spaces, a base measure must be chosen and must be finite.
- Inequality constraints require the Karush–Kuhn–Tucker conditions.
These qualifications do not change the mechanism. They identify when the smooth interior formula describes the optimum directly and when a limiting argument or more general convex analysis is needed.
8.3. The state space and reference measure
MaxEnt has a useful unpleasant property: it forces us to notice decisions that another model might quietly label “neutral.” Even a perfectly solved optimization problem gives a different answer when we change what counts as an elementary state.
Let be the number of successes in binary trials, and suppose only
is known. Consider two models.
Model A: the elementary state is the count
If the state space is
and the reference is uniform over the values of , MaxEnt gives
This is a truncated geometric distribution. Every count is treated as one state, regardless of how many binary configurations produce it.
Model B: the elementary state is a binary configuration
Now a state is the full vector
and the reference is uniform over all microstates. Then
The normalization factorizes, so the coordinates become independent Bernoulli variables with
Consequently,
Why do the answers differ? The count corresponds to
binary configurations. A uniform reference over microstates therefore induces on counts a measure proportional to , not a uniform one:

The difference is easy to see numerically. With and , Model A has and retains substantial mass across the full range; in particular, . Model B gives and a binomial distribution concentrated near seven; here .
Both models satisfy the same mean exactly. They answer different questions.
This is not an exotic trap confined to statistical mechanics. State-space choices appear everywhere in ML:
- whether a multilabel output is one category or a collection of binary decisions;
- whether a sequence is modeled as one object or factorized token by token;
- whether permutations of a set count as different states;
- whether the reference is uniform over classes or inherited from a pretrained model;
- whether two parameterizations of the same function count as different hypotheses.
The practical rule is therefore:
Before saying “choose the maximally uncertain distribution,” name the state space, reference, and constraints.
The issue is sharper for continuous variables. Differential entropy changes under coordinate transformations and changes of units. Relative entropy to an explicit reference measure makes the modeling assumption visible and is often the more reliable starting point.
8.4. Classical MaxEnt distributions and the AWGN channel
Once the state space is fixed, familiar distributions stop looking like an arbitrary menu from a textbook. They arise as answers to different collections of information.
Uniform distribution
On a finite set of states, if only normalization is known,
This is the same fact that appeared in Module 2 as
It now has a different reading: uniformity is not a universal prior law, but the MaxEnt answer on a finite symmetric space with no additional constraints.
Exponential distribution
On , among densities with fixed positive mean
the maximum-differential-entropy density is
The support is part of the information. On the entire real line, a mean constraint alone is insufficient: a distribution can be spread out without changing its mean, increasing differential entropy without bound.
Gaussian distribution
On , among densities with fixed mean and variance
the Gaussian has maximum differential entropy:
In nats,

This property gives an important characterization of the Gaussian: no other density with the same covariance has larger differential entropy. It does not replace the central limit theorem. Entropic forms of the CLT have their own assumptions and proofs; the sentence “the sum becomes Gaussian because entropy increases” joins distinct results too quickly.
Why Gaussian input achieves AWGN capacity
Return to the channel from Module 7:
with independent and . In bits,
The noise term is fixed, so it is the entropy of the output that must be maximized. Its variance satisfies
By the Gaussian MaxEnt property,
Subtracting
gives
Equality is attained by
because the output is then Gaussian and uses the full allowed variance.
It is tempting to compress this into “Gaussian input maximizes entropy, hence mutual information.” The correct chain is slightly longer and more informative: Gaussian input makes the output Gaussian; maximum output entropy is what maximizes mutual information when the noise is fixed.
8.5. Conditional MaxEnt and log-linear models
Before transformers, many NLP systems were built from features designed by hand: the current word begins with a capital letter, the previous tag was B-PER, the suffix is -ing, or the token appears in an organization lexicon. The task was familiar and remains relevant: turn many partial signals into a normalized conditional distribution.
Let be the empirical distribution of inputs, let be the label, and let
be features of an input–answer pair. Require the model to reproduce their empirical averages:
Among all conditional distributions satisfying these constraints, maximize conditional entropy:
The same Lagrange-multiplier argument gives a conditional log-linear model:
where
Each feature contributes additively to a logit, and the partition function turns the total score into a distribution over answers. If is produced by the last hidden layer and is a linear head, this is an ordinary softmax classifier. What changed is the origin of the features: once hand-designed, they are now usually learned by a deep network.

Maximum likelihood and moment matching
For data , the conditional log-likelihood is
Its gradient is
Read the formula before moving on. The first term counts features actually observed in the data. The second asks how often the current model expects the same features. Training closes the gap between those two descriptions of the sample.
If a finite interior maximum of the unregularized likelihood exists, zero gradient gives exact moment matching:
This is not a decorative analogy to MaxEnt. In a conditional exponential family, maximum likelihood and conditional MaxEnt are two sides of the same convex duality.
Where the exact statement ends
The scope can now be stated compactly.
- Regularization contributes its own term to the moment equation.
- Linearly dependent features can make the parameters non-identifiable even when the distribution is unique.
- On separable data, a finite MLE may fail to exist: parameter norms diverge while the likelihood approaches its supremum.
- In a deep network, logits depend nonlinearly on millions of weights. Cross-entropy training remains maximum likelihood for the conditional model, but it does not turn the whole network into one simple MaxEnt problem with explicit constraints on its internal features.
The positive result remains strong: for a log-linear head, the gradient really does compare empirical and model feature averages.
The historical NLP line
Maximum entropy classifiers used these conditional models for tagging and classification. Maximum Entropy Markov Models (MEMMs) normalized transitions locally for each state. Conditional Random Fields (CRFs) moved normalization to the entire output sequence:
Modern architectures may construct far richer features, but exponential normalization remains. The historical connection to MaxEnt is therefore substantive: the machine that produces the scores changed, while the mechanism that turns them into a conditional distribution survived.
The next step is to isolate softmax itself. Every ML engineer knows the API call, but the single line hides a complete variational problem.
8.6. Softmax as score-plus-entropy optimization
Modern ML uses softmax so often that it has almost stopped looking like an idea. It is usually introduced procedurally: a network emits logits, we exponentiate, normalize the sum to one, and obtain probabilities. That is correct, but it leaves a more interesting question unanswered: why does precisely this normalization keep reappearing in classification, generation, and policy learning?
A strong answer is: softmax is a MaxEnt solution. The sentence contains an important truth, but it must be made exact. Softmax does not maximize entropy “in general,” nor does it follow from constraints that already fix the desired probabilities. It resolves a particular conflict: we want to favor high-scoring choices, but we do not want the distribution to concentrate more strongly than those scores justify.
Let be logits, a distribution over choices, and let entropy be measured in nats:
For temperature , consider
The two terms play different roles.
- is expected score. It pulls mass toward larger logits.
- resists premature concentration. It rewards distributions that preserve uncertainty.
- is the exchange rate between the two requirements: how much expected score we are willing to trade for an additional unit of entropy.
The solution is softmax:
The optimal value is
Thus logsumexp is not an arbitrary smooth replacement for a maximum. It is the value of the optimal score–entropy trade-off.
The exact KL gap
Define
For any ,
KL is nonnegative, so the unique optimum is . More importantly, the derivation gives the exact gap:
Every departure from the softmax distribution is paid for by a KL divergence to the optimum. This is no longer a metaphor about “soft choice”; it is the complete geometry of the objective.
In what sense softmax is MaxEnt
We can now recover the strong claim without a logical substitution. Let and
Among all distributions with the same expected logit,
has maximum entropy. On this constraint set, expected score is fixed, so maximizing is equivalent to maximizing .
There are therefore two equivalent readings:
- regularized: softmax maximizes expected score plus times entropy;
- MaxEnt: softmax maximizes entropy at the expected-score level selected by .
By contrast, constraints such as
do not derive softmax: they already say and therefore encode the answer in advance. This is a useful example of a sound intuition being damaged by the wrong formalization.
Temperature as a trade-off parameter
For ,
| , nats | ||
|---|---|---|
At low temperature, one extra unit of logit matters greatly and the distribution concentrates quickly. At high temperature, the same logit gap has less influence on probability, so entropy grows.

The limiting regimes are also exact.
- As , mass concentrates on the maximizers of ; with tied maxima, the limiting softmax is uniform over them.
- As , the distribution approaches uniformity over all choices.
- Adding a constant to every logit does not change softmax.
- Multiplying logits by is equivalent to dividing temperature by .
The function
smooths the maximum:
and its gradient returns the optimal distribution:
Softmax therefore plays three roles at once: it maps scores to a distribution, solves an entropy-regularized optimization problem, and is the gradient of a smooth maximum.
Scope of the statement
Softmax is not the “only honest” way to turn scores into probabilities. It is unique as the solution to this problem, with Shannon entropy and a linear expected-score term. Replacing the regularizer changes the mapping; some alternatives, for example, produce sparse distributions with exact zeros.
There is no need to weaken the main conclusion. It is already strong:
Softmax is the exact optimum of a problem in which logits vote for choices and entropy prevents those votes from becoming a distribution more confident than the selected temperature justifies.
On a finite class set, normalization is cheap. Replace the classes by all possible images, configurations, or token sequences, and the same idea becomes an energy-based model.
8.7. Energy-based models and the partition function
Softmax is the smallest energy-based model. Set the state to , define
and normalize over classes. The result is the same softmax.
With a few thousand states, this normalization looks almost free. If a state is an image, a molecule, or an entire token sequence, summing over all becomes astronomical. The familiar final normalization step is now the central computational obstacle.
An energy-based model (EBM) defines
Here
- is the energy: lower energy means larger unnormalized probability;
- is a base density or measure;
- is the partition function.
Energy answers a local question: “How compatible is this state with the model?” The partition function forces all local answers to agree globally. is the price of turning a scoring system into a probability model.
Connection to MaxEnt
It is easy to make the attractive statement “every EBM is MaxEnt” too broad. The exact connection depends on the energy.
If
then
is an exponential family. This form arises from relative MaxEnt under moment constraints on . The features have the direct meaning of constrained macroscopic quantities and has the role of Lagrange multipliers.
If is an arbitrary deep network, the Gibbs form is still valid, but no explicit set of known MaxEnt constraints need be available. The Gibbs form is broader than the particular inferential story from which it might have been derived. That does not make a neural EBM less meaningful; it means its energy is specified by a model rather than by an interpretable list of moments.
Gradient of the log-likelihood
For one observation ,
If does not depend on ,
so
Read this as training dynamics. The first term asks the model to lower the energy of the observed example. If it were the only term, the model could lower the energy of every state and learn nothing. The second term compares the data with samples from the current model and prevents that trivial solution.
The two terms are often called the positive and negative phases:
- data pull their own energy down;
- model samples receive compensating pressure;
- learning changes the landscape separating data from alternatives, not the absolute energy level.

For a linear energy ,
After averaging over data, stationarity requires
Moment matching reappears inside maximum-likelihood training. It is the same mechanism behind classical MaxEnt models, now visible directly in the likelihood gradient.
Computational difficulty
The data term is easy to evaluate. The model expectation is not. Estimating it requires samples from or another sufficiently accurate approximation. For a complicated energy, that may be harder than evaluating the energy itself.
This is why EBM training leads to methods such as Markov-chain Monte Carlo, contrastive divergence, noise-contrastive estimation, score matching, and learned samplers. They do not change the Gibbs definition; they change how the intractable model expectation is approximated or avoided.
Score-based generative models are connected to this picture through
the score of a time-dependent noisy distribution. For a Gibbs density, the score is the spatial gradient of log density and therefore contains the energy gradient. But diffusion models usually learn scores across many noise levels rather than fit one normalized static EBM by exact likelihood. “Diffusion is MaxEnt without a partition function” is therefore an attractive but incomplete slogan.
The central EBM lesson is exact and useful enough without it: local energies define relative preference; global normalization turns them into probabilities; and the normalization term is what makes likelihood learning computationally difficult.
The next section replaces a generic state by a response from a language model and replaces negative energy by reward. The same Gibbs form then becomes the exact optimum of a KL-regularized policy problem.
8.8. A KL-regularized policy and its Gibbs optimum
Fix a context , a reference policy , a reward , and . Consider
The first term asks the policy to favor high-reward answers. The second charges for moving probability mass away from the reference. This is not merely a qualitative “stay close” instruction; it is a fully solvable variational problem.
Assuming a finite partition function and optimizing over all distributions supported by the reference policy, the optimum is
where
The formula is worth reading slowly. Reward does not replace the reference policy; it tilts it. An answer that is rare under the reference remains disadvantaged unless reward overcomes that rarity. An answer outside the support of the reference cannot receive positive probability from this forward-KL objective at all.

The exact objective gap
Take any admissible policy . From the definition of ,
Averaging under gives
Rearranging,
Thus
and the exact suboptimality of any other policy is
This is the same geometry that appeared in softmax and information projection. The optimum is not merely stationary; the objective gap is exactly a KL divergence. Three facts follow at once:
- is a global optimum, not a local one;
- on the support of the reference policy it is unique;
- the shortfall of any other policy is measured by the KL divergence to it.
This is the Gibbs variational principle, or relative MaxEnt. With a uniform reference policy it collapses into the familiar “reward plus entropy” problem. With a non-uniform reference the entropy term becomes relative: the policy is not charged for concentration as such, but for moving away from the distribution the model already knew how to produce.
A numerical example
Let the reference policy spread its mass over three answers as
Then:
The third answer started at probability , but a high reward gradually pulls mass toward it. The tilt does not forget the reference model in the process: two answers with equal reward would keep exactly the probability ratio given by .
This matters more than it may appear. The formula does not add “reference probability” to “reward”. It adds them in log space:
Reward acts as an increment to the log-probability, after which the whole system is renormalized. Additive reward differences therefore become probability ratios: this multiplicative update is the defining feature of the Gibbs tilt.
Interpreting
Only the ratio matters. Multiplying every reward by has the same effect as dividing by .
- Large makes departure from the reference expensive, so remains close to .
- Small lets reward dominate and concentrates mass near reward maximizers.
- Adding a context-dependent constant to every reward leaves unchanged because the factor cancels in normalization.
The penalized problem is the Lagrangian form of
Under the usual conditions, boundary values of the KL budget correspond to values of . The coefficient can therefore be read as a temperature, a price per unit of departure from the reference, or a Lagrange multiplier for a distributional trust region.
Connection to DPO
The Gibbs form can be rearranged to express reward through the optimal policy:
A Bradley–Terry preference model uses reward differences between two answers. The context-only term cancels:
Substituting this difference into the logistic likelihood of preferences gives the DPO loss. In this precise sense, DPO uses the analytical form of the optimal KL-regularized policy and avoids the separate sequence “fit a reward model, then run an RL loop.”
It is equally important to state what has not been proved. The formula for describes an unrestricted optimum over distributions for fixed and . A real LLM is restricted by parameterization, finite data, and optimization. PPO approximates its training objective through an RL algorithm; DPO estimates a policy from preference pairs under an additional preference model. Their final parameter vectors and even their final policies need not coincide.
The formula nevertheless removes much of the terminology fog around post-training. At the center is one operation:
Reward exponentially redistributes the mass of the reference model, while KL sets the price of that redistribution.
The same beauty reveals the vulnerability. The optimum faithfully maximizes exactly the reward we wrote down. If that reward is an imperfect proxy, the mathematics will faithfully amplify its errors as well.
8.9. Reward overoptimization and the role of KL
A familiar intuition says: the KL anchor protects against Goodhart's law. As an engineering heuristic, this is often useful—staying near the reference does restrict the region in which a reward model can be exploited. As a mathematical statement, it is too strong.
KL sees two policies: the current one and the reference. It does not see an unknown true objective and cannot test whether the reward was specified correctly. The exact question is therefore:
What is guaranteed along the Gibbs path as proxy optimization becomes stronger, and where can its connection to true quality fail?
Let
The parameter measures optimization pressure: larger values tilt the policy more strongly toward proxy reward.
A covariance identity
For any integrable function ,
Differentiate the distribution first:
Multiplying by and summing yields the covariance.
This is the central formula of the section. Exponential tilting increases not every desirable quantity, but those quantities that are positively correlated with proxy reward under the current policy. The word “current” is essential: as the policy moves, the distribution under which the covariance is measured moves as well.
Dynamics of proxy reward
Set :
Unless proxy reward is constant on the support, stronger optimization strictly increases its expectation. The optimizer does what it was asked to do. Goodhart's law begins not with optimization failing, but with optimization succeeding against the wrong measurement.
Dynamics of true quality
Now set :
As long as proxy and true reward remain positively related where the policy puts mass, true quality rises. Stronger tilting, however, selects increasingly extreme states. The tails may contain reward-model errors, rare artifacts, or strategies that receive high proxy score for the wrong reason. The covariance can then shrink, cross zero, and become negative.
This gives an exact mechanism for the familiar Goodhart curve:
- at first, the proxy helps find genuinely better answers;
- then the useful signal is exhausted;
- beyond that point, additional pressure primarily selects errors in the proxy itself.
This is not a universal theorem that true reward must first rise and then fall. That shape occurs when the covariance changes sign. The identity tells us exactly what must be checked.
In the module's numerical experiment, a rare exploit action has reference probability . The proxy scores it highly, while true reward is low. At moderate , ordinary actions improve; at large , the rare reward-model error dominates. Proxy reward keeps rising while true reward falls after reaching a maximum.

Controlled reward-model experiments have observed the same qualitative pattern: stronger optimization can continue to improve the proxy while a fixed gold evaluation deteriorates. That is an empirical result of a particular protocol, not a consequence of the abstract KL formula alone.
What KL controls
Along the same Gibbs path,
so
For a fixed proxy reward, smaller moves the policy farther from the reference. This is the exact role of the anchor: it controls distribution shift relative to the regime in which the reference model—and presumably the reward model—was better studied.
There is also an operational consequence. If , Pinsker's inequality gives
Small KL bounds the change of every bounded statistic relative to the reference. It does not determine the sign of that change. If the reference policy is poor under the true objective, closeness to it does not make the new policy good; if the reward model is already wrong nearby, KL does not detect the error.
A useful practical sentence is therefore:
KL defines a trust region in distribution space, not a certificate that the reward is correct.
Why there is no general law
Let the ideal proxy- and true-reward tilts be
Then
The first term contains , but the expectation and both partition functions also depend on . Neither linear growth nor even monotonicity follows.
A three-action counterexample makes the point. Use a uniform reference and
The two rewards disagree about the second and third actions but share the same unique maximum. As optimization pressure grows, the KL between the two tilted policies first rises and then returns toward zero: both policies eventually concentrate on the first action. The claim “the divergence grows like ” is therefore false even on three states.
Practical consequences
The mathematics does not prohibit strong optimization; it imposes measurement discipline.
- Choose relative to the scale of reward and the observed KL shift, not as a universal dimensionless constant.
- Track an independent human or gold evaluation that is not optimized by the same loop.
- Measure quality at several optimization strengths and stop before the proxy–true relationship breaks down.
- Inspect tails, rare regimes, diversity loss, and new reward-exploitation strategies rather than only mean reward.
This is where MaxEnt, EBMs, and RLHF meet. Exponential tilting is a powerful machine for redistributing probability. It faithfully amplifies the supplied signal, but it cannot distinguish a goal from an imperfect measurement of that goal. That part of the problem must be handled by proxy quality, independent evaluation, and distribution-shift control—not delegated to the partition function or the KL penalty.
8.10. Mathematical deepening: exponential families and sufficiency
This section is not required on a first pass through M8. It is best read as a self-contained second chapter inside the module: we first unpack the structure of an exponential family, then place the main discrete and continuous distributions in canonical form, and only then return to sufficiency and the Pitman–Koopman–Darmois theorem.
By now the same shape has appeared too many times to look accidental:
Repeated shape, however, does not make every statement equivalent. Three questions should be kept separate.
- Which distribution is produced by entropy optimization under constraints?
- How is a preselected parametric family organized?
- When can a sample be compressed to a fixed-dimensional statistic without losing information about the parameter?
MaxEnt answers the first question. The definition of an exponential family answers the second. Sufficiency theory and the Pitman–Koopman–Darmois theorem connect the second question to the third. The three stories share deep geometry, but none is an automatic substitute for the others.
Canonical form: what is fixed and what is learned
Let be a fixed dominating measure: counting measure in a discrete problem or, for example, Lebesgue measure for a density on . A family is exponential if its densities with respect to can be written as
Here
is the log-partition function, and the natural parameter space is
When is open, the family is called regular. This small qualification matters below: it lets us perturb the parameter locally and differentiate the log-partition function without immediately running into the boundary of the parameter space.
Each component has a separate job.
- and specify the support and base geometry. Indicators of the support, combinatorial factors such as , and other parameter-independent terms belong here.
- is the sufficient-statistic vector of one observation. The parameter-dependent part of the model sees only through this vector.
- is the natural or canonical parameter. It weights the statistics linearly on the log-density scale.
- normalizes the distribution. The same function also stores its moments and local geometry.

This decomposition can be used as an algorithm. Take the logarithm of the density, collect all parameter-dependent coefficients multiplying functions of , and place the remaining parameter-dependent term in .
The representation need not be unique
The same model may admit several representations. A linearly redundant coordinate can be added to , with a compensating change in the parameters, without changing the distribution. Exponential families are therefore described as minimal or overcomplete.
A family is minimal when there is no nonzero vector and constant such that
almost everywhere. In a minimal regular family, is strictly convex and the natural parameter is identifiable. Softmax with free logits is the familiar overcomplete example: adding the same constant to every logit leaves the distribution unchanged. A minimal categorical parameterization uses log odds.
This is not merely a notational issue. Redundancy creates null directions in the Hessian and non-unique parameters even when the resulting probability distribution is perfectly well defined.
Why stores moments
The central properties of the log-partition function are easier to derive once than to memorize. By normalization,
Differentiate with respect to component , assuming differentiation can be interchanged with integration:
Therefore
or, in vector form,
Differentiating once more gives
Thus
This is why is convex. Its gradient maps natural coordinates to mean coordinates
while its curvature measures how sensitive those means are to parameter changes.
The same mechanism appears in the score with respect to the natural parameter:
Its expectation is zero, and its covariance is
so the Hessian of the log-partition function is also the Fisher information in natural coordinates. M15 develops the geometry behind this identity.
There is another exact identity. For two members of the same exponential family,
The right-hand side is the Bregman divergence generated by , with a specific argument order. The convex geometry of the log-partition function and the KL geometry of the family are therefore one formula, not merely an analogy.
Duality with MaxEnt
Define the convex conjugate
If lies in the interior of the feasible mean-parameter space and
has a solution, then
On the other hand, maximum entropy relative to the base measure under the moment constraint is
If is normalized and defines the density of a base distribution , this objective equals ; for an unnormalized , it is better read as entropy relative to a base measure.
This is the exact meeting point between MaxEnt and exponential families: the constraints specify , the Lagrange multipliers become , and translates between the two coordinate systems. The connection is deep, but it does not imply that every arbitrarily chosen subfamily solves every MaxEnt problem.
Reading canonical form in discrete distributions
A table is less useful than a repeatable operation: expand the log probability and collect the coefficients of functions of the observation.
Bernoulli: the logit falls out of the algebra
For ,
Taking logs,
Introduce the natural parameter
Since ,
Hence
Thus
and
The logistic function is not attached from outside; it is the map from the Bernoulli natural parameter to its mean parameter.
Categorical distributions: softmax and logit redundancy
Let with class probabilities . Use class as reference and define
Then
and
This is a minimal parameterization. The usual softmax with logits uses the overcomplete form
because and represent the same distribution. The gradient of logsumexp is the probability vector, and its Hessian is the covariance matrix of the one-hot variable.
Poisson: the base measure stores the factorial
For ,
Its log probability is
Therefore
Consequently,
The equality of the Poisson mean and variance is visible directly in the first two derivatives of . The natural parameter also explains the standard log link in Poisson regression: a linear predictor may range over all real numbers while the intensity remains positive.
There is an easy overstatement to avoid. Ordinary MaxEnt on the nonnegative integers with only the constraint and counting measure as the base produces a geometric, not a Poisson, distribution. Poisson requires the relative base
Thus the statistic alone does not determine the family: support and base measure matter just as much as the moment constraint.

The binomial law is the distribution of a sum of independent Bernoulli variables:
The combinatorial factor moves into , while the natural parameter remains the success logit. The multinomial law behaves similarly, with the vector of class counts as its sufficient statistic.
Continuous families: support changes the natural domain
In a continuous model, the support must not disappear from view. It enters through the base measure or an indicator inside and determines which values of make the normalizing integral finite.
Exponential distribution
For rate ,
Set
Then
with
The natural parameter space is not all of : for , the integral over diverges. This is a simple example of why the domain is part of the model rather than an appendix.
Gamma distribution
Using shape and rate ,
Collecting the functions of gives
With ,
where
The gradient returns more than the ordinary mean:
where is the digamma function. The exponential distribution is the one-dimensional slice of the Gamma family.
This example is pedagogically important: “moment matching” in an exponential family means matching expectations of sufficient statistics. One of those statistics may be , not an ordinary power of .
Gaussian family with unknown mean and variance
Expand the square in the log density:
Thus we may choose
and
Its derivatives are
The mean coordinates are therefore the first and second moments, not and themselves. Variance is recovered as
If the variance is fixed in advance, the model becomes a one-dimensional exponential slice with sufficient statistic .
Beta and Dirichlet distributions
For ,
Its canonical components are
The mean coordinates are
The ordinary mean is important for interpretation, but the expectations of the log statistics are the quantities matched when both parameters are estimated in canonical form.
The Dirichlet distribution extends the same construction to a simplex:
This is why Beta and Dirichlet models naturally appear when the random object is a probability, proportion, or probability vector.

How these families become ML output distributions
For practice, it helps to translate canonical form into the language of a model head. For one observation, the negative log-likelihood of any family in canonical form is
and its gradient with respect to the natural parameter has the familiar form
The model again compares the predicted means of sufficient statistics with what occurred in the data. The chosen distribution determines which statistics and constraints sit behind this shared formula.
| Target type | Common distribution | A convenient network output | Typical loss |
|---|---|---|---|
| binary label | Bernoulli | natural logit | binary cross-entropy |
| class or next token | categorical | logits | multiclass cross-entropy |
| real-valued target | Gaussian | mean and sometimes variance | MSE at fixed variance or Gaussian NLL |
| event count | Poisson | Poisson NLL | |
| positive quantity | Gamma | shape and rate, or mean and variance | Gamma NLL |
| proportion in | Beta | positive | Beta NLL |
| random probability vector | Dirichlet | concentrations | Dirichlet NLL or a specialized objective |
The table does not prescribe a single parameterization. A network may emit a natural parameter directly, transform an unconstrained output through softplus, or use interpretable coordinates such as mean and variance. The essential requirement is that the transformation lands in the legal parameter space and that the loss matches the probabilistic assumption we actually intend to make.
The normalizing functions need not be memorized. The reusable skill is to expand the log density, identify the support, find the functions , collect their coefficients in , and check where the normalizing integral is finite.
I.i.d. samples and sufficient statistics
For independent observations ,
All parameter dependence passes through
By the factorization theorem, is sufficient. The actual compression depends on the family.
- Bernoulli: the number of ones .
- Categorical: the vector of class counts.
- Poisson: the total count .
- Gaussian with unknown and : .
- Gamma with unknown shape and rate: .
- Beta with unknown and : .

Sufficiency has a precise meaning: conditional on , the distribution of the original sample does not depend on . Once the statistic has been computed, the raw observations contain no further information about the parameter inside the assumed model.
The final phrase matters. Order, outliers, multimodality, or systematic dependence may be irrelevant for estimating a parameter inside the family yet remain exactly the evidence that the i.i.d. family is misspecified. A sufficient statistic compresses data relative to a specified inferential question; it is not a universally lossless representation of the dataset.
Maximum likelihood as matching mean statistics
Mean log likelihood is
where
Up to a term independent of , mean negative log likelihood is
Its gradient is
and its Hessian is
If the family is minimal and a finite interior maximum-likelihood estimate exists, then
This is the exact scope of moment matching. Here “moments” means expectations of sufficient statistics:
- Bernoulli gives ;
- Poisson gives ;
- categorical probabilities match class frequencies;
- the full Gaussian family matches empirical first and second moments;
- Beta and Gamma estimates match averages involving logarithms and are usually obtained numerically.
When no finite solution exists
Convex form does not guarantee that the optimum lies at a finite point of the natural parameter space.
- If every Bernoulli observation is one, the MLE has , while .
- If a class never appears in a categorical sample, its estimated probability lies on the boundary and the corresponding minimal log odds tend to .
- Under linear separability, unregularized conditional logistic regression may have no finite MLE.
- Regularization changes the stationarity condition, so exact empirical/model moment matching is offset by the penalty gradient.
- In a curved exponential family, where is constrained to a lower-dimensional nonlinear manifold, all coordinates of need not be matched independently.
These cases do not refute the geometry. They distinguish existence of a probability distribution, existence of a finite natural parameter, and existence of an interior MLE.
The Pitman–Koopman–Darmois theorem
So far we moved from exponential form to a sufficient statistic. Under standard regularity conditions, the Pitman–Koopman–Darmois theorem moves in the reverse direction:
For a regular dominated i.i.d. family with common parameter-independent support, the existence of a sufficient statistic whose dimension remains bounded as grows severely restricts the model and leads to finite-dimensional exponential form.
This is a structural theorem, not a model-selection recipe. Its assumptions do real work.
For example,
has the one-dimensional sufficient statistic
but its support depends on the parameter. The standard PKD theorem therefore does not apply.
Other nonregular cases—parameter-dependent support, degeneracy, some discrete settings, or failures of smoothness—also require a more careful formulation. The correct lesson is not that “any sufficient statistic proves exponentiality,” but that in a regular i.i.d. problem, compressing every sample size to a fixed number of coordinates is an exceptionally strong property.
Three connections, not one theorem

We can now assemble the picture without collapsing distinct statements.
- MaxEnt / information projection. Optimizing over all distributions under constraints on means of produces an exponential tilt of the base.
- Exponential family. A parametric class is specified in advance as ; maps natural parameters to means and determines the class's KL geometry.
- Sufficiency / PKD. For an i.i.d. sample, is sufficient, while under regularity the existence of a fixed-dimensional sufficient statistic is tightly connected to exponential form.
The same statistic genuinely plays a central role in all three stories. That is why the connection is so productive in ML: it unifies probabilistic output heads, convex losses, statistic matching, and compact data summaries for parameter estimation.
The boundaries matter as well. MaxEnt does not prove PKD; PKD does not say that every convenient ML distribution was selected by maximum entropy; and an exponential-family output head does not make an entire deep network an exponential family in its weights.
The reusable skill after this section is simple:
Do not memorize the exponential family as a list of distributions. Learn to read a log density: support and base, sufficient statistics, natural parameters, log-partition function, and the domain on which it is finite.
8.12. Conclusion
We began in a setting where a few known averages were insufficient to recover a distribution. MaxEnt did not supply missing facts or guess a hidden truth. It did something more modest and more useful: among distributions genuinely compatible with the constraints, it selected the one closest to a reference.
The central construction of the module is
The meanings of the two components changed across sections:
| Problem | Reference | Tilt |
|---|---|---|
| MaxEnt with moments | base measure or uniform reference | |
| softmax | uniform reference over choices | |
| energy-based model | base measure | |
| KL-regularized policy |
This table explains the unity of the module better than any slogan. Constraints, scores, energies, and rewards enter log probability additively; exponentiation redistributes mass multiplicatively; the partition function reconciles local preferences into one distribution.
Shared algebra does not erase the differences among problems. In MaxEnt we optimize over distributions under specified moments. In an EBM, energy may be an arbitrary neural network with no explicit system of physical constraints. In DPO, the analytical Gibbs form enters the derivation of the loss, while a real policy remains restricted by parameterization and data. KL keeps a distribution near a reference but does not verify that the reward is true.
That is the balance needed in later modules: see the common construction clearly enough to transfer intuition, while retaining the conditions that keep the transfer from becoming a metaphor.
Module 9 changes the object of optimization. Instead of asking “which distribution should we choose?”, we ask “which representation should we preserve?” Information Bottleneck, rate–distortion, and variational autoencoders again turn learning into a trade-off—this time between retained information and the cost of representing it.
Primary sources
- E. T. Jaynes, Information Theory and Statistical Mechanics, 1957, and Part II, Physical Review 108, 171.
- A. Berger, S. Della Pietra, and V. Della Pietra, A Maximum Entropy Approach to Natural Language Processing, 1996.
- J. Lafferty, A. McCallum, and F. Pereira, Conditional Random Fields: Probabilistic Models for Segmenting and Labeling Sequence Data, ICML 2001.
- M. Wainwright and M. Jordan, Graphical Models, Exponential Families, and Variational Inference, 2008.
- Y. LeCun et al., A Tutorial on Energy-Based Learning, 2006.
- Y. Song et al., Score-Based Generative Modeling through Stochastic Differential Equations, 2021.
- J. Schulman et al., Proximal Policy Optimization Algorithms, 2017.
- R. Rafailov et al., Direct Preference Optimization: Your Language Model Is Secretly a Reward Model, 2023.
- L. Gao, J. Schulman, and J. Hilton, Scaling Laws for Reward Model Overoptimization, 2022.
- Y. Polyanskiy and Y. Wu, Information Theory: From Coding to Learning, 2025, sections on exponential families and information projection.
- L. D. Brown, Fundamentals of Statistical Exponential Families, 1986.