Opening your learning space
Starting the app …
Opening your learning space
Starting the app …
KL divergence measures expected information loss when q is assumed instead of the true discrete distribution p.
Free to browse · flashcards or a multiple-choice quiz · import from Essential
Formula
nats with natural logarithms; dimensionless numerical value
| Symbol | Meaning | Unit |
|---|---|---|
| True probability of outcome i | dimensionless | |
| Comparison or model probability for the same outcome | dimensionless | |
| DKL(p‖q) | Relative entropy of q with respect to p | nat |
D_{KL}(p\|q)=\sum_i p_i\ln\frac{p_i}{q_i}For discrete distributions, sum pi ln(pi/qi). It is nonnegative but asymmetric and not a metric. If pi>0 and qi=0, it diverges; terms with pi=0 are zero by continuity. Natural logs give nats; log base two gives bits. Cross-entropy and Shannon entropy relate through H(p,q)=H(p)+DKL(p‖q).
For discrete distributions, sum pi ln(pi/qi). It is nonnegative but asymmetric and not a metric. If pi>0 and qi=0, it diverges; terms with pi=0 are zero by continuity. Natural logs give nats; log base two gives bits. Cross-entropy and Shannon entropy relate through H(p,q)=H(p)+DKL(p‖q).
KL divergence measures expected information loss when q is assumed instead of the true discrete distribution p.
Defining relation
The equation states the defining relation within its stated domain.
Use the example for Kullback-Leibler divergence (relative entropy) to explain which inputs determine the requested output.
The example connects concrete inputs to its result.
KL divergence measures expected information loss when q is assumed instead of the true discrete distribution p.
The relation applies only under its stated assumptions.
Applying the relation to a different case without checking its stated assumptions.
Check the validity range before substituting values: For discrete distributions, sum pi ln(pi/qi). It is nonnegative but asymmetric and not a metric. If pi>0 and qi=0, it diverges; terms with pi=0 are zero by continuity. Natural logs.
Formula cluster
KL divergence measures expected information loss when q is assumed instead of the true discrete distribution p.
For p=(0.5,0.5) and q=(0.9,0.1), DKL=0.5ln(0.5/0.9)+0.5ln(0.5/0.1)≈0.511 nats.
Compare probability models, quantify information loss and evaluate distributional objectives in machine learning.
Here is how to work through a typical Kullback-Leibler divergence (relative entropy) (DKL(p‖q) = Σ pᵢ ln(pᵢ/qᵢ)) task step by step:
Task
Use the example for Kullback-Leibler divergence (relative entropy) to explain which inputs determine the requested output.
Solution path
The example connects concrete inputs to its result.
KL divergence measures expected information loss when q is assumed instead of the true discrete distribution p.
The relation applies only under its stated assumptions.
The relation DKL(p\|q)=\sum_i pi\ln\frac{pi}{qi} summarizes KL divergence measures expected information loss when q is assumed instead of the true discrete distribution p. Read it as a model for defined quantities, not as an automatic claim about every real situation. In the example For p=(0.5,0.5) and q=(0.9,0.1), DKL=0.5ln(0.5/0.9)+0.5ln(0.5/0.1)≈0.511 nats., symbols are connected to concrete values and the result is interpreted in context. Validity limit: For discrete distributions, sum pi ln(pi/qi). It is nonnegative but asymmetric and not a metric. If pi>0 and qi=0, it diverges; terms with pi=0 are zero by continuity. Natural logs Source: SciPy API Reference, scipy.stats.entropy (relative entropy).
First write down the requested quantity and all given values with their symbols. Substitute them into the defining relation and check unit consistency. The example For p=(0.5,0.5) and q=(0.9,0.1), DKL=0.5ln(0.5/0.9)+0.5ln(0.5/0.1)≈0.511 nats. provides a worked check: formula and result must have compatible scale and meaning; round only at the end. Validity limit: For discrete distributions, sum pi ln(pi/qi). It is nonnegative but asymmetric and not a metric. If pi>0 and qi=0, it diverges; terms with pi=0 are zero by continuity. Natural logs Source: SciPy API Reference, scipy.stats.entropy (relative entropy).
The formula applies only when quantities are defined as in the source and background. Check boundary cases, measurement conditions and whether an approximation rather than equality is intended. Substitution can be algebraically correct yet technically wrong when assumptions fail or the population or system boundary changes. Validity limit: For discrete distributions, sum pi ln(pi/qi). It is nonnegative but asymmetric and not a metric. If pi>0 and qi=0, it diverges; terms with pi=0 are zero by continuity. Natural logs Source: SciPy API Reference, scipy.stats.entropy (relative entropy).
The stated units are: nats with natural logarithms; dimensionless numerical value. Convert values to a consistent unit system before substitution; counts, percentages and dimensionless ratios are not interchangeable. The variable list states the role of each symbol. Dimensional analysis catches many errors but does not replace checking the formula's assumptions. Validity limit: For discrete distributions, sum pi ln(pi/qi). It is nonnegative but asymmetric and not a metric. If pi>0 and qi=0, it diverges; terms with pi=0 are zero by continuity. Natural logs Source: SciPy API Reference, scipy.stats.entropy (relative entropy).
Comparison helps when both quantities address the same question but emphasize different properties. Report the definition, input data, threshold or averaging with the value. The source SciPy API Reference, scipy.stats.entropy (relative entropy). supports the definition used here; other conventions can differ. Choose the measure to match the learning or analysis goal. Validity limit: For discrete distributions, sum pi ln(pi/qi). It is nonnegative but asymmetric and not a metric. If pi>0 and qi=0, it diverges; terms with pi=0 are zero by continuity. Natural logs Source: SciPy API Reference, scipy.stats.entropy (relative entropy).
Quanta exam set
Curated exam set for "Kullback-Leibler divergence (relative entropy)":
Question (front)
Which formula describes Kullback-Leibler divergence (relative entropy)?
Answer in your set
Question (front)
How do you rearrange Kullback-Leibler divergence (relative entropy) for Defining relation?
Answer in your set
Question (front)
Which common mistake happens with Kullback-Leibler divergence (relative entropy)?
Answer in your set
+ 7 more cards: units, variables, derivation, example, exam task
The formula set contains 10 cards. After importing, review them and start practicing; your ratings determine later review intervals.
This list names subject references and further reading. A page or section number appears when it is part of the reference; these are not verbatim quotations.
Create a curated FSRS exam set for DKL(p‖q) = Σ pᵢ ln(pᵢ/qᵢ): formula recall, variables, derivation, rearrangement, worked example, common mistakes and exam context.
Curated formula set · LaTeX · FSRS spaced repetition · import from Essential