Maximum Likelihood and Cross-Entropy
A mathematical textbook connecting likelihood, entropy, KL divergence, statistical estimation, and probabilistic machine learning, with worked examples and solved exercises.
The central idea. Maximum-likelihood estimation chooses a model that makes the observed data as plausible as possible. Cross-entropy measures its average logarithmic prediction loss. For independent observations, these are the same optimization problem. At the population level, the excess cross-entropy above an irreducible baseline is a Kullback–Leibler divergence.
This textbook assumes undergraduate probability, derivatives, gradients, matrices, and basic integration. Expectations, convergence, and asymptotic normality are explained where they enter, but this is not a first course in probability. Work through the finite examples before the asymptotic theory. All logarithms are natural unless a base is explicitly given; losses are in nats. Divide by to convert nats to bits.
Learning route. Read Sections 1–4 for likelihood and estimation, 5–7 for the information-theoretic connection, 8–10 for classification and implementation, and 11–12 for statistical guarantees and limitations. Section 13 is a reference sheet. Sections 14–15 contain exercises and complete solutions.
1 Models, data, and the direction of inference
1.1 A statistical model is a family of distributions
Let be an observation with unknown distribution . A parametric model is a family , where is the parameter space. Write for a probability mass function or a density relative to a fixed dominating measure .
For discrete observations, can be counting measure and is a probability. For continuous observations, can be Lebesgue measure and is a density: probabilities are integrals of it. A density may exceed one. The probability of a single specified real-valued outcome is usually zero; this does not make continuous-data inference impossible.
We first observe independent, identically distributed data from , with . If for some parameter, the model is correctly specified. Otherwise it is misspecified: every model distribution is an approximation.
| Symbol | Meaning |
| An observed value; fixed during fitting. | |
| A candidate parameter; varied during fitting. | |
| The model’s mass or density at . | |
| The unknown data-generating distribution. | |
| An estimator: a function of the sample. | |
| A candidate predictive distribution on a finite alphabet. |
An estimator is random before sampling because its input data are random. After a sample is observed, its computed value is an estimate. Keep those two perspectives separate when interpreting uncertainty statements.
1.2 Likelihood is not a posterior
The joint model density of the observed sample, viewed as a function of the parameter, is the likelihood:
Hold fixed and vary . A likelihood need not integrate to one over ; it is not a probability distribution over parameters. Bayesian inference instead uses a prior density and forms
MLE needs no prior. A maximum a posteriori estimate maximizes the posterior, not just the likelihood. Those optimizers coincide under a constant prior on the relevant parameter space, when such a prior and maxima are meaningful.
Why independence matters. The product above follows from the i.i.d. assumption. For dependent observations the general factorization is
One may still maximize this joint likelihood, but replacing its conditional factors with marginals is a different model, not a harmless algebraic step.
2 From a likelihood to an optimization problem
2.1 Products become sums
The maximum-likelihood estimator is any maximizer
Because the logarithm is strictly increasing, maximizing a positive likelihood is equivalent to maximizing the log-likelihood
Use as an extended-real convention. A candidate assigning zero mass or density to an observed value has zero likelihood and infinite negative log-likelihood.
Define total negative log-likelihood (NLL) and average NLL by
Multiplication by the positive constant does not change the optimizer:
The values are different, however. An average loss is comparable across sample sizes; a total loss scales with . If a penalty is added, its scaling must be adjusted too.
2.2 Which constants may be dropped?
If , a term independent of every fitted parameter can be omitted when finding the maximizer. It cannot necessarily be omitted when reporting a likelihood value or comparing likelihoods from different observation models.
For example, the Gaussian normalization includes . It is a constant if the variance is known, but not if the variance is being fitted. Parameter-dependent support indicators must also be retained.
2.3 An optimizer need not exist or be unique
The notation does not prove existence. A continuous function on a compact parameter space attains a finite maximum if it is finite there; open or unbounded spaces need not have this property. Distinct parameters may also induce the same distribution. Identifiability means implies ; without it, a unique distribution need not correspond to a unique parameter.
A zero gradient is only a candidate for an interior optimum. Check the parameter space, boundaries, curvature, and whether the likelihood can grow without bound. These checks are part of MLE, not optional finishing touches.
3 Worked example: Bernoulli and categorical MLE
3.1 A coin with unknown probability
Let , with and . If successes are observed, then
These formulas describe the particular ordered sequence. If the observation were only the count , its binomial mass would include . That factor is independent of , so both experiments give the same MLE.
For , differentiation on gives
Strict concavity makes the stationary point the unique global maximizer:
If , the maximum on is at zero. If , it is at one. On the open space , these two samples have a supremum but no MLE. A derivative calculation alone would miss this distinction.
3.2 A complete numerical fit
Suppose ten flips give seven heads and three tails. The fitted success probability is .
| Sequence likelihood | Average NLL | |
All sequence probabilities are small. Their absolute smallness is not a failure: any particular long sequence can be unlikely. The MLE compares candidates for the same observed sample. Predicting 0.9 after observing mostly heads overstates confidence and is penalized by the three tails.
3.3 More than two outcomes
For classes, let belong to the probability simplex: and . If class occurs times, the ordered-data log-likelihood is
When all counts are positive, introduce a Lagrange multiplier:
Stationarity gives . Summing the implied yields , hence
If a class is unobserved, the maximum over the closed simplex assigns it zero probability. Assigning mass to an unobserved class would leave less mass for the observed classes and reduce their likelihood. A strictly positive softmax parameterization can approach this boundary but cannot attain it with finite logits.
MLE does not automatically smooth. A zero empirical count can produce a zero fitted probability. Priors or other regularization can change this, but doing so changes the estimation rule.
4 Worked example: Gaussian MLE and squared error
4.1 Estimating mean and variance
Assume are i.i.d. normal with mean and variance :
The log-likelihood is
For fixed , maximizing over minimizes the sum of squares:
Let . Substituting the fitted mean gives
If , the maximum is
This is not the usual unbiased estimator . Indeed, , so the MLE has expectation . MLE optimizes likelihood; unbiasedness is a different criterion.
If all data values coincide, . Taking equal to their common value and down to zero sends the likelihood to infinity. There is no MLE with . This includes any sample of size one when both parameters are free.
Numerical example. For , and , so . The unbiased variance estimate is .
4.2 Regression is a likelihood model too
Suppose the responses satisfy
conditionally independently, with known common variance . Conditional NLL is
Thus least squares is Gaussian conditional MLE under these assumptions. With known unequal variances , the squared residuals instead carry weights . With a fitted variance, the normalization must remain. Absolute-error loss corresponds to a Laplace error model with fixed scale, not to the same Gaussian likelihood.
5 Entropy, cross-entropy, and KL divergence
5.1 Surprise and entropy
For a finite alphabet, an event predicted with probability incurs logarithmic loss, or surprise, . An outcome assigned probability one incurs zero loss; a possible outcome assigned zero probability incurs infinite loss. Independent events have additive surprise because .
If the true probabilities are , the expected surprise under a model is the cross-entropy
The entropy is the self-prediction baseline
Use and interpret a term with as zero, even if . If but , cross-entropy is infinite.
Entropy measures uncertainty in the source distribution. Cross-entropy also depends on the model. Calling them interchangeable hides exactly the quantity that fitting can improve.
5.2 KL divergence is the excess cross-entropy
The Kullback–Leibler divergence from to is
If is positive on the support of , simple algebra gives
It remains true with infinite cross-entropy under the conventions above. The first term does not depend on , so minimizing cross-entropy over a model family minimizes the forward divergence .
Gibbs’ inequality, proved. The inequality for follows by minimizing at . Therefore
Hence . Equality requires on the support of and no extra mass outside it, so . If vanishes at a positive-probability outcome, the divergence is infinite and the inequality is immediate.
KL divergence is not a distance: it is generally asymmetric and does not satisfy the triangle inequality. The order matters. Likelihood fitting corresponds to , not its reversal.
5.3 A worked three-class calculation
Take and a model . Then
The extra loss comes from probability mismatch, not additional randomness in the source. Both distributions select class 1 by their largest probability, so a class-decision metric alone does not reveal this mismatch.
5.4 Coding intuition and its limits
With base-two logarithms, ideal code lengths have the form . A code designed for uses expected ideal length when the source is , with excess . Individual prefix-code lengths must be integers and obey coding constraints, so cross-entropy need not equal the exact expected length of a particular one-symbol code. Block or arithmetic coding makes the ideal-rate interpretation useful.
6 The exact bridge from MLE to cross-entropy
6.1 Empirical distributions turn sample sums into expectations
For categorical data, define the empirical distribution . Then
Consequently
The data-dependent entropy is fixed during optimization. The unrestricted categorical MLE sets and makes the divergence zero.
This is an exact finite-sample identity, not a large-sample approximation. The approximation enters when we replace the unknown population distribution by its empirical counterpart.
6.2 Population risk and the best model in a restricted family
Define the population logarithmic risk
For a finite alphabet, write the true mass function as . Then
If the true distribution belongs to an identifiable model, the unique risk minimizer is . If it does not, a minimizer is a pseudo-true parameter: the model’s best forward-KL approximation, assuming a minimizer exists. It need not reproduce every property of .
Restricted-model example. Suppose the three-class model is and the true distribution is . Its population cross-entropy is
Differentiation gives , hence the best model is . It matches the first class and the combined mass of the other two, but cannot distinguish their frequencies. Its risk is about , leaving KL divergence about .
The sample objective estimates ; it is not identical to it. A flexible model can reduce training NLL without reducing risk on fresh data.
7 Continuous observations require care
7.1 Differential entropy is not discrete entropy
If has density relative to the same measure as , define, when the integrals are finite,
Then
In settings where an entropy is infinite, do not subtract infinities to justify the identity. Work directly with well-defined expectations or likelihood ratios and verify integrability.
Differential entropy can be negative. For a uniform density on , , which is negative for . Density values and differential entropy depend on coordinates and units. Under a smooth bijection with nonzero Jacobian determinant, the change-of-variables formula gives
If is independent of , the additional term is the same for all candidates, so the MLE is unchanged. KL divergence is invariant when both distributions undergo the same bijective transformation, subject to the usual measure-theoretic definitions.
7.2 Why empirical continuous-data NLL is not an empirical KL
The empirical probability measure puts mass at each observation (counting repeated values with their multiplicities). A continuous model assigns zero probability to this finite set. Therefore the empirical measure is not absolutely continuous with respect to that model, and .
Nevertheless
is a perfectly useful empirical density log-loss. It estimates the population cross-entropy under integrability assumptions. Do not claim that it equals a finite empirical KL plus an empirical differential entropy. That finite-discrete derivation does not transfer to atomic empirical data and continuous model measures.
8 Conditional likelihood and binary cross-entropy
8.1 Predicting a label given features
For pairs , a discriminative model specifies . Conditionally independent labels give
When the feature distribution has no fitted dependence, its factor can be omitted from a joint likelihood for fitting . We are modeling responses conditional on features, not asserting that features are random noise that can always be ignored.
For binary labels , let . The Bernoulli conditional mass is
Its negative log is the binary cross-entropy (BCE):
For a hard label 1 it is ; for a hard label 0 it is . Both terms are needed for the distribution, even though one vanishes for each hard-labeled observation.
8.2 Soft targets and the optimal probability
Let . Conditional expected loss at a fixed is
For ,
The unique minimum is . The analogous minima for and are at the respective boundaries. Log loss is thus a strictly proper scoring rule: in expectation, reporting the true distribution is optimal.
A soft label can represent an actual conditional class distribution or a chosen training target. Applying BCE to it computes an expected Bernoulli log-loss. A fractional target is not a single observed Bernoulli outcome; its interpretation matters.
For general classes, conditional population cross-entropy decomposes as
Here is finite-valued and expectations use the true feature distribution. The baseline is label uncertainty remaining after observing .
8.3 Logistic regression: gradient and curvature
Let a logit be , with
Using and the chain rule,
Absorb the intercept into an augmented feature vector . The Hessian for all coefficients is
For any vector , its quadratic form is a sum of nonnegative squares, so logistic NLL is convex in these coefficients. It is strictly convex at finite coefficients if the augmented design has full column rank. Convexity does not imply a finite minimizer exists; separation is a counterexample. A neural network’s logits are nonlinear functions of its weights, so the same convexity conclusion does not generally hold for all network weights.
9 Multiclass cross-entropy and softmax
9.1 One categorical outcome per example
For mutually exclusive classes, let if observation belongs to class , and zero otherwise. A probability vector yields loss
where is the observed class index. This is categorical NLL and cross-entropy between a one-hot target and the predicted distribution. Its target entropy is zero. The entropy of an aggregate class-frequency distribution need not be zero: these are different distributions.
With soft targets summing to one, the loss becomes . A uniform prediction has loss for any such target, providing a useful numerical reference, not a universal performance threshold for every dataset.
9.2 Softmax converts logits into a probability vector
For logits , define
The loss for one observation with target is
Differentiating log-sum-exp gives
For any , the quadratic form equals , a variance and hence nonnegative. The loss is convex in logits. Adding the same constant to every logit leaves unchanged, so logits are not identifiable without a constraint, such as setting one reference logit to zero.
Numerical example. Logits give probabilities . If class 2 is observed, the loss is and the logit gradient is . Its components sum to zero, consistent with invariance to a common logit shift.
9.3 Binary, multiclass, and multilabel are distinct
- Binary: one Bernoulli outcome; use one logit and BCE.
- Multiclass: exactly one of classes; use categorical NLL, often with softmax probabilities summing to one.
- Multilabel: several labels may simultaneously be present; a common model uses one Bernoulli probability per label and sums BCE terms. This models labels as conditionally independent given the features. Their probabilities need not sum to one.
A two-class softmax is equivalent to a single sigmoid with logit equal to the difference of the two logits. Multiple independent sigmoids are not a replacement for a single categorical distribution over exclusive classes.
10 Computing and interpreting log loss correctly
10.1 Stable formulas use logits directly
A naive implementation can overflow by computing , or round a probability to zero or one before taking a logarithm. Use algebraically equivalent logit formulas instead. For finite binary logit and target ,
The last expression avoids exponentiating a large positive number. Implement the final logarithm with a dedicated log1p operation. For multiclass logits, let :
At least one shifted exponent is one and none exceeds one. Fused cross-entropy-with-logits routines implement these stable transformations; check whether an API expects logits, probabilities, hard class indices, or soft targets. Applying softmax twice is not the same objective.
Extreme-logit check. A binary positive label with has loss approximately and derivative approximately , not an undefined logarithm. With , its loss is effectively zero at ordinary floating precision. Reversing the label reverses which prediction is badly wrong.
Clipping probabilities changes the objective and can flatten or distort its gradients. It may be a deliberate policy when evaluating externally supplied probabilities, but it is not equivalent to stable evaluation of the original logit loss.
10.2 Accuracy and log loss answer different questions
Suppose the true binary frequency is . Predictors always reporting and make the same class decision at threshold , so both have expected accuracy . Their expected log losses differ:
The second is overconfident. Accuracy ignores the reported confidence until it crosses the decision threshold; log loss evaluates the full probability. Good average log loss also does not, by itself, prove calibration in every subgroup or good performance under distribution shift.
10.3 Class weights and label smoothing change the target
For binary class weights , conditional expected weighted loss is
Its optimum is
Unless the weights are equal or a boundary case applies, this is not the original class probability . Class weighting can serve a cost-sensitive or resampling objective, but the resulting raw probabilities need not be calibrated to the original population.
For label smoothing, replacing target by , with a chosen reference distribution , optimizes cross-entropy to that modified target. It is not ordinary MLE of the unchanged hard labels. Be explicit about the goal being optimized.
10.4 Penalties, MAP, and normalization
If a prior has density , a MAP estimate minimizes
In average-loss form the same objective is . Using instead corresponds to a total penalty . A Gaussian prior produces a quadratic penalty, with coefficients determined by its variance. Regularization can make an otherwise nonexistent unpenalized estimate finite, but it changes the estimator.
MLE is equivariant under a one-to-one reparameterization: transform a maximizer to obtain a maximizer in the new coordinate. A MAP density mode is generally not invariant, because transforming a density introduces a Jacobian. Neither statement licenses dropping a parameter-dependent factor.
11 Why MLE works: consistency and asymptotic inference
11.1 Consistency is an argmin argument
For each fixed , the law of large numbers suggests when the log loss is integrable. Pointwise convergence alone is not enough to move a minimizer through a limit: a sample-dependent optimizer can chase narrow random dips.
Here is one useful, deliberately sufficient formulation. Suppose:
- The observations are i.i.d.; is compact.
- For almost every , is finite and continuous, and its absolute value is bounded uniformly over by an integrable envelope. Assume the measurability needed for the suprema.
- The continuous risk has a unique minimizer .
- is a measurable exact minimizer, or an approximate minimizer satisfying , with in probability.
Compactness, continuity, and the envelope give a uniform law of large numbers:
For any fixed , compactness and uniqueness give a positive gap
when the set is nonempty. On the other hand, approximate optimality implies
With probability tending to one, this is smaller than , so . Thus in probability: consistency.
For a correctly specified, identifiable model with the required finite risks, the KL identity identifies with . Under misspecification, the same argument targets the pseudo-true minimizer. These assumptions are sufficient, not necessary: normal mean estimation on an unbounded space is consistent too, but requires a different compactness or tightness argument. Boundary probabilities and parameter-dependent supports can violate the displayed assumptions.
11.2 Score and Fisher information
For one observation, define the score and observed log-likelihood curvature at parameter :
Assume a common support and enough domination to differentiate integrals. Under the model ,
Differentiating normalization once more yields the information identity
This is per-observation Fisher information; independent observations have information . The identity can fail when support depends on the parameter or differentiation under the integral is invalid.
For Bernoulli ,
Therefore the asymptotic variance of the sample proportion is , consistent with its exact variance.
11.3 The local normal approximation
In a correctly specified, identifiable, fixed-dimensional model, suppose is interior, the MLE is consistent, the likelihood is sufficiently smooth with valid differentiation and local Hessian convergence, and is finite and nonsingular. A Taylor expansion of the score at an interior MLE gives, to first order,
Consequently
The multivariate central limit theorem gives
The arrow denotes convergence in distribution. Approximate standard errors are square roots of diagonal entries of , or of a suitable observed-information inverse. This is a local, large-sample result, not a guarantee for small samples or boundary estimates.
For seven successes in ten trials, the plug-in Bernoulli standard error is . A naive 95% Wald interval is about . Ten observations are a small sample; the approximation can be poor, and at all-success or all-failure samples it degenerates. Score intervals, such as Wilson’s interval, or exact binomial procedures avoid that particular plug-in pathology.
11.4 Misspecification needs a sandwich covariance
At an interior pseudo-true parameter, put
If the score has mean zero there and the corresponding consistency, smoothness, moment, central-limit, and nonsingularity conditions hold,
The information identity generally does not equate and under the true misspecified distribution. The middle matrix is not optional. Empirical averages of fitted scores and Hessians estimate these matrices in the i.i.d. setting; dependent data require an appropriate covariance of the score sum, not automatically this independent-observation formula.
12 Failure modes that test the assumptions
12.1 Separation: perfect classification without a finite MLE
Absorb the binary intercept into and the features. Suppose there is a vector with
This is complete linear separation. Set and increase . Every observed-class probability tends to one, so every NLL term tends to zero. At finite coefficients all sigmoid probabilities lie strictly between zero and one, so the loss is positive. Its infimum zero is not attained.
The classifier may already have perfect training accuracy while its weight norm keeps growing. That is not proof of a finite unregularized MLE. An penalty on all coefficients makes the objective coercive and strictly convex, producing a unique finite minimizer; leaving an intercept unpenalized can preserve exceptional nonexistence cases.
12.2 Parameter-dependent support: uniform estimation
Let be i.i.d. uniform on , with . If , the full likelihood is
It decreases for and is zero below , so the MLE is . Differentiating only and searching for a zero score would fail. The maximum lies at the support constraint.
The usual regular normal limit fails too. Under a true endpoint , for fixed and sufficiently large ,
Thus the scaled endpoint error has an exponential limit at rate , not a normal limit at rate . Regularity assumptions carry mathematical content; they are not ceremonial qualifications.
12.3 Training fit does not establish predictive quality
Empirical NLL measures fit to the data used in its average. Evaluating probabilities on independent validation or test observations estimates predictive log loss without reusing those observations for fitting. Repeated model selection on a test set makes it part of the fitting process.
Model misspecification, small samples, dependent data, changing populations, and optimization error are different problems. More training iterations address only some optimization error; they do not automatically fix any of the statistical problems. Likewise, a convex objective does not make an incorrect data model true.
13 Reference sheet: the equivalences and their limits
| Object | Formula and interpretation |
| Likelihood | for i.i.d. data. |
| Log-likelihood | . Maximize it. |
| Average NLL | . Minimize it. |
| Discrete entropy | . A fixed-source baseline. |
| Cross-entropy | . Expected model log loss. |
| Forward KL | . |
| Binary loss | . Bernoulli NLL. |
| Multiclass loss | for observed class . Categorical NLL. |
| Gaussian regression | Fixed-variance NLL equals a positive multiple of squared error plus a parameter-independent constant. |
Before using an equivalence, ask:
- What is random, what is conditioned on, and what parameter is fitted?
- Are these probabilities or densities relative to a fixed measure?
- Does the factorization follow from the stated dependence assumptions?
- Which quantities are constant with respect to all fitted parameters?
- Is the target empirical or population, hard-labeled or deliberately modified?
- Does an optimizer exist in the actual parameter space?
- Do the regularity assumptions justify any uncertainty approximation?
The shortest reliable chain is
For finite discrete outcomes this is empirical cross-entropy minimization. At the population level, under finite-entropy conditions, it is forward-KL minimization plus a constant. The qualifiers distinguish a theorem from a slogan.
14 Exercises
Try these before reading the solutions. Give the parameter space as part of every MLE answer.
- Bernoulli boundaries. Derive the MLE after four successes and one failure. What changes after five successes and no failures on versus ? Compute the minimum average NLL for the first sample.
- A categorical zero. Counts are . Find the unrestricted categorical MLE and its training cross-entropy. Can finite softmax logits represent that MLE exactly?
- Poisson estimation. For , assume with (including the degenerate distribution at zero). Derive the MLE and evaluate it for . Handle an all-zero sample.
- Known and unknown Gaussian means. For , compute the variance MLE when the mean is known to be zero. Compare with the result when the mean is fitted. Why can the normalization not be discarded?
- KL asymmetry. For and , calculate and . Explain which appears when the data come from and the predictor is .
- One logistic update. Let , , no separate intercept, and initial . Compute the single-example loss, gradient, and one gradient-descent step with learning rate .
- Class weighting. A feature group has true positive rate . Positive examples have weight four and negative examples weight one. Find the probability minimizing weighted BCE. Is it the original positive rate? Derive the formula that recovers from the weighted optimum.
- Logits and shifting. For class-1 target and logits , compute a stable expression for the loss and its approximate value. Explain why subtracting 1000 from all logits changes nothing.
- Misspecified Gaussian uncertainty. Fit a normal mean with fixed model variance to i.i.d. observations with true mean and finite true variance , not necessarily Gaussian. Find the pseudo-true mean, , , and the asymptotic variance of the fitted mean.
- Nonregular endpoint. For i.i.d. uniform observations, derive , , and a bias-corrected estimator from the sample maximum. Is that correction still the MLE?
15 Solutions
15.1 Bernoulli boundaries
The sample has , , so . Strict concavity of the log-likelihood on proves uniqueness. The minimum average NLL is
For five successes, . On the MLE is one. On there is no maximizer: the supremum is approached as tends to one from below. The limiting average NLL is zero.
15.2 A categorical zero
The MLE is and the training cross-entropy is . The fourth term contributes zero, not an undefined product. Finite softmax logits give strictly positive probabilities in every class. One can approach this distribution by sending the fourth relative logit to negative infinity, but cannot represent it exactly with finite logits.
15.3 Poisson estimation
Writing , for ,
If , the derivative vanishes at and the second derivative is negative. The sample sum is and the sample size is , giving . The factorial terms may be dropped for optimization because they do not involve .
If , every observation is zero. The likelihood is , maximized at in the stated closed parameter space. If the model required , that sample would have no MLE.
15.4 Known and unknown Gaussian means
With known mean zero, maximize over to get . With a fitted mean, and . The known-mean estimator measures squared deviations from zero, not from the sample mean. The term penalizes spreading the density too widely. Without it, the retained residual term would favor tending to infinity rather than the correct finite optimum.
15.5 KL asymmetry
Direct substitution gives
Data drawn from weight the loss contributions by , so the excess expected log loss is . Reversing the arguments changes the averaging distribution and answers a different question.
15.6 One logistic update
The initial logit is zero and . The loss is . The gradient is
A descent step gives . The new logit for this example is , so its positive-class probability is , and its loss falls to about . This demonstrates the update direction; it is not a proof that an arbitrary learning rate decreases every dataset’s loss.
15.7 Class weighting
With , , and ,
That is not the original rate . Solving the general optimum formula for gives
This inversion applies when the predicted value really is the corresponding weighted conditional optimum and the weighting scheme is known; it is not a universal calibration guarantee for an imperfect fitted model.
15.8 Logits and shifting
The maximum logit is . Stable log-sum-exp yields
Subtracting a common constant multiplies numerator and denominator of softmax by the same factor. It cancels in probabilities and in the log-sum-exp-minus-target-logit expression. No large positive exponential needs to be evaluated.
15.9 Misspecified Gaussian uncertainty
The population NLL, apart from a constant, is . Since , its unique minimizer is . The score is and its negative derivative is , so
Thus converges in distribution to by the central limit theorem. The fitted mean is the sample mean, with asymptotic variance , not necessarily . The assumed model variance cannot replace the true variance without a justification such as correct specification of that variance.
15.10 Nonregular endpoint
For , independence gives
Its density on that interval is . Therefore
The estimator is unbiased. For it is not the MLE, because it exceeds the smallest admissible endpoint , where the likelihood is largest. An unbiasedness correction changes the optimization criterion’s answer; unbiasedness and maximum likelihood are not synonyms.
16 Further reading
- George Casella and Roger L. Berger, Statistical Inference, second edition (2002): likelihood, point estimation, and large-sample methods.
- A. W. van der Vaart, Asymptotic Statistics (1998), Chapter 5: M-estimators and rigorous consistency and asymptotic-normality arguments.
- Thomas M. Cover and Joy A. Thomas, Elements of Information Theory, second edition (2006), Chapter 2: entropy, relative entropy, and information inequalities.
- Christopher M. Bishop, Pattern Recognition and Machine Learning (2006), Chapters 3–4: regression, probabilistic classification, and cross-entropy objectives.
Final takeaway. Choose a probabilistic observation model first. Its likelihood determines the log-loss; the data distribution determines the expectation; and the parameter space determines which optima exist. MLE, cross-entropy, and KL divergence then connect precisely, without erasing the distinctions that make each concept useful.