Skip to content

style: prefer $$ \begin{aligned} … $$ over a bare align block in divergence_measures.md #885

@mmcky

Description

@mmcky

Summary

In lectures/divergence_measures.md (lines ~134–140) the KL-divergence derivation uses a bare top-level \begin{align} block:

\begin{align}
D_{KL}(f \parallel g) &= \sum_{i} f_i \log\left[\frac{f_i}{g_i}\right] \\
&= \sum_{i} f_i \left[\log f_i - \log g_i\right] \\
&= \sum_{i} f_i \log f_i - \sum_{i} f_i \log g_i \\
&= -H(f) + H(f,g) \\
&= H(f,g) - H(f)
\end{align}

This is not a build error — the amsmath MyST extension renders bare amsmath environments and the book builds fine. It's a minor style/consistency note: this is the only lecture in the series using a bare top-level align. The QuantEcon convention is to wrap multi-line display math in $$ with aligned (see math.md), which is also the more robust form for PDF/LaTeX output.

Suggested change

$$
\begin{aligned}
D_{KL}(f \parallel g) &= \sum_{i} f_i \log\left[\frac{f_i}{g_i}\right] \\
&= \sum_{i} f_i \left[\log f_i - \log g_i\right] \\
&= \sum_{i} f_i \log f_i - \sum_{i} f_i \log g_i \\
&= -H(f) + H(f,g) \\
&= H(f,g) - H(f)
\end{aligned}
$$

Context

Low-priority finding from the May 2026 style audit of the QuantEcon lecture series — report: https://quantecon.github.io/audit.2026-05.style-guide/ (see the divergence_measures page). Consistency only; no rush.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions