-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tex
1765 lines (1658 loc) · 56 KB
/
main.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\documentclass[10pt]{homework}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{minted}
\usepackage{braket}
\usepackage{longtable}
\usepackage{parskip}
\usepackage[open,openlevel=1]{bookmark}
\bookmarksetup{}
\usepackage{fix-unnumbered-sections}
% \usepackage{scrextend}
% \deffootnote{1.5em}{0em}{\textsuperscript\thefootnotemark\,}
% \setlength{\footnotesep}{11pt}
% \hypersetup{
% colorlinks=true,
% urlcolor=blue,
% }
\newcommand{\hwauthor}{JAPM}
\newcommand{\hwauthorextra}{}
\newcommand{\hwtitle}{Notes}
\newcommand{\hwshorttitle}{Notes}
% CHANGE THESE ONLY ONCE PER CLASS
\newcommand{\hwclass}{Information Theory}
\newcommand{\hwclassshort}{Information Theory}
\newcommand{\mysep}{\vspace{0.5em} \hrule \vspace{.1in}}
\usepackage{stackrel}
\DeclareMathOperator*{\mysimbig}{\scalebox{2.75}{\raisebox{-0.35ex}{$\sim$}}}
\newcommand{\simover}[1]{
\overset
{\resizebox{0.27in}{!}{#1}}
{\resizebox{0.30in}{!}{$\mysimbig$}}
}
\newcommand{\pluseq}{\mathrel{+}=}
\newcommand{\lelem}[1]{% elementary operations (left alignment)
\begin{subarray}{l}#1\end{subarray}%
}
\usepackage{bbm}
\usepackage{nicematrix}
\usepackage{tikz}
\usetikzlibrary{fit,shapes.geometric}
\tikzset{highlight/.style={rectangle, draw=black!40, semithick, inner sep=2pt}}
\newcommand{\tikzHlcol}[2]{
\tikz \node [highlight, fit=(1-#1) (#2-#1)] {} ;
}
\newcommand{\tikzHlrow}[2]{
\tikz \node [highlight, fit=(#1-1) (#1-#2), inner sep=1pt] {} ;
}
\usepackage{array} % for \newcolumntype macro
\newcolumntype{M}[1]{>{$\displaystyle\quad}p{#1}<{$}}
\usepackage{mathtools}
\usepackage{bm}
% https://tex.stackexchange.com/questions/343494/
\usepackage{xpatch}
\makeatletter
\AtBeginEnvironment{minted}{\dontdofcolorbox}
\def\dontdofcolorbox{\renewcommand\fcolorbox[4][]{##4}}
\xpatchcmd{\inputminted}{\minted@fvset}{\minted@fvset\dontdofcolorbox}{}{}
\xpatchcmd{\mintinline}{\minted@fvset}{\minted@fvset\dontdofcolorbox}{}{} % see https://tex.stackexchange.com/a/401250/
\makeatother
\newcommand{\indep}{\perp \!\!\! \perp}
\newenvironment{mytable}
{ % begin
\bgroup
\centering
\def\arraystretch{2.3}% 1 is the default, change whatever you need
\begin{longtable}{wr{0.34\textwidth}M{0.66\textwidth}}
}
{ % end
\end{longtable}
\egroup
}
\newenvironment{mytextcol}
{ % begin
\begin{minipage}[t]{0.6\textwidth}
}
{ % end
\end{minipage}
}
% Use for publications...
%\newcommand{\entr}{\mathcal{H}}
\usepackage[overlay,absolute]{textpos}
\newcommand\PlaceText[3]{%
\begin{textblock*}{10in}(#1,#2) %% change width of box from 10in as you wish
#3
\end{textblock*}
}%
\begin{document}
\PlaceText{0.88\textwidth}{\voffset+1.6cm}{Version: \texttt{\detokenize{2023_06_03_0}}}
\mysetupheader
% TODO: fix this...
% \vspace{1cm}\phantom{M}
%%%%
The author of this document is the sole responsible for all the typos/mistakes found in it and would be grateful to receive corrections and constructive feedback in general.
\\[-20pt]
\section*{References}
\begin{itemize}
\item
Stefan Höst, \emph{Information and Communication Theory}, 1st ed., ISBN: 978-1-119-43378-1, Lund University.
% TODO: add McEliece book !!
\item Raymond W.\@ Yeung, \emph{Information Theory and Network Coding}, 1st ed., ISBN: 978-0-387-79234-7, CUHK.
\item
Akshay Krishnamurthy, Aarti Singh, \emph{10-704 Lecture Notes}, Winter 2016-2017, CMU.
\\
\url{https://www.cs.cmu.edu/~aarti/Class/10704_Spring15/lecs.html}
\item
Eirik Rosnes, \emph{INF 144}, Spring 2017, UiB.
\\
\url{https://folk.uib.no/st03333/INF144_2017/Lectures/}
% TODO: http://isl.stanford.edu/~abbas/ee376b/lect02.pdf
\item
David Tse, \emph{EE376A Lecture Notes}, Winter 2016-2017, Stanford University.
\\
\url{https://tselab.stanford.edu/mirror/ee376a_winter1617/lectures.html}
\item
Stefan M. Moser, \emph{IT Lecture Notes}, version 6.9. ETHZ.
\\
\url{https://moser-isi.ethz.ch/docs/it_script_v69.pdf}
% https://www.icg.isy.liu.se/courses/infotheory/
% Robert Gallager
% https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-450-principles-of-digital-communications-i-fall-2006/lecture-notes/
% https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-451-principles-of-digital-communication-ii-spring-2005/readings-and-lecture-notes/
\item
Yury Polyanskiy, Yihong Wu, \emph{Lecture notes on Information Theory}, v.\@\! 2019-May-15, MIT LIDS.
\\
Too advanced! (but really good), requires measure theory notions.\\
\url{http://people.lids.mit.edu/yp/homepage/data/itbook-export.pdf}
\end{itemize}
\section*{Probability}
\subsection*{Basic definitions}
\begin{mytable}
Conditional probability: &
P(A|B) = \frac{P(A \cap B)}{P(B)}
\,;\quad
p_{X|Y}(x|y) = \frac{p_{X,Y}(x,y)}{p_Y(y)}
\\[-8pt]&
\text{given }P(B)\neq 0,\, p_Y(y)\neq 0
\\
Independence ($X \indep Y$):
&
p_{XY}(x,y) = p_{X}(x)\cdot p_{Y}(y)
\iff
p_{X|Y}(x|y) = p_{X}(x),\, \forall y\, (\text{with } p(y)\neq 0)
\\
Marginalization (total probability): &
P(X=x) = \sum_{y\in \mathcal Y} P(X=x,Y=y) = \sum_{y\in \mathcal Y} P(Y=y)\cdot P(X=x|Y=y) \\
&
p_X(x) = \sum_{y\in \mathcal Y} p_{XY}(x,y) = \sum_{y\in \mathcal Y} p_Y(y)\cdot p_{X|Y}(x|y) \\
Expectation: &
\mathbb{E}[X] = \sum_{x\in \mathcal X} x\cdot p_X(x) = \mu_X; \quad
\mathbb{E}[g(X)] = \sum_{x\in \mathcal X} g(x)\cdot p_X(x)
\\
Variance: &
\mathbb{V}[X] = \mathbb{E} [(X-\mu_X)^2] = \sigma_X^2 \text{, where } \mu_X = \mathbb{E}[X]\\
Power (Mean Square): & \mathbb{E}[X^2] = \mathbb{V}[X] + (\mathbb{E}[X])^2
\\
Covariance: &
\text{Cov}(X,Y) = \mathbb{E}_{XY} [(X-\mu_X)\cdot (Y-\mu_Y)] = \mathbb{E}_{XY} [X\cdot Y] -\mu_X \cdot \mu_Y
\\
RV linear combination: &
Y = \sum_{i=1}^{N}\alpha_n\cdot X_i \implies
\mathbb{E}[Y]=\sum_{i=1}^{N}\alpha_i\cdot \mathbb{E}[X_i]
\\ &
\mathbb{V}[Y] = \sum_{i=1}^{N}\alpha_n^2\cdot \mathbb{V}[X_n]
+ 2\cdot \sum_{i=1}^{N}\sum_{j=i+1}^{N} \text{Cov}(X_i, X_j)
\\
Entropy (discrete RV): &
H(X) = \mathbb{E}_X[-\log_2(p_X(X))]\text{ bits};
\quad H_e(X) = \ln 2\cdot H(X)\text{ ``nats''}
\\[-8pt]
& H(X) = H(p_1, p_2, \cdots, p_n) = \sum_i p_i\cdot \log \frac{1}{p_i}
\\
Differential entropy (continuous RV): &
H_\text{Dif}(X) = \mathbb{E}_X[-\log_2(f_X(X))] = \int_{\mathbb{R}} f_X(x)\cdot\log_2 \frac{1}{f_X(x)}\, dx, \newline\phantom{M} (X \text{ with pdf } f_X)
\\\pagebreak
Wide-Sense Stationary (WSS) process: &
E[X_i] = E[X_1]; \quad r_{XX}(n, n+k) = r_{XX}(k)
\\
(Strongly/Strictly) Stationary process: &
p_X(x_{1},x_{2}, \cdots ,x_{n}) =
p_X(x_{1+\Delta},x_{2+\Delta}, \cdots ,x_{n+\Delta})
\newline\phantom{M}
\text{(time shift invariance)}
\\
Ergodic process: &\text{WSS and (in mean) }
\hat\mu_X = \langle X_i \rangle_N = \frac{1}{N}\sum^N{X_i} = \mathbb{E}[X_0] = \mu_X\\
% &\text{(in autocovariance) }\newline\phantom{MM} \hat r_{XX}(\tau) = (????) = \mathbb{E}[(X_t-\mu_{X_t})(X_{t-\tau}-\mu_{X_{t-\tau}})] = r_{XX}(\tau)
% \\
\end{mytable}
\subsection*{Basic properties}
\begin{mytable}
Bayes' theorem: &
p_{X|Y}(x|y) =
\frac{p_{Y|X}(y|x)\cdot p_X(x)}{p_Y(y)} =
\frac{p_{Y|X}(y|x)\cdot p_X(x)}{
\sum\limits_{x^\prime\in\mathcal{X}} p_{Y|X}(y|x^\prime)\cdot p_X(x^\prime)
}
\\
Chain rule: &
P(X_1,X_2, \dots, X_n) = P(X_1,X_2, \dots, X_{n-1})
\cdot P(X_n|X_1, X_2, \dots, X_{n-1})
\\
&
= \cdots =
\overbrace{\underbrace{P(X_1)\cdot P(X_2|X_1)}_{P(X_1,X_2)}
\cdot P(X_3|X_1,X_2)}^{P(X_1,X_2,X_3)} \cdots
P(X_n|X_1, X_2, \dots, X_{n-1})
\\[-4pt]
&
= \prod_{i=1}^n P(X_i | X_1, X_2, \dots, X_{i-1}), \quad \text{(convention: first factor is $P(X_1)$)}
\\
Markov's inequality: &
P(X>a) \le \frac{\mathbb{E}[X]}{a}
\quad \text{($X$ is a nonnegative RV)}
\\
Chebyshev's inequality: &
P\left(\left|X-\mathbb{E}[X]\right|>\varepsilon\right) \le \frac{\mathbb{V}[X]}{\varepsilon^2};
\quad
P\left(\left|X-\mathbb{E}[X]\right|>\frac{\sigma_X}{\varepsilon}\right) \le \varepsilon^2
\\
Weak Law of Large Numbers (LLN): & Y_N = \frac{1}{N}\sum_{i=1}^{N} X_i \quad (X_i \text{ i.i.d.});
\quad
P\left(\left|Y_N-\mathbb{E}[X]\right|>\varepsilon\right) \le \frac{\mathbb{V}[X]}{\varepsilon^2}
\\&
\lim_{N\to\infty} P\left(\left|Y_N-\mathbb{E}[X]\right|<\varepsilon\right) = 1;
\quad
Y_N \xrightarrow[]{P} \mathbb{E}[X]
\\
%Convergence in probability:
%& \text{[TODO]}
%\\
Central Limit Theorem (CLT): & Y_N = \frac{1}{N}\sum_{i=1}^{N} X_i \quad (X_i \text{ i.i.d., } \mathbb{E}[X_i] = \mu,\,\mathbb{V}[X_i]=\sigma^2)
\\&
\frac{Y_N-\mu}{\sigma/\sqrt{N}}
\,\simover{$(N\to\infty)$}\,
\mathcal{N}(0,1)
\\
Convexity:&
f(\lambda \cdot x_1+(1-\lambda) \cdot x_2) \le
\lambda\cdot f( x_1 ) + (1-\lambda)\cdot f( x_2 ),\, \forall\lambda \in [0,1]
\\
Concavity:& \text{$f$ is convex $\iff$ $-f$ is concave}
\\
Jensen's inequality: & g \text{ is convex} \implies \mathbb{E}[g(X)] \ge g(\mathbb{E}[X])
\\
Log-sum inequality: & \sum_i a_i \cdot \log \frac{a_i}{b_i} \ge
A \cdot \log \frac{A}{B}; \quad A =\sum_i a_i; \, B =\sum_i b_i; \, a_i > 0,\,b_i > 0
\\
IT inequality: & \log_B (r) \le (r-1)\cdot \log_B(e); \\[-10pt]&
\text{``$\log x$ is concave so it lies below its tangent line at $(1,0)$''}
\\
\end{mytable}
\newpage
\subsection*{Discrete Distributions}
Hint -- Use combinatorics: \url{https://en.wikipedia.org/wiki/Urn_problem}
\begin{mytable}
Uniform (discrete): & X\sim U(n),\quad
p_X(x) = \frac{1}{|\mathcal{A}|}\cdot \mathbbm{1}_\mathcal{A}(x),\quad \mathcal{A} = \{0,\dots, n-1\} \subset \mathbb{N}, \, |\mathcal{A}| = n
\\
& \mathbb{E}[X] = \frac{n-1}{2}; \quad \mathbb{V}[X] = \frac{n^2-1}{2};
\quad H(X) = H(p, p, \dots, p) = \log_2 p
\\
Bernoulli:&\text{``heads or tails (loaded coin), black/white ball, success/failure, 1 or 0, ...''}
\\[-8pt]
&
X\sim\text{Be}(p); \quad
P(X=\text{``1''}) = p = 1 - P(X=\text{``0''})
\\[-12pt]
& \mathbb{E}[X] = p; \quad \mathbb{V}[X] = p\cdot (1-p);
\quad H(X) = h_2(p) = H(p, 1-p)
\\[-6pt]
&\begin{mytextcol}
``Probability of $k$ successes (with prob.\,$p$) in $n$ attempts'' = \\= ``Probability of a binary string of length $n$ with $k$ ones'' =\\ = $P(\bm X=\bm x)=p^k\cdot (1-p)^{n-k}$
\end{mytextcol}
\\
Geometric: &
\text{``infinite attempts where the first success is at the }k\text{-th attempt''}
\\ &
X\sim\text{Ge}(p),
\quad p=P(X=\text{``}\underbrace{\text{00...01}}_k\text{...''})
\\
&
p_X(k)= p\cdot (1-p)^{k-1};
\quad
\mathbb{E}[X] = \frac{1}{p}; \quad \mathbb{V}[X] = \frac{1-p}{p^2}; \quad H(X) = \frac{h_2(p)}{p}
\\
Binomial:
&
\text{``number of ones (successes) out of }n\text{ attempts (with replacement)''}
\\&
X\sim \text{Bin}(n,p),
\quad p=P(X_{\text{Bern}(i)}=\text{``1''})
\\&
p_X(k) = \binom{n}{k}\cdot p^k\cdot (1-p)^{n-k}
\\&
\mathbb{E}[X] =n\cdot p ; \quad \mathbb{V}[X] = n\cdot p\cdot (1-p); \\& H(X) = \frac{1}{2}\cdot \log_2\left(2\pi \cdot e\cdot n\cdot p\cdot (1-p)\right) + \mathcal{O}(1/n)
\\
Hypergeometric:
&
\begin{mytextcol}
``number of black balls (successes) out of $n$ total balls drawn \emph{without replacement} from an urn with initially $N$ balls, of which $K$ are black''.
\end{mytextcol}
%
\\&
X\sim \text{Hypergeometric}(N,K,n);\quad \left(n=1\implies X\sim Be(p), \, p=K/N\right)
\\&
p_X(k) = \frac{\binom{K}{k}\binom{N-K}{n-k}}{\binom{N}{n}}
;\quad \mathbb{E}[X] =n\cdot \frac{K}{N}
\\&
\begin{mytextcol}
\footnotesize{Sometimes `hypergeometric' refers to the multivariate hypergeometric distribution (multiple colors), here we refer only to the \emph{bivariate} distribution (2 colors: black and white). Also, this is different from the `multinomial distribution' which is the `with replacement' case, the generalization of the binomial distribution.}
\end{mytextcol}
\end{mytable}
%\pagebreak
\subsection*{Continuous Distributions}
\begin{mytable}
Uniform (continuous): & X\sim U(a, b),\quad
f_X(x) = \frac{1}{\Delta}\cdot \mathbbm{1}_\mathcal{A}(x),\quad \mathcal{A} = [a, b] \subset \mathbb{R}, \, \Delta = b - a
\\
& \mathbb{E}[X] = \frac{a+b}{2}; \quad \mathbb{V}[X] = \frac{\Delta^2}{12}; \quad H_\text{Dif}(X) = \log_2 \Delta
\\
Gaussian distribution: & X \sim \mathcal N(\mu, \sigma), \,\sigma > 0
\\
& f_X(x)=\frac{1}{\sqrt{2\pi\sigma^2}}\cdot
\exp\left[-\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^2\right]
\\
& \mathbb{E}[X] = \mu; \quad \mathbb{V}[X] = \sigma^2; \quad H_\text{Dif}(X) =
\frac{1}{2}
\log_2(2\pi\cdot e\cdot \sigma^2)
\\
Exponential distribution: & X \sim \text{Exp}(\lambda), \,\lambda > 0 \implies
f_X(x) = \lambda \cdot e ^ {-\lambda x}, \, x\ge 0
\\
& \mathbb{E}[X] = \frac{1}{\lambda}; \quad \mathbb{V}[X] = \frac{1}{\lambda^2}
\\
\end{mytable}
\newpage
\section*{Information and entropy}
\begin{mytable}
Hartley's information measure: & I_H(X) = \log k = \log |\mathcal{X}|
\\[-8pt]&
\text{Number of possible outcomes (disregarding probabilities).}
\\[-8pt]&
I_H(X_1,X_2, \cdots, X_n) = \log k^n = n\cdot I_H(X)
\\
Mutual information (between events):
& I(A;B) = \log \frac{P(A|B)}{P(A)} = \log \frac{P(A\cap B)}{P(A)\cdot P(B)} = I(B;A)
\\
Bounds on $I(A;B)$:
&
-\infty \le I(A;B) \le \min \{
-\log P(A), \, -\log P(B)
\}
\\&
\begin{cases}
P(A|B) = 0 \implies
( B \Rightarrow \lnot A ) \implies
A \cap B = \varnothing \implies
I(A;B) = -\infty
\\
P(A|B) = 1 \implies
( B \Rightarrow A ) \implies
A \subseteq B \implies
I(A;B) = -\log P(A)
\\
P(B|A) = 1 \implies
( A \Rightarrow B ) \implies
B \subseteq A \implies
I(A;B) = -\log P(B)
\\
P(A|B) = P(A) \implies
A \indep B \implies I(A;B) = 0
\end{cases}
\\
Self-information (of an event):&
I(A) = I(A;A) = -\log P(A) \ge 0
\\
Entropy (of a discrete RV):&
H(X) = \mathbb{E}_x[I(X=x)] = \mathbb{E}_X[-\log p_X(X)] = -\sum_x p_X(x)\cdot \log p_X(x)
\\[-12pt]&
H(X)\ge 0
\\[-8pt]&
\text{Notation: }H(p_1, p_2, \cdots, p_n) = -\sum_i p_i\cdot \log p_i, \,\,\, \text{ given } \sum_i p_i = 1, p_i\ge 0
\\
Binary entropy function:
& h_2(p) = H(p, 1-p),\, 0\le p\le 1; \, \quad \frac{\partial h_2(p)}{\partial p} = \log_2 \frac{1-p}{p} = -\mathrm{logit}_2\,p
\\
Entropy bounds:& 0 \le H(X) \le \log k, \,\, k = |\mathcal{X}|
\\&
H(X)=0 \Rightarrow X\text{ deterministic};\,H(X)=\log k \Rightarrow X\sim\text{Uniform}(k)
\\&
H(X) \le \log k = I_H(X=x) = H\left(\frac{1}{k}, \frac{1}{k}, \cdots, \frac{1}{k}\right)
\\
Property for 3 outcomes:
&H(p_1,p_2,p_3) = h(p_1) + (1-p_1)\cdot h\left(\frac{p_2}{1-p_1}\right), \text{ given }p_1\neq 1
\\
Property for $N$ outcomes:
&H(p_1,p_2,\cdots,p_N) = h(p_1) + (1-p_1)\cdot H\left(\frac{p_2}{1-p_1},\frac{p_3}{1-p_1},\cdots \frac{p_N}{1-p_1} \right) \newline\phantom{M}\text{given }p_1\neq 1
\\
Permutation invariance:
&
\begin{mytextcol}
$H(X) = H(f(X))$, for $f$ injective (usually bijective, i.e.~invertible)\\ (a.k.a.\@ invariance under relabeling)\\[5pt]
In general: $H(X) \ge H(f(X))$
\end{mytextcol}
\\
Joint entropy: &
H(X,Y) = \mathbb{E}_{XY}[-\log p(X,Y)] = -\sum_x \sum_y p_{XY}(x,y)\cdot \log p_{XY}(x,y)
\\[-8pt] &
H(X_1,X_2, \cdots, X_n) = \mathbb{E}_{\bm X}[-\log p(\bm X)]
\\
Entropy conditioned on an outcome: &
H(X|Y=y) = H(X|\{Y=y\}) = - \sum_x p_{X|Y}(x|y) \cdot \log p_{X|Y}(x|y) \\
Conditional entropy: &
H(X|Y) = \mathbb{E}_y[H(X|\{Y=y\})] = \sum_y H(X|\{Y=y\}) \cdot p_Y(y)
\\&
H(X|Y) = \mathbb{E}_{XY}[-\log p(X,Y)] = -\sum_x \sum_y \underbrace{p_{XY}(x,y)}_\text{!!!}\cdot \log p_{X|Y}(x|y)
\\\pagebreak
Mutual information (between RVs):
& I(X;Y) = \mathbb{E}_{XY}[I(X=x;Y=y)] = I(Y;X)
\\ &
I(X;Y) = H(X) - H(X|Y) = H(X) + H(Y) - H(X,Y)
\\&
\phantom{MM}\includegraphics[width=0.3\textwidth]{img_Polyanskiy_mutual.pdf} \text{\footnotesize{(source: Y.\@ Polyanskiy IT\,lectures)}}
\\ &
I(X;Y) =\mathbb{E}_{XY}\hspace{-1.4mm}\left[\log \frac{p_{XY}(x,y)}{p_X(x)\cdot p_Y(y)}\right] = \sum_{x,y}p_{XY}(x,y)\cdot \log\frac{p_{XY}(x,y)}{p_X(x)\cdot p_Y(y)}
\\
Conditioning reduces entropy: &
I(X;Y) = H(X) - H(X|Y) \ge 0 \Rightarrow H(X) \ge H(X|Y) \text{, equal iff }X\indep Y
\\
RV self-information is entropy: &
H(X|X) = 0 \implies I(X;X) = H(X)
\\
Mutual info.\,is bounded by entropy:
& H(X) \ge H(X) - H(X|Y) = I(X;Y)
\\[-8pt]&\phantom{M}
\implies I(X;Y) \le \min\{H(X),H(Y)\}
\\[-8pt]&
\text{Also: } \max_{p_X(x)} H(X) = \log |\mathcal X| = I_H(X) \\[-8pt]&\phantom{M}
\implies
I(X;Y) \le \min\{\log |\mathcal X|,\log |\mathcal Y|\}
\\
Conditional mutual information: &
I(X;Y|Z) =
\mathbb{E}_{XYZ}\left[\log
\frac{p(X,Y|Z)}{p(X|Z)p(Y|Z)}
\right] =
\sum_{x,y,z} p(x,y,z)\log
\frac{p(x,y|z)}{p(x|z)p(y|z)}
\\&
I(X;Y|Z) =
H(X|Z)+H(X|Z)-H(X,Y|Z)
\\&
I(X;Y|Z) =
H(X|Z)-H(X|Y,Z)=H(Y|Z)-H(Y|X,Z)
\\
Chain rule for entropy: &
H(X,Y) = H(X|Y) + H(Y) = H(Y|X) + H(X) \le H(X) + H(Y)
\\&
H(X_1, X_2, \cdots, X_n) = \sum_{i=1}^n H(X_i|X_1,X_2,\cdots X_{i-1}) \le \sum_{i=1}^n H(X_i)
\\
KL divergence (a.k.a.\,relative entropy):
&
D(p||q) = \mathbb{E}_p\left[\log\frac{p(X)}{q(X)}\right] =
\sum_x p(x) \cdot \log\frac{p(x)}{q(x)} \ge 0
\\&
\text{in general:}
\begin{cases}
\text{no symmetry,}&
D(p||q) \neq D(q||p)\\
\text{no triangle inequality,}&
D(p||q) + D(q||r) \ngeq D(p||r)
\end{cases}
\\
Mutual information as KL div.:
&
I(X;Y) = D(p_{XY}(x,y)||p_X(x)\cdot p_Y(y)) \ge 0
\\
Entropy rate (of a random process): &
H_\infty(X) = \lim_{n\to\infty}\frac{1}{n}\cdot H(X_1,X_2,\cdots,X_n)
\\
\emph{Alternative} entropy rate: &
H(X|X^\infty) = \lim_{n\to\infty} H(X_n|X_1,X_2,\cdots,X_{n-1})
\\[-12pt]
&\text{Equality in stationary processes: } H_\infty(X) = H(X|X^\infty)
\\
Bounds for stationary processes: &
0\le H_\infty (X)\le H(X) \le \log k; \quad H(X) = H(X_i)
\end{mytable}
\section*{Markov chains}
\begin{mytable}
Markov property: &
P(X_i | X_{i-1}, \cdots, X_1) = P(X_i|X_{i-1}),\,\,\forall i>1\\
&\text{The RVs } X_i\text{ are in a total order (\emph{chain}): } X_1\to X_2 \to \cdots \to X_N
\\
Time-invariant (TI) Markov chains: &
p(x_i|x_{i-1}) = p(x_{i+\ell}|x_{i-1+\ell}) \text{ (assumed in general)}
\\
Chain rule for Markov chains: &
P(X_1,X_2, \dots, X_N) = \prod_{i=1}^n P(X_i | X_1, X_2, \dots, X_{i-1}) =
\\
&
= P(X_1)\cdot \prod_{i=2}^N P(X_i | X_{i-1})
\stackrel{\text{(TI)}}{=}
P(X_1)\cdot \left( P(X_2 | X_{1})\right)^{N-1}
\\
&
H(X_1,X_2,\cdots,X_N) =
H(X_1) + \sum_{i=2}^{N} H(X_i|X_{i-1})
\newline\phantom{MMMMMMMM...}
\stackrel{\text{(TI)}}{=}
H(X_1) + (N-1)\cdot H(X_2|X_{1})
\\
State transition matrix:&
\mathcal P = [p_{ij}]; \quad p_{ij} = p_{X_2|X_1}(x_i|x_j), \quad i\text{-th row adds up to }1
\\[-6pt]&
\pi_k^{(n)} = P(X_n=x_k),
\quad \bm{\pi}^{(n+1)} = \bm{\pi}^{(n)}\cdot \mathcal P
\quad \text{($\bm \pi^{(n)}$ are row vectors)}
\\
Asymptotic distribution:&
\bm{\pi} = \lim_{n\to \infty} \bm{\pi}^{(n)} = \lim_{n\to \infty} \bm{\pi}^{(0)} \cdot \mathcal P^n; \quad \lim_{n\to \infty} \mathcal P^n =
\bgroup\def\arraystretch{1}
\begin{pmatrix}
\bm{\pi} \\
\vdots \\
\bm{\pi} \\
\end{pmatrix}\egroup ; \quad \bm\pi\cdot \mathcal P = \bm\pi
\\
Existence (and uniqueness) of $\bm\pi$:
& \exists n_0 >0 \text{ s.t.\,all entries of } \mathcal P^{n_0} \text{ are strictly positive (nonzero)} \implies \exists!\bm \pi
\\[-12pt] &
\text{(particular case of Perron–Frobenius thrm.\@ for strongly connected graphs)}
\\
Computation of $\bm\pi$:
&
\begin{cases}
\bm\pi \cdot (\mathcal P-I) = 0 & \text{ (rank $N-1$ due to $\mathcal P$'s nullspace dimesnion)} \\
\sum_k \pi_k = 1 & \text{ (extra equation needed for full rank)}
\end{cases}
\\
$H_\infty(X)$ of a stationary Markov chain: &
H_\infty(X) = H(X_2|X_1)=
\\[-12pt]&
H_\infty(X) = \sum_i \bm\pi_i\cdot H(X_2|X_1=x_i); \quad
H(X_2|X_1=x_i)=-\sum_j p_{ij}\log p_{ij}
\\[-12pt]&
H_\infty(X)\text{ is the min.\,average info required to encode one transition.}
\\
Data processing lemma:
& X\to Y\to Z \text{ is a Markov chain} \implies
\begin{cases}
I(X;Z) \le I(X;Y) \\
I(X;Z) \le I(Y;Z)
\end{cases}
\\
&
I(X; Z) = H(X) - H(X|Z) \le H(X) - H(X|YZ) =\newline\phantom{MMMMMMMMMMM.M}= H(X) - H(X|Y) = I(X;Y)
\end{mytable}
\section*{Source coding}
\begin{mytable}
Compression ratio: & R = \frac{\#\text{Source bits}}{\#\text{Compressed bits}}, \quad \text{($R > 1$, except in pathological cases)}
\\
Classification of source codes: &
\begin{mytextcol}
\begin{itemize}
\item Non-singular codes: coding is injective (lossless compression)
$\bm x_1 \neq \bm x_2 \implies C(\bm x_1) \neq C(\bm x_2)$
\item Uniquely decodable codes: sequence of symbols is unambiguously decodable (\emph{extension} code is non-singular)
Sequences $\bm x_1^n \neq \bm x_2^m \implies C_{ext}(\bm x_1^n) \neq C_{ext}(\bm x_2^m)$
where $C_{ext}(\bm x^n) = \text{Concat}(C(\bm x_{(1)}),...,C(\bm x_{(n)}))$
\item Prefix codes: no codeword is prefix of any other codeword.
\end{itemize}
\end{mytextcol}
\\
Average codeword length: &
L=\mathbb{E}[\ell_x] = \sum_x p_X(x)\cdot\ell_x
\\
Path length lemma: &
L=\sum_{n_i\in\text{\,``inner nodes''}} p(n_i)
\quad \text{ (valid for prefix codes)}
\\
Kraft inequality: &
\sum_{i=1}^k D^{-\ell_i}\le 1 \text{ (valid for }D\text{-ary prefix codes)}
\\[-4pt] &
\text{all prefix codes must obey this constraint.}
\\
McMillan inequality: &
\begin{mytextcol}
Kraft inequality also holds for $D$-ary uniquely decodable codes.\\
Therefore, those are also subject to the same constraint.
\end{mytextcol}
\\
$L$, lower bound: &
L \ge H_D(X) = \frac{H(X)}{\log_2 D}
\\ & \text{equality if all }\ell_x =-\log_D p(x)
\text{ (only possible if all are integers)}
\\
$L$, achievable upper bound: &
L < H_D(X)+1 \text{ (for some }D\text{-ary prefix code, guaranteed to exist)}
\\
Shannon-Fano code &
\begin{mytextcol}
Prefix code with $\displaystyle\ell_{x_i} = \lceil -\log_D p(x_i) \rceil $
\\[8pt]
$L$ below upper bound, may have unused leaves, not optimal in general
\end{mytextcol}
\\
Fano code: &
\begin{mytextcol}
``Binary partition into sets as equiprobable as possible''.\\[3pt]
$L$ is similar to Shannon-Fano code.\\[3pt]
Provided sorted probabilities: $ p_1\ge p_2\ge\cdots\ge p_k$, \\[3pt]
recursively split at index $q$ that minimizes:
$\displaystyle
\left|\sum_{i=1}^q p_i - \sum_{i=q+1}^k p_i\right|
$
\end{mytextcol}
\\
Huffman code: &
\begin{mytextcol}
Tree algorithm: replace smallest (least prob.)\@ 2 nodes with an inner node with their sum; repeat until only one node (root) remains.\\[3pt]
Optimal: no better binary prefix code in terms of $L$.
Note: [verify this claim??] if an optimal code is built using a distribution $q(x)$, but it is applied to a source with a distribution $p(x)$, then the resulting average codeword length is equal to the cross-entropy (used in MachLearn field): $L = \mathbb{E}_p[q] = - \sum p(x) \log q(x)$
\end{mytextcol}
\\
Optimal code for i.i.d.\,sequences: &
\bm{X} = (X_1,\cdots,X_n); \quad \bm{x} \xmapsto[]{\text{Huff}_n}
\bm{y}; \quad |\bm{y}| = \ell^{(n)}_{\bm{x}}; \quad L^{(n)} = \mathbb{E}[\ell^{(n)}_{\bm{x}}]
\\&
H(X_1,\cdots X_n) \le L^{(n)} \le H(X_1,\cdots X_n) + 1
\\&
\xRightarrow[]{\text{i.i.d}}
n\cdot H(X_1) \le L^{(n)} \le n\cdot H(X_1) + 1; \quad H(X) = H(X_1)
\\
Optimal $L$ for i.i.d.\,sequences: &
H(X) \le L \le H(X) + \frac{1}{n}
;\quad
\left[L=
\frac{\mathbb E[\ell_{\bm x}]}{n}=\frac{L^{(n)}}{n}\right]
\\&
\lim_{n\to \infty} L = H(X) \quad \text{(length per symbol $L$ is optimized as $n$ increases)}
\\
Optimal $L$ for ergodic processes: &
H(X_1,\cdots X_n) \le L^{(n)} \le H(X_1,\cdots X_n) + 1
\\&
\implies \frac{1}{n}\cdot H(X_1,\cdots X_n) \le L \le \frac{1}{n} \cdot H(X_1,\cdots X_n) + \frac{1}{n}
\\&
\implies \boxed{\lim_{n\to \infty} L = H_\infty(X)} \le H(X) = H(X_1) \\[-6pt]
&\begin{mytextcol}
Better than i.i.d.\\(cannot be attained by Huffman codes unless symbols are grouped)
\end{mytextcol}
\\\end{mytable}
\newpage
\section*{Universal compression/source coding}
A source code is universal if it can be constructed without knowledge of the statistics of the
source.
\begin{mytable}
LZ77 codeword: &
\bm y = (j,l,c); \text{ where:}\begin{cases}
j,&\text{match offset (in $S$, from the right)}\\
l,&\text{match length (can overlap $B$)}\\
c,&\text{character after the match (in $B$)}
\end{cases}
\\&
\begin{cases}
\text{no match }&\implies j=0,\, l=0,\, c=\text{``first char in $B$''}
\\
\text{match }&\implies j>0,\, l>0
\end{cases}
\\[-4pt]&
\text{If match, advance buffers
$l+1$
chars (otherwise: $1$ char)}
\\[-4pt]
LZ77 codeword length: &
\ell_{\bm y} = \ell((j,l,c)) =
\lceil \log(S+1) \rceil +
\lceil \log(B+1) \rceil +
|c|
\\[-8pt]
& |c| = \lceil \log k \rceil \text{; when }c\in \text{``ASCII 8-bit'', }|c| = \log_2 2^8 =8 \text{ bits}
\\
LZ77 total compressed size: &
\underbrace{S \cdot |c|}_\text{initial buffer} + \sum_i \ell_{\bm{y}_i} = {S \cdot |c|} + N_{cw} \cdot \ell_{\bm{y}}, \quad N_{cw} = \text{num.\,of codewords}
\\
LZSS codeword: &
\bm y = \begin{cases}
(0,j,l),&\text{match}\\
(1, c),&\text{no match}\\
\end{cases}
; \text{ where:}\begin{cases}
j,&\text{match offset (never $0$)}\\
l,&\text{match length (never $0$)}\\
c,&\text{first char in $B$}
\end{cases}
\\[-4pt]&
\text{If match, advance buffers $l$ chars (otherwise: $1$ char)}
\\
LZSS codeword length: & \ell_{\bm{y}} =
\begin{cases}
\text{match:} &
1 + \lceil \log(S+1) \rceil +
\lceil \log(B+1) \rceil
\\
\text{no match:} &
1 + |c|
\end{cases}
\\
LZSS total compressed size: &
\underbrace{S \cdot |c|}_\text{initial buffer} + \sum_i \ell_{\bm{y}_i} =
S \cdot |c| +
N_\text{match} \cdot \ell_{\text{match}} +
N_\text{no-match} \cdot \ell_{\text{no-match}}
\\
LZ78: & [...] \text{Dictionary} [...]
\\
LZW: & [...] \text{Dictionary with preinitialization (usually with the 1-char entries)} [...]
\end{mytable}
\newpage
\section*{Asymptotic Equipartition Property or Principle (AEP)}
\begin{mytable}
AEP concept: &
\begin{mytextcol}
There exists some class/set of sequences $A_\varepsilon^{(n)}$ of length $n$ called \emph{typical} such that, as $n$ increases ($n\to\infty$), they become almost sure ($P\to 1$), and, at the same time, they remain a negligible portion (as $\varepsilon\to 0$) of the total set of sequences of length $n$, $\mathcal X^{(n)}$, with the only exception of the sequence generated by the uniform distribution with support $\mathcal X$.\\
Incidentally, sequences that are individually the most probable tend not to be in $A_\varepsilon^{(n)}$, i.e. are \emph{atypical} (same for the \emph{least} probable ones).
\\
The typical sequences are defined as precisely those that enable the convergence to $H(X)$ using Weak LLN (i.e.\@ convergence in probability).
% TODO: It also happens that those sequences tend to not contain
% the most probable words nor the least probable words.
% (see Sergio Verdú video).
\end{mytextcol}
\\
Sequence of $n$ i.i.d.\@ RVs: &
\begin{mytextcol}
``$\bm X$ is i.i.d'' means the sequence of $n$ RVs $\bm X = (X_1, X_2, \cdots, X_i, \cdots, X_n)$\\ with $\bm X \in \mathcal{X}^n$ has the property: $X_{i}, X_{j}$ are i.i.d., $\forall i,j; i \neq j$\\ (i.e.\@ pairwise i.i.d.)
\end{mytextcol}
\\
Set of $\varepsilon$-typical sequences for i.i.d.\@ RVs: &
\text{Given a sequence $\bm X$ of $n$ i.i.d.\@ $n$ RVs, for each and $\varepsilon>0$ define:}
\\[-8pt]&
A_\varepsilon^{(n)} (X) = \left\{
\bm x = (x_1,x_2,\cdots,x_n):
\,
\left|
-\frac{1}{n}\log p_{\bm X}(\bm x)-H(X)
\right|\le \varepsilon
\right\} =
\\&
A_\varepsilon^{(n)} (X) = \left\{
\bm x = (x_1,\cdots,x_n):
\,
2^{-n\cdot(H(X)+\varepsilon)}
\le p_{\bm{X}}(\bm x)
\le
2^{-n\cdot(H(X)-\varepsilon)}
\right\}
\\
AEP (Weak LLN redux): &
\text{Because $\bm X$ are i.i.d.:}\, -\frac{1}{n}\log p_{\bm X}(\bm X) =
-\frac{1}{n}\log \prod_{i} p_{X}(X_i) \stackrel[n\to\infty]{P}{\longrightarrow} H(X)
\\&
\forall\varepsilon>0,\, \exists n_0:\, \forall n>n_0 \implies
P(``\bm x \in A_\varepsilon^{(n)} (X) ") \ge 1-\varepsilon
\\&
\text{Main idea: } \underset{(n,\,\varepsilon)\to(\infty,\,0^+)}{\text{lim}^*}\, P(``\bm x \in A_\varepsilon^{(n)} (X) ") = 1
\\[-0.3cm]&\text{\footnotesize{${}^*$Note: this is not actually a limit...}}
\\[-0.3cm]&
\begin{mytextcol}
Also we have (as $\varepsilon\to 0$): $p_{\bm X}(\bm x)|_{\bm x\in A_\varepsilon^{(n)}}
\approx 2^{-n H(X)};\quad p_{\bm X}(\bm x)|_{\bm x\notin A_\varepsilon^{(n)}} \approx 0$
\\ (i.e.\@ sequences inside the typical set tend to be equiprobable and sequences outside of it tend to be impossible)
\end{mytextcol}
\\
Size of $A^{(n)}_\varepsilon (X)$ is negligible: &
(1-\varepsilon)\cdot 2^{n\cdot (H(X)-\varepsilon)}
\le
|A_\varepsilon^{(n)} (X)|
\le
2^{n\cdot (H(X)+\varepsilon)},\, \forall n\ge n_0
\\&
\implies \underset{(n,\,\varepsilon)\to(\infty,\,0^+)}{\text{lim}^*}\frac{|A_\varepsilon^{(n)} (X)|}{|\mathcal{X}^{n}|} =
\lim_{n\to\infty}\frac{2^{n\cdot H(X)}}{2^{n\cdot \log_2 |\mathcal{X}|}} =
\begin{cases}
1, &\text{ if $X$ is uniform} \\
0 ?, &\text{ otherwise}
\end{cases}
\\[12pt]
AEP generalizations: &
\text{AEP holds for \emph{any} $\bm X$}
\begin{cases}
\text{i.i.d.} & \text{as shown here} \\
\text{independent} & \text{not shown here} \\
\text{ergodic} & \text{using next definition of $A_\varepsilon^{(n)}$} \\
\end{cases}
\\
$A_\varepsilon^{(n)}$ for ergodic $\bm X$: &
A_\varepsilon^{(n)} (X) = \left\{\bm x = (x_1,x_2,\cdots,x_n):
\,
\left|
-\frac{1}{n}\log p_{\bm X}(\bm x)-H_\infty(X)
\right|\le \varepsilon
\right\}
\\
Set of jointly $\varepsilon$-typical sequences: &
A_\varepsilon^{(n)} (X,Y) =
\left\{(\bm x,\bm y):
\,
\bm x \in A_\varepsilon^{(n)} (X),\,
\bm y \in A_\varepsilon^{(n)} (Y)
\right\} \cap
\newline\phantom{MMMMMM}
\cap\left\{(\bm x,\bm y):
\,
\left|
-\frac{1}{n}\log p_{\bm{XY}}(\bm{xy})-H(X,Y)
\right|\le \varepsilon
\right\}
\\
$A_\varepsilon^{(n)} (X,Y)$ is defined for:&
\text{i.i.d.\,$\bm X$ and i.i.d.\,$\bm Y$ (but $\bm X,\bm Y$ could be jointly not i.i.d.)}
\\
Properties of $A_\varepsilon^{(n)} (X,Y)$: &
\text{AEP: }
P
\left((\bm{x},\bm{y}) \in A_\varepsilon^{(n)} (X,Y)
\right) \ge 1-\varepsilon,
\,\, \forall n\ge n_0
\,\, \forall \varepsilon>0
\\ &
(1-\varepsilon)\cdot 2^{n\cdot (H(X,Y)-\varepsilon)}
\le
\left|
A_\varepsilon^{(n)} (X,Y)
\right|
\le
2^{n\cdot (H(X,Y)+\varepsilon)},\, \forall n\ge n_0
\\
When $\bm X \indep \bm Y$:&
(1-\varepsilon)\cdot 2^{-n\cdot (H(X,Y)+3\cdot\varepsilon)}
\le
P\left(
(\bm x,\bm y)\in A_\varepsilon^{(n)} (X,Y)
\right)
\le
2^{-n\cdot (H(X,Y)-3\cdot\varepsilon)}
\\[-12pt]&
\forall n\ge n_0. \quad \text{Meaning of }\text{``}\bm X \indep \bm Y \text{'' here}
%\Longleftrightarrow
:\quad
p_{\bm{XY}}(\bm x,\bm y)
= p_{\bm{X}}(\bm x)\cdot p_{\bm{Y}}(\bm y)
% \\[-10pt]&
\end{mytable}
\section*{Source Coding Theorem}
\begin{mytable}
Source Coding Theorem for i.i.d.\@$\bm X$: & \forall \delta >0,\, \exists n_0 \text{ s.t. }
n\ge n_0 \implies \boxed{ \frac{L^{(n)}}{n} \le H(X) + \delta}
\\[-8pt]&
\begin{mytextcol}
assuming i.i.d.\@ sequences of $n$ RVs $\bm X = (X_1, X_2, \cdots,X_i,\cdots, X_n)$ and $L^{(n)} = \mathbb E [\ell_{
\bm x}]$ for some source code that is guaranteed to exist.
\end{mytextcol}
\\[8pt]
Proposed optimal source code:&
\begin{mytextcol}
Given $\varepsilon$ and $n$, add prefix bit $1$ if $\bm x\in A_\varepsilon^{(n)}$ or $0$ otherwise.
Then, concatenate with index in set if $\bm x\in A_\varepsilon^{(n)}$ or with index in $\bm X$ otherwise.
\\[5pt]
With that, the resulting codeword lengths are:\\[3pt]
\end{mytextcol}
\\[16pt]&
\ell_{\bm x, \varepsilon} =
\begin{cases}
\text{if } \bm x \in A_\varepsilon^{(n)}, &
1 + \lceil \log |A_\varepsilon^{(n)} | \rceil \underset{\text{(AEP)}}{\le}
2 + n (H(X)+\varepsilon)
\\
\text{if }\bm x \notin A_\varepsilon^{(n)}, &
1 + \lceil \log k^n \rceil
\le
2 + n\log k
\\
\end{cases}
\\&
\text{for } \delta = \varepsilon \cdot (1+\log k) + \frac{2}{n} \text{,\, $L^{(n)}$ verifies the Source Coding Theorem.}
\\[-10pt]&\text{(this proves the \emph{achievability})}
\\
Source Coding Theorem for ergodic $\bm X$: &
\boxed{ \frac{L^{(n)}}{n} \le H_\infty(X) + \delta}
\quad\text{(just replace $H(X)$ with $H_\infty(X)$)}
\\
\end{mytable}
\section*{Channel Coding Theorem}
\begin{mytable}
Channel code definition: & \text{(See Channel Coding section)}
\\
Error probability (after decoding): & P_e = P(g(Y)\neq u | U=u) = P(
\widehat U\neq u | U=u), \, \widehat U = g(Y)
\\
Fano's lemma: &
H(U|\widehat U) \le h(P_e) + P_e \cdot \log (M-1),\, P_e = P(\widehat U \neq U)
\\[-4pt]
Properties of $H(U|\widehat U)$:
&
H(U|\widehat U) =