Skip to content

Commit 04c4dff

Browse files
authored
added proof "duni-kl"
1 parent 7c131aa commit 04c4dff

1 file changed

Lines changed: 75 additions & 0 deletions

File tree

P/duni-kl.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
layout: proof
3+
mathjax: true
4+
5+
author: "Joram Soch"
6+
affiliation: "BCCN Berlin"
7+
e_mail: "joram.soch@bccn-berlin.de"
8+
date: 2023-11-17 15:19:37
9+
10+
title: "Kullback-Leibler divergence for the discrete uniform distribution"
11+
chapter: "Probability Distributions"
12+
section: "Univariate discrete distributions"
13+
topic: "Discrete uniform distribution"
14+
theorem: "Kullback-Leibler divergence"
15+
16+
sources:
17+
18+
proof_id: "P425"
19+
shortcut: "duni-kl"
20+
username: "JoramSoch"
21+
---
22+
23+
24+
**Theorem:** Let $X$ be a [random variable](/D/rvar). Assume two [discrete uniform distributions](/D/Duni) $P$ and $Q$ specifying the probability distribution of $X$ as
25+
26+
$$ \label{eq:dunis}
27+
\begin{split}
28+
P: \; X &\sim \mathcal{U}(a_1, b_1) \\
29+
Q: \; X &\sim \mathcal{U}(a_2, b_2) \; .
30+
\end{split}
31+
$$
32+
33+
Then, the [Kullback-Leibler divergence](/D/kl) of $P$ from $Q$ is given by
34+
35+
$$ \label{eq:duni-KL}
36+
\mathrm{KL}[P\,||\,Q] = \ln \frac{b_2-a_2+1}{b_1-a_1+1} \; .
37+
$$
38+
39+
40+
**Proof:** The [KL divergence for a discrete random variable](/D/kl) is given by
41+
42+
$$ \label{eq:KL-disc}
43+
\mathrm{KL}[P\,||\,Q] = \sum_{x \in \mathcal{X}} p(x) \, \ln \frac{p(x)}{q(x)} \; .
44+
$$
45+
46+
This means that the KL divergence of $P$ from $Q$ is only defined, if for all $x \in \mathcal{X}$, $q(x) = 0$ implies $p(x) = 0$. Thus, $\mathrm{KL}[P\,||\,Q]$ only exists, if $a_2 \leq a_1$ and $b_1 \leq b_2$, i.e. if $P$ only places non-zero probability where $Q$ also places non-zero probability, such that $q(x)$ is not zero for any $x \in \mathcal{X}$ where $p(x)$ is positive.
47+
48+
If this requirement is fulfilled, we can write
49+
50+
$$ \label{eq:duni-KL-s1}
51+
\mathrm{KL}[P\,||\,Q] = \sum_{x=-\infty}^{a_1} p(x) \, \ln \frac{p(x)}{q(x)} + \sum_{x=a_1}^{b_1} p(x) \, \ln \frac{p(x)}{q(x)} + \sum_{x=b_1}^{+\infty} p(x) \, \ln \frac{p(x)}{q(x)}
52+
$$
53+
54+
and because $p(x) = 0$ for any $x < a_1$ and any $x > b_1$, we have
55+
56+
$$ \label{eq:duni-KL-s2}
57+
\mathrm{KL}[P\,||\,Q] = \sum_{x=-\infty}^{a_1} 0 \cdot \ln \frac{0}{q(x)} + \sum_{x=a_1}^{b_1} p(x) \, \ln \frac{p(x)}{q(x)} + \sum_{x=b_1}^{+\infty} 0 \cdot \ln \frac{0}{q(x)} \; .
58+
$$
59+
60+
Now, $(0 \cdot \ln 0)$ is taken to be $0$ [by convention](/D/ent), such that
61+
62+
$$ \label{eq:duni-KL-s3}
63+
\mathrm{KL}[P\,||\,Q] = \sum_{x=a_1}^{b_1} p(x) \, \ln \frac{p(x)}{q(x)}
64+
$$
65+
66+
and we can use the [probability mass function of the discrete uniform distribution](/P/duni-pmf) to evaluate:
67+
68+
$$ \label{eq:duni-KL-s4}
69+
\begin{split}
70+
\mathrm{KL}[P\,||\,Q] &= \sum_{x=a_1}^{b_1} \frac{1}{b_1-a_1+1} \cdot \ln \frac{\frac{1}{b_1-a_1+1}}{\frac{1}{b_2-a_2+1}} \\
71+
&= \frac{1}{b_1-a_1+1} \cdot \ln \frac{b_2-a_2+1}{b_1-a_1+1} \sum_{x=a_1}^{b_1} 1 \\
72+
&= \frac{1}{b_1-a_1+1} \cdot \ln \frac{b_2-a_2+1}{b_1-a_1+1} \cdot (b_1-a_1+1) \\
73+
&= \ln \frac{b_2-a_2+1}{b_1-a_1+1} \; .
74+
\end{split}
75+
$$

0 commit comments

Comments
 (0)