# Analysis of Kullback-Leibler divergence

Let us consider the following two probability distributions

P       Q
0.01    0.002
0.02    0.004
0.03    0.006
0.04    0.008
0.05    0.01
0.06    0.012
0.07    0.014
0.08    0.016
0.64    0.928


I have have calculated Kullback-Leibler divergence which is equal $0.492820258$, I want to know in general what does this number shows me? Generally, Kullback-Leibler divergence shows me how far is one probability distribution from another, right? It is similar to entropy terminology, but in terms of numbers, what does it mean? If I have a result of result of 0.49, can I say that approximately one distribution is far from another by 50%?

The Kullback-Leibler Divergence is not a metric proper, since it is not symmetric and also, it does not satisfy the triangle inequality. So the "roles" played by the two distributions are different, and it is important to distribute these roles according to the real-world phenomenon under study.

When we write (the OP has calculated the expression using base-2 logarithms)

$$\mathbb K\left(P||Q\right) = \sum_{i}\log_2 (p_i/q_i)p_i$$

we consider the $P$ distribution to be the "target distribution" (usually considered to be the true distribution), which we approximate by using the $Q$ distribution.

Now,

$$\sum_{i}\log_2 (p_i/q_i)p_i = \sum_{i}\log_2 (p_i)p_i-\sum_{i}\log_2 (q_i)p_i = -H(P) - E_P(\ln(Q))$$

where $H(P)$ is the Shannon entropy of distribution $P$ and $-E_P(\ln(Q))$ is called the "cross-entropy of $P$ and $Q$" -also non-symmetric.

Writing

$$\mathbb K\left(P||Q\right) = H(P,Q) - H(P)$$

(here too, the order in which we write the distributions in the expression of the cross-entropy matters, since it too is not symmetric), permits us to see that KL-Divergence reflects an increase in entropy over the unavoidable entropy of distribution $P$.

So, no, KL-divergence is better not to be interpreted as a "distance measure" between distributions, but rather as a measure of entropy increase due to the use of an approximation to the true distribution rather than the true distribution itself.

So we are in Information Theory land. To hear it from the masters (Cover & Thomas) "

...if we knew the true distribution $P$ of the random variable, we could construct a code with average description length $H(P)$. If, instead, we used the code for a distribution $Q$, we would need $H(P) + \mathbb K (P||Q)$ bits on the average to describe the random variable.

The same wise people say

...it is not a true distance between distributions since it is not symmetric and does not satisfy the triangle inequality. Nonetheless, it is often useful to think of relative entropy as a “distance” between distributions.

But this latter approach is useful mainly when one attempts to minimize KL-divergence in order to optimize some estimation procedure. For the interpretation of its numerical value per se, it is not useful, and one should prefer the "entropy increase" approach.

For the specific distributions of the question (always using base-2 logarithms)

$$\mathbb K\left(P||Q\right) = 0.49282,\;\;\;\; H(P) = 1.9486$$

In other words, you need 25% more bits to describe the situation if you are going to use $Q$ while the true distribution is $P$. This means longer code lines, more time to write them, more memory, more time to read them, higher probability of mistakes etc... it is no accident that Cover & Thomas say that KL-Divergence (or "relative entropy") "measures the inefficiency caused by the approximation."

• Extremely useful and informative answer. Nov 27, 2018 at 14:43

Consider an information source with distribution $P$ that is encoded using the ideal code for an information source with distribution $Q$. The extra encoding cost above the minimum encoding cost that would have been attained by using the ideal code for $P$ is the KL divergence.

KL Divergence measures the information loss required to represent a symbol from P using symbols from Q. If you got a value of 0.49 that means that on average you can encode two symbols from P with the two corresponding symbols from Q plus one bit of extra information.
{"ft_lang_label":"__label__en","ft_lang_prob":0.89069414,"math_prob":0.9945239,"size":2827,"snap":"2023-40-2023-50","text_gpt3_token_len":707,"char_repetition_ratio":0.14594403,"word_repetition_ratio":0.018223235,"special_character_ratio":0.25327203,"punctuation_ratio":0.10242086,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9995196,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-09-23T00:24:56Z\",\"WARC-Record-ID\":\"<urn:uuid:c934b06a-7d7d-44b7-ac8b-c8d8f0cb4bbc>\",\"Content-Length\":\"185573\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:07129da9-4564-4b7f-8d8d-4bd9ef34f713>\",\"WARC-Concurrent-To\":\"<urn:uuid:365dd4ca-0de5-4c59-88c9-5472ae88817a>\",\"WARC-IP-Address\":\"104.18.11.86\",\"WARC-Target-URI\":\"https://stats.stackexchange.com/questions/111445/analysis-of-kullback-leibler-divergence?noredirect=1\",\"WARC-Payload-Digest\":\"sha1:FSAH2K2KRYAYF7IR6PCIXTLNAI7X72HX\",\"WARC-Block-Digest\":\"sha1:KFC52LKRFOOCX6TGOFOREFNP2B6KH3C4\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-40/CC-MAIN-2023-40_segments_1695233506429.78_warc_CC-MAIN-20230922234442-20230923024442-00364.warc.gz\"}"}