KL Divergence
KL divergence measures the extra expected log loss from using distribution when the data follow . It is central to information theory, maximum-likelihood training, variational inference, language modeling, and regularized objectives.
Defining math
For discrete distributions with absolutely continuous with respect to ,
It is nonnegative and equals zero only when on the support. It is not a distance because it is asymmetric:
in general. Cross-entropy decomposes as , and mutual information is a KL divergence between a joint distribution and the product of its marginals.
Worked example
Take and . Summing term by term,
Swapping the roles of and gives the reverse divergence,
a different value on the same pair of distributions. That asymmetry matters: fitting to cover all mass of is not the same pressure as fitting to avoid placing mass where is small.
Caveats
KL divergence becomes infinite if for an event with . Empirical estimates can be fragile in sparse categories, so smoothing and support checks are part of the modeling decision, not just implementation details for probabilistic loss functions.
References
Nav