In the context of coding theory, D KL ( P ∥ ∥ Q ) can be constructed by measuring the expected number of extra bits required to code samples from P using a code optimized for Q rather than the code optimized for P.