Skip to content

Commit 854a69a

Browse files
authored
added proof "bin-kl"
1 parent c877b06 commit 854a69a

1 file changed

Lines changed: 93 additions & 0 deletions

File tree

P/bin-kl.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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-10-20 12:49:46
9+
10+
title: "Kullback-Leibler divergence for the binomial distribution"
11+
chapter: "Probability Distributions"
12+
section: "Univariate discrete distributions"
13+
topic: "Binomial distribution"
14+
theorem: "Kullback-Leibler divergence"
15+
16+
sources:
17+
- authors: "PSPACEhard"
18+
year: 2017
19+
title: "Kullback-Leibler divergence for binomial distributions P and Q"
20+
in: "StackExchange Mathematics"
21+
pages: "retrieved on 2023-10-20"
22+
url: "https://math.stackexchange.com/a/2215384/480910"
23+
24+
proof_id: "P420"
25+
shortcut: "bin-kl"
26+
username: "JoramSoch"
27+
---
28+
29+
30+
**Theorem:** Let $X$ be a [random variable](/D/rvar). Assume two [binomial distributions](/D/bin) $P$ and $Q$ specifying the probability distribution of $X$ as
31+
32+
$$ \label{eq:bins}
33+
\begin{split}
34+
P: \; X &\sim \mathrm{Bin}(n, p_1) \\
35+
Q: \; X &\sim \mathrm{Bin}(n, p_2) \; .
36+
\end{split}
37+
$$
38+
39+
Then, the [Kullback-Leibler divergence](/D/kl) of $P$ from $Q$ is given by
40+
41+
$$ \label{eq:bin-KL}
42+
\mathrm{KL}[P\,||\,Q] = n p_1 \cdot \ln \frac{p_1}{p_2} + n (1-p_1) \cdot \ln \frac{1-p_1}{1-p_2} \; .
43+
$$
44+
45+
46+
**Proof:** The [KL divergence for a discrete random variable](/D/kl) is given by
47+
48+
$$ \label{eq:KL-disc}
49+
\mathrm{KL}[P\,||\,Q] = \sum_{x \in \mathcal{X}} p(x) \, \ln \frac{p(x)}{q(x)}
50+
$$
51+
52+
which, applied to the [binomial distributions](/D/bin) in \eqref{eq:bins}, yields
53+
54+
$$ \label{eq:bin-KL-s1}
55+
\begin{split}
56+
\mathrm{KL}[P\,||\,Q] &= \sum_{x=0}^{n} p(x) \, \ln \frac{p(x)}{q(x)} \\
57+
&= p(X=0) \cdot \ln \frac{p(X=0)}{q(X=0)} + \ldots + p(X=0) \cdot \ln \frac{p(X=0)}{q(X=0)} \; .
58+
\end{split}
59+
$$
60+
61+
Using the [probability mass function of the binomial distribution](/P/bin-pmf), this becomes:
62+
63+
$$ \label{eq:bin-KL-s2}
64+
\begin{split}
65+
\mathrm{KL}[P\,||\,Q] &= \sum_{x=0}^{n} {n \choose x} \, p_1^x \, (1-p_1)^{n-x} \cdot \ln \frac{{n \choose x} \, p_1^x \, (1-p_1)^{n-x}}{{n \choose x} \, p_2^x \, (1-p_2)^{n-x}} \\
66+
&= \sum_{x=0}^{n} {n \choose x} \, p_1^x \, (1-p_1)^{n-x} \cdot \left[ x \cdot \ln \frac{p_1}{p_2} + (n-x) \cdot \ln \frac{1-p_1}{1-p_2} \right] \\
67+
&= \ln \frac{p_1}{p_2} \cdot \sum_{x=0}^{n} {n \choose x} \, p_1^x \, (1-p_1)^{n-x} x + \ln \frac{1-p_1}{1-p_2} \cdot \sum_{x=0}^{n} {n \choose x} \, p_1^x \, (1-p_1)^{n-x} (n-x) \; .
68+
\end{split}
69+
$$
70+
71+
We can now see that some terms in this sum are [expected values](/D/mean) with respect to [binomial distributions](/D/bin):
72+
73+
$$ \label{eq:bin-means-s1}
74+
\begin{split}
75+
\sum_{x=0}^{n} {n \choose x} \, p_1^x \, (1-p_1)^{n-x} x &= \mathrm{E}\left[ x \right]_{\mathrm{Bin}(n,p_1)} \\
76+
\sum_{x=0}^{n} {n \choose x} \, p_1^x \, (1-p_1)^{n-x} (n-x) &= \mathrm{E}\left[ n-x \right]_{\mathrm{Bin}(n,p_1)} \; .
77+
\end{split}
78+
$$
79+
80+
Using the [expected value of the binomial distribution](/P/bin-mean), these can be simplified to
81+
82+
$$ \label{eq:bin-means-s2}
83+
\begin{split}
84+
\mathrm{E}\left[ x \right]_{\mathrm{Bin}(n,p_1)} &= n p_1 \\
85+
\mathrm{E}\left[ n-x \right]_{\mathrm{Bin}(n,p_1)} &= n - n p_ 1 \; ,
86+
\end{split}
87+
$$
88+
89+
such that the Kullback-Leibler divergence finally becomes:
90+
91+
$$ \label{eq:bin-KL-qed}
92+
\mathrm{KL}[P\,||\,Q] = n p_1 \cdot \ln \frac{p_1}{p_2} + n (1-p_1) \cdot \ln \frac{1-p_1}{1-p_2} \; .
93+
$$

0 commit comments

Comments
 (0)