1 %% -*- mode: latex; mode: reftex; mode: flyspell; coding: utf-8; tex-command: "pdflatex.sh" -*-
3 %% Any copyright is dedicated to the Public Domain.
4 %% https://creativecommons.org/publicdomain/zero/1.0/
5 %% Written by Francois Fleuret <francois@fleuret.org>
7 \documentclass[10pt,a4paper,twoside]{article}
8 \usepackage[paperheight=18cm,paperwidth=10cm,top=5mm,bottom=20mm,right=5mm,left=5mm]{geometry}
9 %\usepackage[a4paper,top=2.5cm,bottom=2cm,left=2.5cm,right=2.5cm]{geometry}
10 \usepackage[utf8]{inputenc}
11 \usepackage{amsmath,amssymb,dsfont}
12 \usepackage[pdftex]{graphicx}
13 \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue,citecolor=blue]{hyperref}
15 \usetikzlibrary{arrows,arrows.meta,calc}
16 \usetikzlibrary{patterns,backgrounds}
17 \usetikzlibrary{positioning,fit}
18 \usetikzlibrary{shapes.geometric,shapes.multipart}
19 \usetikzlibrary{patterns.meta,decorations.pathreplacing,calligraphy}
20 \usetikzlibrary{tikzmark}
21 \usetikzlibrary{decorations.pathmorphing}
22 \usepackage[round]{natbib}
24 \usepackage{mleftright}
26 \newcommand{\setmuskip}[2]{#1=#2\relax}
27 \setmuskip{\thinmuskip}{1.5mu} % by default it is equal to 3 mu
28 \setmuskip{\medmuskip}{2mu} % by default it is equal to 4 mu
29 \setmuskip{\thickmuskip}{3.5mu} % by default it is equal to 5 mu
31 \setlength{\parindent}{0cm}
32 \setlength{\parskip}{12pt}
33 %\renewcommand{\baselinestretch}{1.3}
34 %\setlength{\tabcolsep}{0pt}
35 %\renewcommand{\arraystretch}{1.0}
37 \def\argmax{\operatornamewithlimits{argmax}}
38 \def\argmin{\operatornamewithlimits{argmin}}
39 \def\expect{\mathds{E}}
41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47 Information Theory is awesome so here is a TL;DR about Shannon's entropy.
49 The field is originally about quantifying the amount of
50 ``information'' contained in a signal and how much can be transmitted
51 under certain conditions.
53 What makes it awesome IMO is that it is very intuitive, and like
54 thermodynamics in Physics, it gives exact bounds about what is possible
57 \section{Shannon's Entropy}
59 Shannon's entropy is the key concept from which everything is defined.
61 Imagine that you have a distribution of probabilities $p$ on a finite
62 set of symbols, and that you generate a stream of symbols by sampling
63 them one after another independently with that distribution.
65 To transmit that stream, for instance with bits over a communication
66 line, you can design a coding that takes into account that the symbols
67 are not all as probable, and decode on the other side.
69 For instance if $P('\!\!A')=1/2$, $P('\!\!B')=1/4$, and
70 $P('\!\!C')=1/4$ you would transmit ``0'' for a ``A'' and ``10'' for a
71 ``B'' and ``11'' for a ``C'', 1.5 bits on average.
73 If the symbol is always the same, you transmit nothing, if they are
74 equiprobable you need $\log_2$(nb symbols) etc.
76 Shannon's Entropy (in base 2) is the minimum number of bits you have
77 to emit on average per symbol to transmit that stream.
79 It has a simple analytical form:
82 H(p) = - \sum_k p(k) \log_2 p(k)
85 where by convention $0 \log_2 0 = 0$.
87 It is often seen as a measure of randomness since the more
88 deterministic the distribution is, the less you have to emit.
90 The examples above correspond to "Huffman coding", which reaches the
91 Entropy bound only for some distributions. A more sophisticated scheme
92 called "Arithmetic coding" does it always.
94 From this perspective, many quantities have an intuitive
95 value. Consider for instance sending pairs of symbols (X, Y).
97 If these two symbols are independent, you cannot do better than
98 sending one and the other separately, hence
101 H(X, H) = H(X) + H(Y).
104 However, imagine that the second symbol is a function of the first
105 Y=f(X). You just have to send X since Y can be computed from it on the
114 An associated quantity is the mutual information between two random
115 variables, defined with
118 I(X;Y) = H(X) + H(Y) - H(X,Y),
121 that quantifies the amount of information shared by the two variables.
123 \section{Conditional Entropy}
125 Conditional entropy is the average of the entropy of the conditional distribution:
129 &= \sum_y p(Y=y) H(X \mid Y=y)\\
130 &= \sum_y P(Y=y) \sum_x P(X=x \mid Y=y) \log P(X=x \mid Y=y)
133 Intuitively it is the [minimum average] number of bits required to describe X given that Y is known.
135 So in particular, if X and Y are independent, getting the value of $Y$
136 does not help at all, so you still have to send all the bits for $X$,
143 if X is a deterministic function of Y then
149 And if you send the bits for Y and then the bits to describe X given
150 that Y, you have sent (X, Y). Hence we have the chain rule:
153 H(X, Y) = H(Y) + H(X \mid Y).
159 I(X;Y) &= H(X) + H(Y) - H(X,Y)\\
160 &= H(X) + H(Y) - (H(Y) + H(X \mid Y))\\
161 &= H(X) - H(X \mid Y).
164 \section{Kullback-Leibler divergence}
166 Imagine that you encode your stream thinking it comes from
167 distribution $q$ while it comes from $p$. You would emit more bits than
168 the optimal $H(p)$, and that supplement is $D_{KL}(p||q)$ the
169 Kullback-Leibler divergence between $p$ and $q$.
171 In particular if $p=q$
177 and if there is a symbol $x$ with $q(x)=0$ and $p(x)>0$, you cannot encode it and
180 D_{KL}(p\|q)=+\infty.
183 Its formal expression is
186 D_{KL}(p\|q) = \sum_x p(x) \log\left(\frac{p(x)}{q(x)}\right)
189 that can be understood as a value called the cross-entropy between $p$ and $q$
192 H(p,q) = -\sum_x p(x) \log q(x)
195 minus the entropy of p
197 H(p) = -\sum_x p(x) \log p(x).
200 Notation horror: if $X$ and $Y$ are random variables $H(X, Y)$ is the
201 entropy of their joint law, and if $p$ and $q$ are distributions,
202 $H(p,q)$ is the cross-entropy between them.