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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
45 Information Theory is awesome so here is a TL;DR about Shannon's entropy.
47 The field is originally about quantifying the amount of
48 ``information'' contained in a signal and how much can be transmitted
49 under certain conditions.
51 What makes it awesome IMO is that it is very intuitive, and like
52 thermodynamics in Physics it give exact bounds about what is possible
55 \section{Shannon's Entropy}
57 Shannon's entropy is the key concept from which everything is defined.
59 Imagine that you have a distribution of probabilities $p$ on a finite
60 set of symbols, and that you generate a stream of symbols by sampling
61 them one after another independently with that distribution.
63 To transmit that stream, for instance with bits over a communication
64 line, you can design a coding that takes into account that the symbols
65 are not all as probable, and decode on the other side.
67 For instance if $P('\!\!A')=1/2$, $P('\!\!B')=1/4$, and
68 $P('\!\!C')=1/4$ you would transmit ``0'' for a ``A'' and ``10'' for a
69 ``B'' and ``11'' for a ``C'', 1.5 bits on average.
71 If the symbol is always the same, you transmit nothing, if they are
72 equiprobable you need $\log_2$(nb symbols) etc.
74 Shannon's Entropy (in base 2) is the minimum number of bits you have
75 to emit on average per symbol to transmit that stream.
77 It has a simple analytical form:
80 H(p) = - \sum_k p(k) \log_2 p(k)
83 where by convention $o \log_2 0 = 0$.
85 It is often seen as a measure of randomness since the more
86 deterministic the distribution is, the less you have to emit.
88 The examples above correspond to "Huffman coding", which reaches the
89 Entropy bound only for some distributions. A more sophisticated scheme
90 called "Arithmetic coding" does it always.
92 From this perspective, many quantities have an intuitive
93 value. Consider for instance sending pairs of symbols (X, Y).
95 If these two symbols are independent, you cannot do better than
96 sending one and the other separately, hence
99 H(X, H) = H(X) + H(Y).
102 However, imagine that the second symbol is a function of the first
103 Y=f(X). You just have to send X since Y can be computed from it on the
112 An associated quantity is the mutual information between two random
113 variables, defined with
116 I(X;Y) = H(X) + H(Y) - H(X,Y),
119 that quantifies the amount of information shared by the two variables.
121 \section{Conditional Entropy}
123 Conditional entropy is the average of the entropy of the conditional distribution:
127 &= \sum_y p(Y=y) H(X \mid Y=y)\\
128 &= \sum_y P(Y=y) \sum_x P(X=x \mid Y=y) \log P(X=x \mid Y=y)
131 Intuitively it is the [minimum average] number of bits required to describe X given that Y is known.
133 So in particular, if X and Y are independent, getting the value of $Y$
134 does not help at all, so you still have to send all the bits for $X$,
141 if X is a deterministic function of Y then
147 And if you send the bits for Y and then the bits to describe X given
148 that Y, you have sent (X, Y). Hence we have the chain rule:
151 H(X, Y) = H(Y) + H(X \mid Y).
157 I(X;Y) &= H(X) + H(Y) - H(X,Y)\\
158 &= H(X) + H(Y) - (H(Y) + H(X \mid Y))\\
159 &= H(X) - H(X \mid Y).
162 \section{Kullback-Leibler divergence}
164 Imagine that you encode your stream thinking it comes from
165 distribution $q$ while it comes from $p$. You would emit more bits than
166 the optimal $H(p)$, and that supplement is $D_{KL}(p||q)$ the
167 Kullback-Leibler divergence between $p$ and $q$.
169 In particular if $p=q$
175 and if there is a symbol $x$ with $q(x)=0$ and $p(x)>0$, you cannot encode it and
178 D_{KL}(p\|q)=+\infty.
181 Its formal expression is
184 D_{KL}(p\|q) = \sum_x p(x) \log\left(\frac{p(x)}{q(x)}\right)
187 that can be understood as a value called the cross-entropy between $p$ and $q$
190 H(p,q) = -\sum_x p(x) \log q(x)
193 minus the entropy of p
195 H(p) = -\sum_x p(x) \log p(x).
198 Notation horror: if $X$ and $Y$ are random variables $H(X, Y)$ is the
199 entropy of their joint law, and if $p$ and $q$ are distributions,
200 $H(p,q)$ is the cross-entropy between them.