\documentclass[10pt, xcolor=x11names]{beamer}
%\usecolortheme{seagull}
\useoutertheme{infolines}
\usefonttheme[onlymath]{serif}
\setbeamertemplate{headline}[default]
\setbeamertemplate{navigation symbols}{}
\mode<beamer>{\setbeamertemplate{blocks}[rounded][shadow=true]}
\setbeamercovered{transparent}
%\setbeamercolor{block body example}{fg=blue, bg=black!20}

\usepackage[utf8]{inputenc}
\usepackage[]{csquotes}
\usepackage{amsmath}
\usepackage{tikz, wasysym}
\usepackage{graphicx}
\usetikzlibrary{automata,positioning}
\usepackage{hyperref}
\usepackage{amsfonts}
\usepackage{csquotes}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{positioning}
\usepackage{wrapfig}
\usepackage{pgfplots}
\usepackage{outlines}
\usepackage{mathtools}
\usepackage{xcolor}

%\usepackage{amsfonts}
%\usepackage{amssymb}
%\usepackage{makeidx}
%\usepackage{graphicx}

\usepackage{hyperref}
\author{Sven Fiergolla}
\title[Colloquium]{Improving Run Length Encoding through preprocessing}
\subtitle[short version]{}
\date{14. Januar 2020}
%\institute[Uni Trier]{Universität Trier}
%\logo{\includegraphics[scale=.25]{unilogo.pdf}}

%read the data to \dataA

\begin{document}

	\frame{\maketitle}
	\frame{\frametitle{}
	\tableofcontents
	}

\section{Introduction}
\frame{\frametitle{Run Length Encoding (RLE)}
	\begin{outline}
		\1 Employed in the transmission of analog television signals as far back as 1967 \cite{rle-patent}
		\1 Particularly well suited to palette-based bitmap images such as computer icons
	\end{outline}
}
\frame{\frametitle{Run Length Encoding (RLE) - binary RLE}
	assume $\Sigma = \{a,b\}$
	\only<1-2>{
		\[
			aaaaabbbbbbaaaaaa
		\]
		\visible<2->{
			\[
			a^5b^6a^6
			\]}}
	\only<3->{
		\only<3-8>{
			\[
			a^5b^6a^6
			\]}
		\only<9>{\[
			\overbrace{a^5b^6a^6}^{17 \:\:\: bit}
			\]}
		\visible<4->{
			\medskip \\
			assume $|\Sigma| = 2$ and runs start with $a$\\
			\visible<5->{
				set maximum run length to 7 ( $=3$ bits per run)\\
				\medskip
				\only<5>{
					\[
					566
					\]}
				\only<6>{
					\[
					\underbrace{5}_{101}66
					\]
				}
				\only<7>{
					\[
					\underbrace{5}_{101}\underbrace{6}_{110}6
					\]
				}
				\only<8>{
					\[
					\underbrace{5}_{101}\underbrace{6}_{110}\underbrace{6}_{110}
					\]
				}

				\only<9->{
					\[
					\overbrace{\underbrace{5}_{101}\underbrace{6}_{110}\underbrace{6}_{110}}^{9 \:\:\: bit}
					\]
}}}}}

\frame{\frametitle{Run Length Encoding (RLE) - binary RLE}
	assume $\Sigma = \{a,b\}$
	\only<1-2>{
		\[
		aabaabbabbbababaabb
		\]
		\visible<2->{
			\[
			a^2b^1a^2b^2a^1b^3a^1b^1a^1b^1a^2b^2
			\]}}
	\only<3->{
		\only<3-9>{
		\[
		a^2b^1a^2b^2a^1b^3a^1b^1a^1b^1a^2b^2
		\]}
		\only<10>{\[
			\overbrace{a^2b^1a^2b^2a^1b^3a^1b^1a^1b^1a^2b^2}^{19 \:\:\: bit}
			\]}
		\visible<4->{
			\medskip \\
			assume $|\Sigma| = 2$ and runs start with $a$\\
			\visible<5->{
				set maximum run length to 3 ( $=2$ bits per run)\\
				\medskip
				\only<5>{
					\[
					212213111122
					\]}
				\only<6>{
					\[
					\underbrace{2}_{10}12213111122
					\]
				}
				\only<7>{
					\[
					\underbrace{2}_{10}\underbrace{1}_{01}2213111122
					\]
				}
				\only<8>{
					\[
					\underbrace{2}_{10}\underbrace{1}_{01}\underbrace{2}_{10}213111122
					\]
				}
				\only<9>{
					\[
					\underbrace{2}_{10}\underbrace{1}_{01}\underbrace{2}_{10}\underbrace{2}_{10}\underbrace{1}_{01}\underbrace{3}_{11}\underbrace{1}_{..}11122
					\]
}
				\only<10->{
	\[
	\overbrace{\underbrace{2}_{10}\underbrace{1}_{01}\underbrace{2}_{10}\underbrace{2}_{10}\underbrace{1}_{01}\underbrace{3}_{11}\underbrace{1}_{..}11122}^{24 \:\:\: bit}
	\]
}}}}}

\frame{\frametitle{Run Length Encoding (RLE) - binary RLE}
	assume $|\Sigma| = 2$ and runs start with $a$\\
	set maximum run length to 3 ( $=2$ bits per run / per RLE number)\\
	\only<1>{
		\[
		b^1a^5b^2
		\]
	}
	\only<2>{
		\[
		\underbrace{b^1}_{00 + 01}a^5b^2
		\]
	}
	\only<3>{
		\[
		\underbrace{b^1}_{00 + 01} \: \: \underbrace{a^5}_{11 + 00 + 10}b^2
		\]
	}

}

\frame{\frametitle{Run Length Encoding (RLE) - byte wise RLE}
	\only<2>{
	assume $|\Sigma| = 2^8$\\
	set maximum run length to 4 ( $=2$ bits per run / per RLE number)\\
}
	\only<3>{
		\[
		b^1a^2c^3
		\]
	}
	\only<4>{
		\[
		\underbrace{b^1}_{01100010 + 00}a^2c^4
		\]
	}
	\only<5>{
		\[
		\underbrace{b^1}_{01100010 + 00} \: \: \: \underbrace{a^2}_{01100001 + 01} \: \: \: \underbrace{c^3}_{01100011 + 11}
		\]
	}}

\frame{\frametitle{Run Length Encoding (RLE)}
	\begin{outline}
		\1 Used for bitmap images or DNA sequence encoding \cite{rle-dna} \cite{rle-bio}.
		\visible<2->{ \1 The International Telecommunication Union describes the standard to encode fax transmissions, known as T.45 \cite{fax-rle}.
		\2 RLE is combined with Huffman Encoding into \emph{Modified Huffman Encoding}.}
	\end{outline}
}

\frame{\frametitle{Huffman Encoding}
	\centering
	$\Sigma = \{a,b,c\}$\\
	$w = cacbcacc$\\
	\visible<2->{$l_a(w) = 2 \:\:\: l_b(w) = 1 \:\:\: l_c(w) = 5$}
	\visible<3->{
	\begin{figure}[h]
		\centering
		\begin{tikzpicture}
		\begin{scope}[every node/.style={circle,thick,draw=red}]
		\visible<4->{\node (B) at (1.25,2) {3};}
		\visible<5->{\node (C) at (2.5,4) {8};}
		\end{scope}
		\begin{scope}[every node/.style={circle,thick,draw=green}]
		\node (A) at (0,0) {a,2};
		\node (D) at (2.5,0) {b,1};
		\node (F) at (5,0) {c,5} ;
		\end{scope}

		\begin{scope}[>={Stealth[black]},
		every node/.style={fill=white,circle}]
		\visible<4->{\path [->] (A) edge node {$0$} (B);}
		\visible<5->{\path [->] (B) edge node {$0$} (C);}
		\visible<4->{\path [->] (D) edge node {$1$} (B);}
		\visible<5->{\path [->] (F) edge node {$1$} (C);}

		\end{scope}
		\end{tikzpicture}
		\caption{Example Huffman tree with 3 leaf nodes.} \label{fig:M1:example Huffman tree}
	\end{figure}
}
\visible<6->{$a = 00 \:\:\: b = 01 \:\:\: c = 1$}
}

\frame{\frametitle{Modified Huffman Encoding T.45}
	\begin{table}
		\centering
		\begin{tabular}[p]{r|c|c}
			run length &  white run Huffman codes & black run Huffman codes\\
			\hline
			0 &  00110101 & 0000110111\\
			1 & 000111 & 010\\
			2 & 0111 & 11\\
			3 & 1000 & 10\\
			4 & 1011 & 011\\
			... &  & \\
			20 & 0001000 & 00001101000\\
			... & & \\
			64+ & 11011 & 0000001111\\
			128+ & 10010 & 000011001000
			\label{tab:t1:static huffman codes}
		\end{tabular}
		\caption{T4 static Huffman codes.}
	\end{table}
	\only<2>{
		\[
		\underbrace{1111}_{2} \rightarrow `11`
		\]}
	\only<3->{
		\[
		0^{132} \rightarrow `10010` + `1011`
		\]}
}

\frame{\frametitle{Run Length Encoding (RLE)}
	\begin{table}[H]
		\centering
		\begin{tabular}{r|r|r|r|r|r}
			file & size original & bits per run & size encoded & ratio in \% & \textit{bps}\\
			\hline
			pic & 513216 & 2 & 350292 & 68.25 & 5.46 \\
			& & 3 & 235067 & 45.80 & 3.66\\
			& & 4 & 165745 & 32.29 & 2.58\\
			& & 5 & 126349 & 24.61 & 1.96\\
			& & 6 & 106773 & 20.80 & 1.66\\
			& & 7 & 100098 & 19.50 & 1.56\\
			& & 8 & 101014 & 19.68 & 1.57\\
		\end{tabular}
		\caption{The bitmap image file \textit{pic} with increasing bits per binary RLE encoded number.}
		\label{tab:t40 The file pic with increasing bits per RLE encoded number}
	\end{table}
	\begin{itemize}
		\visible<2->{\item Byte-wise RLE achieves $27.2\%$ of its original size using 2.17 \textit{bps} with 6 bits per run.}
	\end{itemize}
}

\frame{\frametitle{Calgary Corpus}
	\begin{table}[H]
		\centering
		\begin{tabular}{l|r|l}
			file & size & description\\
			\hline
			bib & 111261 & ASCII text - 725 bibliographic references\\
			book1 & 768771 & unformatted ASCII text\\
			book2 & 610856 & ASCII text in UNIX \enquote{troff} format\\
			geo & 102400 & 32 bit numbers in IBM floating point format\\
			news & 377109 & ASCII text - USENET batch file on a variety of topics\\
			obj1 & 21504 & VAX executable program \\
			obj2 & 246814 &	Macintosh executable program \\
			paper1 & 53161 & UNIX \enquote{troff} format \\
			paper2 & 82199 & UNIX \enquote{troff} format \\
			pic & 513216 & 1728 x 2376 bitmap image\\
			progc & 39611 & Source code in C \\
			progl & 71646 &  Source code in Lisp\\
			progp & 49379 & Source code in Pascal\\
			trans & 93695 & ASCII and control characters\\
		\end{tabular}
		\caption{The Calgary Corpus.}
		\label{tab:t05 The Calgary Corpus}
	\end{table}
}

\frame{\frametitle{RLE - Unmodified compression on the Calgary Corpus}
	\begin{table}[h]
		\centering
		\begin{tabular}{l|r|r||r|r}
			bits per rle number & \multicolumn{2}{c}{byte-wise RLE} & \multicolumn{2}{c}{binary RLE} \\
			&  ratio in \% & \textit{bps} & ratio in \% & \textit{bps}\\
			\hline
			8 & 165 & 13.20 & 329 & 26.38\\
			7 & 154 & 12.38 & 288 & 23.11\\
			6 & 144 & 11.57 & 248 & 19.87 \\
			5 & 134 & 10.77 & 208 & 16.66\\
			4 & 125 & 10.00 & 168 & 13.51\\
			3 & 116 & 9.29 & 131 & 10.50\\
			2 & 109 & 8.74 & 104 & 8.36
		\end{tabular}
		\caption{Byte-wise and binary RLE on the Calgary Corpus.}
		\label{tab:t31 Byte-wise RLE on the Calgary Corpus}
	\end{table}
}

\frame{\frametitle{Findings}
	\begin{outline}
		\1 Files with long runs work really well with RLE.
		\visible<2->{\1 Most files other than pallet based images do not contain long runs of identical bit values.}
		\medskip
		\visible<3->{\1 Artificially creating runs on arbitrary data will improve the performance of RLE.}
	\end{outline}
}

\section{Basics}
\frame{\frametitle{Basics of Compression}
	\begin{itemize}
		\item Non random data contains redundant information
		\item Compression is about pattern or structure identification and exploitation

		\visible<2->{  \item No algorithm can compress all possible data of a given length, even by one byte (Kolmogorov Complexity \cite{kolmogorov})}
	\end{itemize}
}

\frame{\frametitle{Basics of Compression - Entropy Encoding}
	\begin{itemize}
		\item generating a probability model for the data
		\item compute variable length codes
		\visible<2->{ \item low speed, high compression strength
		\item recommended for poorly structured data}
	\end{itemize}
}

\frame{\frametitle{Basics of Compression - Entropy Encoding}
\begin{outline}
		\1 Huffman Encoding (1952)
		\2 computes optimal length prefix-free codes for symbols acc. to their probabilities
		\visible<2->{ \1 Run Length Encoding (1967) \2 computes runs of identical symbols}
		\visible<3->{ \1 Arithmetic Encoding (1979) \2 encodes a message of symbols in a single rational number in [0,1]}
		\visible<4->{\1 Asymmetric Numeral Systems (ANS) Encoding (2014) \2 encodes a message of symbols in a single natural number}
\end{outline}
}

\frame{\frametitle{Basics of Compression - Dictionary Encoding}
	\begin{outline}
		\1 maintain a dictionary of strings for either a \emph{sliding window} or the whole data
		\2 replace later occurrence with reference position an length
		\visible<2->{ \1 High speed, moderate compression strength}
		\visible<3->{ \1 Famous Lempel-Ziv methods LZ77 and LZ78 (1977/78) \2 many derivatives, some still used today}
	\end{outline}
}

\frame{\frametitle{State of the art}
	\begin{table}[h]
	\begin{tabular}{r|r|r|r|r}
		method & options &  size in bytes & compression & \textit{bps}\\
		\hline
		uncompressed & & 3,145,718 & 100.0\% & 8.00 \\
		compress 4.2.4 & & 1,250,382 & 40.4\% & 3.24 \\
		gzip v1.10 & -9 & 1,021,720 & 32.4\% & 2.60\\
		ZIP v3.0 &-9& 1,019,783 & 32.4\% & 2.59 \\
		zstandard 1.4.2& --ultra-23 -long=30 & 887,004 & 28.1\% & 2.25\\
		bzip2 v1.0.8 & --best & 832,443 & 26.4\% & 2.11 \\
		brotli 1.0.7 & -q 11 -w 24 & 826,638 & 26.3\%& 2.10\\
		p7zip 16.02 (deflate) & a -mx10 & 821,873 & 26.1\% & 2.08 \\
		p7zip 16.02 (PPMd) & a -mm=ppmd o=32 & 763,067& 24.2\% & 1.93 \\
		ZPAQ v7.15 & -m5 & 659,700 & 20.9\% & 1.67  \\
		paq8hp* & - & - & - & - \\
		cmix v18 & -c -d & 554,983 & 17.6\% & 1.41
	\end{tabular}
	\label{tab:t20 stat of the art}
	\caption{State of the art compression ratios on the Calgary Corpus.}
\end{table}
}

\section{Design}
\frame{\frametitle{Design - Preprocessing}
	\begin{outline}
		\1 Vertical interpretation
		\visible<2->{\1 Dynamic byte remapping}
		\visible<3->{\1 Burrows-Wheeler-Transformation}
		\visible<4->{\1 Huffman Encoding of RLE runs}
	\end{outline}
}

\frame{\frametitle{Preprocessing - Vertical interpretation}
	\includegraphics[height=\textheight, width=\textwidth]{g0902.png}
}

\frame{\frametitle{Preprocessing - Vertical interpretation}
		\[
			w = abraca
		\]
	\only<1>{\textcolor{red}{0} 1 1 0 0 0 0 1 0 1 1 0 0 0 1 0 0 1 1 1 0 0 1 0 0 1 1 0 0 0 0 1 0 1 1 0 0 0 1 1}
	\only<2>{0 \textcolor{red}{1} 1 0 0 0 0 1 0 1 1 0 0 0 1 0 0 1 1 1 0 0 1 0 0 1 1 0 0 0 0 1 0 1 1 0 0 0 1 1}
	\only<3>{0 1 \textcolor{red}{1} 0 0 0 0 1 0 1 1 0 0 0 1 0 0 1 1 1 0 0 1 0 0 1 1 0 0 0 0 1 0 1 1 0 0 0 1 1}
	\only<4>{0 1 1 \textcolor{red}{0} 0 0 0 1 0 1 1 0 0 0 1 0 0 1 1 1 0 0 1 0 0 1 1 0 0 0 0 1 0 1 1 0 0 0 1 1}
}

\frame{\frametitle{Preprocessing - Vertical interpretation}
	\only<1>{
\begin{equation}
\begin{multlined}
	w = abraca\\
		\textcolor{red}{0} 1 1 0 0 0 0 1 \\
		0 1 1 0 0 0 1 0 \\
		0 1 1 1 0 0 1 0 \\
		0 1 1 0 0 0 0 1 \\
		0 1 1 0 0 0 1 1 \\
		0 1 1 0 0 0 0 1 \\
\end{multlined}
\end{equation}
}
	\only<2>{
	\begin{equation}
	\begin{multlined}
	w = abraca\\
	0 1 1 0 0 0 0 1 \\
	\textcolor{red}{0} 1 1 0 0 0 1 0 \\
	0 1 1 1 0 0 1 0 \\
	0 1 1 0 0 0 0 1 \\
	0 1 1 0 0 0 1 1 \\
	0 1 1 0 0 0 0 1 \\
	\end{multlined}
	\end{equation}
}

	\only<3>{
	\begin{equation}
	\begin{multlined}
	w = abraca\\
	0 1 1 0 0 0 0 1 \\
	0 1 1 0 0 0 1 0 \\
	\textcolor{red}{0} 1 1 1 0 0 1 0 \\
	0 1 1 0 0 0 0 1 \\
	0 1 1 0 0 0 1 1 \\
	0 1 1 0 0 0 0 1 \\
	\end{multlined}
	\end{equation}
}

	\only<4>{
	\begin{equation}
	\begin{multlined}
	w = abraca\\
	0 1 1 0 0 0 0 1 \\
	0 1 1 0 0 0 1 0 \\
	0 1 1 1 0 0 1 0 \\
	\textcolor{red}{0} 1 1 0 0 0 0 1 \\
	0 1 1 0 0 0 1 1 \\
	0 1 1 0 0 0 0 1 \\
	\end{multlined}
	\end{equation}
}
	\only<5>{
	\begin{equation}
	\begin{multlined}
	w = abraca\\
	0 1 1 0 0 0 0 1 \\
	0 1 1 0 0 0 1 0 \\
	0 1 1 1 0 0 1 0 \\
	0 1 1 0 0 0 0 1 \\
	\textcolor{red}{0} 1 1 0 0 0 1 1 \\
	0 1 1 0 0 0 0 1 \\
	\end{multlined}
	\end{equation}
}

	\only<6>{
	\begin{equation}
	\begin{multlined}
	w = abraca\\
	0 1 1 0 0 0 0 1 \\
	0 1 1 0 0 0 1 0 \\
	0 1 1 1 0 0 1 0 \\
	0 1 1 0 0 0 0 1 \\
	0 1 1 0 0 0 1 1 \\
	\textcolor{red}{0} 1 1 0 0 0 0 1 \\
	\end{multlined}
	\end{equation}
}
	\only<7>{
	\begin{equation}
	\begin{multlined}
	w = abraca\\
	0 \textcolor{red}{1} 1 0 0 0 0 1 \\
	0 1 1 0 0 0 1 0 \\
	0 1 1 1 0 0 1 0 \\
	0 1 1 0 0 0 0 1 \\
	0 1 1 0 0 0 1 1 \\
	0 1 1 0 0 0 0 1 \\
	\end{multlined}
	\end{equation}
}

	\only<8>{
	\begin{equation}
	\begin{multlined}
	w = abraca\\
	0 1 1 0 0 0 0 1 \\
	0 \textcolor{red}{1} 1 0 0 0 1 0 \\
	0 1 1 1 0 0 1 0 \\
	0 1 1 0 0 0 0 1 \\
	0 1 1 0 0 0 1 1 \\
	0 1 1 0 0 0 0 1 \\
	\end{multlined}
	\end{equation}
}
}

\frame{\frametitle{Preprocessing - Vertical interpretation}
	\begin{table}[H]
		\centering
		\begin{tabular}{r|r|r}
			bits per rle number & ratio in \% & \textit{bps}\\
			\hline
			8 & 255.22 & 20.41\\
			7 & 224.45 & 17.95\\
			6 & 194.74 & 15.57\\
			5 & 167.04 & 13.36\\
			4 & 142.58 & 11.40\\
			3 & 127.80 & 10.22\\
			2 & 139.79 & 11.18 \\
		\end{tabular}
		\caption{Binary RLE on vertical interpreted data, fixed run lengths.}
		\label{tab:t30 binary RLE on vertical interpreted data}
	\end{table}
}

\frame{\frametitle{Preprocessing - Vertical interpretation}
	\[
		w = abraca
	\]
	\only<1>{
	\centering
	\begin{math}
\begin{array}{l}
0 1 1 0 0 0 0 1 \\
0 1 1 0 0 0 1 0 \\
0 1 1 1 0 0 1 0 \\
0 1 1 0 0 0 0 1 \\
0 1 1 0 0 0 1 1 \\
0 1 1 0 0 0 0 1\\
\end{array}
\end{math}
}
\only<2>{
	\centering
	\begin{math}
	\text{8 bit per run}
	\left\{
	\begin{array}{l}
	\left.
	\begin{array}{l}
	0 1 1 0 0 0 0 1 \\
	\end{array}
	\right \} 	\text{2 bits per run}\\
	\left.
	\begin{array}{l}
	0 1 1 0 0 0 1 0 \\
	0 1 1 1 0 0 1 0 \\
	\end{array}
	\right \} 	\text{2 bits per run}\\
	\left.
	\begin{array}{l}
	0 1 1 0 0 0 0 1\\
	0 1 1 0 0 0 1 1 \\
	0 1 1 0 0 0 0 1\\
	\end{array}
	\right \} 	\text{2 bits per run}\\
	\end{array}
	\right.
	\end{math}
}
}

\frame{\frametitle{Preprocessing - Vertical interpretation}
\begin{figure}[h]
	\begin{tikzpicture}
	\begin{axis}[
	width=\textwidth,
	height=0.45\textwidth,
	axis x line=center,
	axis y line=left,
	xlabel={bits per run},
	ylabel={Compression ratio},
	symbolic x coords = {22222222,33333333,44444444,22223436,22223437,22223438,22223439,22233578,22233579,222335710},
	x tick label style={font=\small,text width=1cm,align=center},
	xtick=data,
	x label style={at={(axis description cs:0.5,-0.1)},anchor=north},
	enlargelimits=true,
	ymax=145,
	legend style={
		at={(0.5,1.2)},
		anchor=north,
		legend columns=-1,
		/tikz/every even column/.append style={column sep=0.5cm}
	},
	ymajorgrids=true,
	grid style=dashed,
	ybar]
	\addplot[color=blue,fill]
	coordinates {
		(22222222,139)(33333333,127)(44444444,142)(22223436,112.55)(22223437,112.4)(22223438,112.6)(22223439,113)
	};
	\end{axis}
	\end{tikzpicture}
	%}
	%\end{scaletikzpicturetowidth}
	\caption{Byte mapping and varying maximum run lengths.}
	\label{fig:2:Byte mapping and varying maximum run lengths}
\end{figure}
}

\frame{\frametitle{Preprocessing - Vertical interpretation}
\begin{table}[h]
	\centering
	\begin{tabular}{r|r|r|r|r}
		file & size original & size encoded & ratio in \% & \textit{bps}\\
		\hline
		bib & 111261 & 129424 & 116.32 & 9.31 \\
		book1 & 768771 & 820463 & 106.72 & 8.54 \\
		book2 & 610856 & 659811 & 108.01 & 8.64 \\
		geo & 102400 & 162274 & 158.47 & 12.68 \\
		news & 377109 & 400810 & 106.28 & 8.50 \\
		obj1 & 21504 & 31592 & 146.91 & 11.75 \\
		obj2 & 246814 & 379591 & 153.80 & 12.30 \\
		paper1 & 53161 & 57654 & 108.45 & 8.68 \\
		paper2 & 82199 & 88121 & 107.20 & 8.58 \\
		pic & 513216 & 533254 & 103.90 & 8.31 \\
		progc & 39611 & 41360 & 104.42 & 8.35 \\
		progl & 71646 & 74554 & 104.06 & 8.32 \\
		progp & 49379 & 53403 & 108.15 & 8.65 \\
		trans & 93695 & 99818 & 106.54 & 8.52 \\
		\hline
		all files & 3145718 & 3536225 & 112.41 & 8.99
	\end{tabular}
	\caption{Calgary Corpus encoded, vertical encoding, using bits per run (2, 2, 2, 2, 3, 4, 3, 7).}
	\label{tab:t50:Calgary Corpus encoded, vertical encoding, using bits per run: (2, 2, 2, 2, 3, 4, 3, 7)}
\end{table}
}

\frame{\frametitle{Preprocessing}
	\only<1>{
	\begin{columns}
		\begin{column}{0.40\textwidth}
			Current preprocessing steps:
		\end{column}
		\begin{column}{0.60\textwidth}
			\begin{center}
				\begin{tikzpicture}[
				every node/.style = {shape=rectangle,% is not necessary, default node's shape is rectangle
					draw=cyan, semithick,
					text width=0.8\linewidth,
					align=center}
				]
				\node (pq2) [] {Vertical Interpretation};
				\node (pq3) [dashed,below=of pq2] {Run Length Encoding};
				%
				\path[->,thick,cyan]
				(pq2) edge  (pq3);
				\end{tikzpicture}
			\end{center}
		\end{column}
	\end{columns}}
\only<2>{
	\begin{columns}
		\begin{column}{0.40\textwidth}
			Current preprocessing steps:
		\end{column}
		\begin{column}{0.60\textwidth}
			\begin{center}
				\begin{tikzpicture}[
				every node/.style = {shape=rectangle,% is not necessary, default node's shape is rectangle
					draw=cyan, semithick,
					text width=0.8\linewidth,
					align=center}
				]
				\node (pq1) [draw] {Byte Remapping};
				\node (pq2) [below=of pq1] {Vertical Interpretation};
				\node (pq3) [dashed,below=of pq2] {Run Length Encoding};
				%
				\path[->,thick,cyan]
				(pq2) edge  (pq3)
				(pq1) edge  (pq2);
				\end{tikzpicture}
			\end{center}
		\end{column}
\end{columns}}
}

\frame{\frametitle{Preprocessing - Byte Remapping}
	\centering
	\begin{math}
\begin{array}{l}
	w = abracab 	\medskip \\
	0 1 1 0 0 0 0 1 \\
	0 1 1 0 0 0 1 0 \\
	0 1 1 1 0 0 1 0 \\
	0 1 1 0 0 0 0 1 \\
	0 1 1 0 0 0 1 1 \\
	0 1 1 0 0 0 0 1 \\
	0 1 1 0 0 0 1 0 \\
\end{array}
\end{math}
\visible<2->{
	\[
	l_a(w)=3 \:\:\: l_b(w)=2 \:\:\: l_c(w)=1 \:\:\: l_r(w)=1
	\]
}
\visible<3->{Mapping:
\[
a = 0x00 \:\:\: b = 0x01 \:\:\: c = 0x02 \:\:\: r = 0x03
\]
}
}

\frame{\frametitle{Preprocessing - Byte Remapping}
	\centering
	\only<1>{
	\begin{math}
\begin{array}{l}
	w = abraca\\
	0 0 0 0 0 0 0 0 \\
	0 0 0 0 0 0 0 1 \\
	0 0 0 0 0 0 1 1 \\
	0 0 0 0 0 0 0 0 \\
	0 0 0 0 0 0 1 0 \\
	0 0 0 0 0 0 0 0 \\
	0 0 0 0 0 0 0 1 \\
\end{array}
\end{math}
}
\only<2>{
	\begin{math}
\begin{array}{l}
w = abraca\\
0 0 0 0 0 0 0 0 \\
0 0 0 0 0 0 0 1 \\
0 0 0 0 0 0 1 1 \\
0 0 0 0 0 0 0 0 \\
0 0 0 0 0 0 1 0 \\
0 0 0 0 0 0 0 0 \\
\underbrace{0 0 0 0 0 0}_{} 0 1\\
\end{array}
\end{math}
\begin{outline}
	\1 increased average run length on bits of higher significance
\end{outline}

}}

\frame{\frametitle{Preprocessing - Byte Remapping}
	\begin{figure}[h]
		\begin{tikzpicture}
		\begin{axis}[
		width=\textwidth,
		height=0.45\textwidth,
		axis x line=center,
		axis y line=left,
		xlabel={bits per run},
		ylabel={Compression ratio},
		symbolic x coords={22223436,22223437,22223438,22223439,22233578,22233579,222335710},
		x tick label style={font=\small,text width=1cm,align=center},
		xtick=data,
		x label style={at={(axis description cs:0.5,-0.1)},anchor=north},
		enlargelimits=true,
		ymax=115,
		legend style={
			at={(0.5,1.2)},
			anchor=north,
			legend columns=-1,
			/tikz/every even column/.append style={column sep=0.5cm}
		},
		ymajorgrids=true,
		grid style=dashed,
		ybar]
		\addplot[color=blue,fill]
		coordinates {
			(22223436,112.55)(22223437,112.4)(22223438,112.6)(22223439,113)(22233578,113)(22233579,115)(222335710,116)
		};
		\addplot[color=red,fill]
		coordinates {
			(22223436,103.3)(22223437,102.6)(22223438,102.3)(22223439,102.25)(22233578,95)(22233579,94.9)(222335710,95)
		};
		\legend{vertical encoding,with byte mapping}
		\end{axis}
		\end{tikzpicture}
		%}
		%\end{scaletikzpicturetowidth}
		\caption{Byte mapping and varying maximum run lengths.}
		\label{fig:2:Byte mapping and varying maximum run lengths2}
	\end{figure}
}

\frame{\frametitle{Preprocessing - Byte Remapping}
\begin{table}[h]
	\centering
	\begin{tabular}{r|r|r|r|r}
		file & size original & size encoded & ratio in \% & \textit{bps}\\
		\hline
		bib & 111261 & 111579 & 100.29 & 8.02 \\
		book1 & 768771 & 669578 & 87.10 & 6.97 \\
		book2 & 610856 & 551757 & 90.33 & 7.23 \\
		geo & 102400 & 144974 & 141.58 & 11.33 \\
		news & 377109 & 363010 & 96.26 & 7.70 \\
		obj1 & 21504 & 30166 & 140.28 & 11.22 \\
		obj2 & 246814 & 340165 & 137.82 & 11.03 \\
		paper1 & 53161 & 50074 & 94.19 & 7.54 \\
		paper2 & 82199 & 71747 & 87.28 & 6.98 \\
		pic & 513216 & 408136 & 79.53 & 6.36 \\
		progc & 39611 & 38490 & 97.17 & 7.77 \\
		progl & 71646 & 63765 & 89.00 & 7.12 \\
		progp & 49379 & 46093 & 93.35 & 7.47 \\
		trans & 93695 & 94729 & 101.10 & 8.09 \\
		\hline
		all files & 3145718 & 2988359 & 94.99 & 7.59
	\end{tabular}
	\caption{Calgary Corpus encoded with vertical reading, byte remapping, using bits per run (2, 2, 3, 3, 3, 4, 5, 8).}
	\label{tab:t43 Calgary Corpus encoded with vertical reading, byte remapping and varying bits per run}
\end{table}
}

\frame{\frametitle{Preprocessing - Burrows-Wheeler-Transformation}

	\[
		w = abcabr
	\]

		\only<2>{
			\begin{table}[h]
				\centering
				\begin{tabular}{l|l|l|l|l|l}
					 a & b & c & a & b & r\\
					\hline
					r & a & b & c & a & b\\
					\hline
					b & r & a & b & c & a\\
					\hline
					a & b & r & a & b & c\\
					\hline
					c & a & b & r & a & b\\
					\hline
					b & c & a & b & r & a
						\label{tab:t10 bwt-example1}
				\end{tabular}
				\caption{Burrows Wheeler Transformation Matrix (all cyclic rotations).}
			\end{table}
		}
	\only<3>{
	\begin{table}[h]
		\centering
		\begin{tabular}{l|l|l|l|l|l}
			a & b & c & a & b & r\\
			\hline
			a & b & r & a & b & c\\
			\hline
			b & c & a & b & r & a\\
			\hline
			b & r & a & b & c & a\\
			\hline
			c & a & b & r & a & b\\
			\hline
			r & a & b & c & a & b
			\label{tab:t10 bwt-example2}
		\end{tabular}
		\caption{Burrows Wheeler Transformation Matrix (all cyclic rotations, sorted).}
	\end{table}
}
	\only<4>{
		\begin{table}[h]
			\centering
			\begin{tabular}{l|l|l|l|l|l}
				a & b & c & a & b & \textcolor{red}{r}\\
				\hline
				a & b & r & a & b &  \textcolor{red}{c}\\
				\hline
				b & c & a & b & r &  \textcolor{red}{a}\\
				\hline
				b & r & a & b & c &  \textcolor{red}{a}\\
				\hline
				c & a & b & r & a &  \textcolor{red}{b}\\
				\hline
				r & a & b & c & a &  \textcolor{red}{b}
				\label{tab:t10 bwt-example3}
			\end{tabular}
			\caption{Burrows Wheeler Transformation Matrix (all cyclic rotations, sorted).}
		\end{table}
		 \[
		 L = rcaabb
		 \]
		 \[
		 i = 1
		 \]
	}
}

\frame{\frametitle{Preprocessing - inverse Burrows-Wheeler-Transformation}
		 \[
		 L = rcaabb
		 \]
		 \[
		 i = 1
		 \]
		 \only<2>{
		 \begin{table}[h]
		 	\centering
		 	\begin{tabular}{l}
		 		word $L$\\
		 		\hline
		 		r  \\
		 		c  \\
		 		a \\
		 		a  \\
		 		b  \\
		 		b
		 		\label{tab:t11 standard permutation}
		 	\end{tabular}
		 	\caption{Standard permutation generation of the word $L$.}
		 \end{table}
		}
			 \only<3>{
		\begin{table}[h]
			\centering
			\begin{tabular}{l|l}
				word $L$& word with position\\
				\hline
				r & (r,1) \\
				c & (c,2)  \\
				a & (a,3) \\
				a & (a,4) \\
				b & (b,5)  \\
				b & (b,6)
				\label{tab:t11 standard permutation}
			\end{tabular}
			\caption{Standard permutation generation of the word $L$.}
		\end{table}
	}
		 \only<4>{
	\begin{table}[h]
		\centering
		\begin{tabular}{l|l|l}
			word $L$ & word with position & sorted\\
			\hline
			r & (r,1) & (a,3) \\
			c & (c,2) & (a,4) \\
			a & (a,3) & (b,5) \\
			a & (a,4) & (b,6) \\
			b & (b,5) & (c,2) \\
			b & (b,6) & (r,1)
			\label{tab:t11 standard permutation}
		\end{tabular}
		\caption{Standard permutation generation of the word $L$.}
	\end{table}
}
	 \only<5>{
	\begin{table}[h]
		\centering
		\begin{tabular}{l|l|l|l}
			word $L$ & word with position & sorted & $\pi^t_L$\\
			\hline
			r & (r,1) & (a,3) & 1 3\\
			c & (c,2) & (a,4) & 2 4\\
			a & (a,3) & (b,5) & 3 5\\
			a & (a,4) & (b,6) & 4 6\\
			b & (b,5) & (c,2) & 5 2\\
			b & (b,6) & (r,1) & 6 1
			\label{tab:t11 standard permutation}
		\end{tabular}
		\caption{Standard permutation generation of the word $L$.}
	\end{table}
}
}

\frame{\frametitle{Preprocessing - inverse Burrows-Wheeler-Transformation}
		 \[
		 L = rcaabb
		 \]
		 \[
		 i = 1
		 \]
	This yields a standard permutation of:
	\begin{gather}
	\pi_L =
	\begin{pmatrix} 1 & 2 & 3 & 4 & 5 & 6\\ 3 & 4 & 5 & 6 & 2 & 1 \end{pmatrix}
	\end{gather}
	\visible<2->{
	Following $\pi^1_L(1)$ to $\pi^6_L(1)$ :
	\begin{gather}
	3 \xrightarrow[]{\pi_L} 5 \xrightarrow[]{\pi_L} 2 \xrightarrow[]{\pi_L} 4 \xrightarrow[]{\pi_L} 6 \xrightarrow[]{\pi_L} 1
	\end{gather}}

	\visible<3->{
	Applying the sequence to the labeling function of the word $L$:
	\begin{gather}
	\lambda_L(3) \: \lambda_L(5) \: \lambda_L(2) \: \lambda_L(4) \: \lambda_L(6) \: \lambda_L(1)
	= abcabr = w
	\end{gather}}
}

\frame{\frametitle{Preprocessing - Burrows-Wheeler-Transformation}
		\begin{columns}
		\begin{column}{0.6\textwidth}
\only<2-3>{
\visible<2-3>{
	\begin{table}[h]
		\centering
		\begin{tabular}{r|r|r}
			bits per rle number & ratio in \% & \textit{bps}\\
			\hline
			3 & 95.41 & 7.63\\
			2 & 91.39 & 7.31 \\
		\end{tabular}
		\caption{Initial Burrows-Wheeler-Transformation implementation on byte wise RLE.}
		\label{tab:t11 Simple Burrows Wheeler Transformation on byte wise RLE}
\end{table}}
\visible<3-3>{
	\begin{table}[h]
		\centering
		\begin{tabular}{r|r|r}
			bits per rle number & ratio in \% & \textit{bps}\\
			\hline
			3 & 91.62 & 7.33\\
			2 & 89.46 & 7.15
		\end{tabular}
		\caption{Original Burrows-Wheeler-Transformation on byte wise RLE.}
		\label{tab:t12 Burrows Wheeler Transformation on byte wise RLE}
\end{table}}}
\only<4->{
	\begin{table}[h]
	\centering
	\begin{tabular}{r|r|r}
		bits per rle number & ratio in \% & \textit{bps}\\
		\hline
		8 & 74.42 & 5.95\\
		7 & 69.90 & 5.59\\
		6 & 65.58 & 5.24\\
		5 & 61.71 & 4.93\\
		4 & 58.98 & 4.71\\
		3 & 59.18 & 4.73\\
		2 & 67.69 & 5.41
	\end{tabular}
	\caption{Sophisticated Burrows-Wheeler-Transformation on byte wise RLE.}
	\label{tab:t13 Modified Burrows Wheeler Transformation on byte wise RLE}
\end{table}
}
		\end{column}
		\begin{column}{0.4\textwidth}
			\begin{center}
				\begin{tikzpicture}[
				every node/.style = {shape=rectangle,% is not necessary, default node's shape is rectangle
					draw=cyan, semithick,
					text width=0.8\linewidth,
					align=center}
				]
				\node (pq0) [draw] {Burrows-Wheeler-Transformation};
				\node (pq3) [dashed,below=of pq0] {Byte-wise Run Length Encoding};
				%
				\path[->,thick,cyan]
				(pq0) edge  (pq3);
				\end{tikzpicture}
			\end{center}
		\end{column}
	\end{columns}
}

\frame{\frametitle{Preprocessing - Burrows-Wheeler-Transformation}
\begin{table}[h]
	\centering
	\begin{tabular}{r|r|r|r|r}
		file & size original & size encoded & compression & \textit{bps}\\
		\hline
		bib & 111261 & 59285 & 53.28 & 4.26 \\
		book1 & 768771 & 590879 & 76.86 & 6.15 \\
		book2 & 610856 & 374742 & 61.35 & 4.91 \\
		geo & 102400 & 101192 & 98.82 & 7.91 \\
		news & 377109 & 246047 & 65.25 & 5.22 \\
		obj1 & 21504 & 16467 & 76.58 & 6.13 \\
		obj2 & 246814 & 126626 & 51.30 & 4.10 \\
		paper1 & 53161 & 34130 & 64.20 & 5.14 \\
		paper2 & 82199 & 56507 & 68.74 & 5.50 \\
		pic & 513216 & 136074 & 26.51 & 2.12 \\
		progc & 39611 & 24312 & 61.38 & 4.91 \\
		progl & 71646 & 31466 & 43.92 & 3.51 \\
		progp & 49379 & 20862 & 42.25 & 3.38 \\
		trans & 93695 & 32835 & 35.04 & 2.80 \\
		\hline
		all files & 3145718 & 1855520 & 58.98 & 4.71
	\end{tabular}
	\caption{Calgary Corpus encoded with byte wise RLE after a Burrows-Wheeler- Transformation with 4 bit per run.}
	\label{tab:t14:Calgary Corpus encoded with byte wise RLE after a Burrows-Wheeler-Transformation}
\end{table}
}

\frame{\frametitle{Preprocessing}
	\only<1>{
	\begin{columns}
		\begin{column}{0.40\textwidth}
			Current preprocessing steps:

		\end{column}
		\begin{column}{0.60\textwidth}
			\begin{center}
				\begin{tikzpicture}[
				every node/.style = {shape=rectangle,% is not necessary, default node's shape is rectangle
					draw=cyan, semithick,
					text width=0.8\linewidth,
					align=center}
				]
				\node (pq1) [draw] {Byte Remapping};
				\node (pq2) [below=of pq1] {Vertical Interpretation};
				\node (pq3) [dashed,below=of pq2] {Run Length Encoding};
				%
				\path[->,thick,cyan]
				(pq1) edge  (pq2)
				(pq2) edge  (pq3);
				\end{tikzpicture}
			\end{center}
		\end{column}
	\end{columns}}

\only<2>{
	\begin{columns}
		\begin{column}{0.40\textwidth}
			Current preprocessing steps:

		\end{column}
		\begin{column}{0.60\textwidth}
			\begin{center}
				\begin{tikzpicture}[
				every node/.style = {shape=rectangle,% is not necessary, default node's shape is rectangle
					draw=cyan, semithick,
					text width=0.8\linewidth,
					align=center}
				]
				\node (pq0) [draw] {Burrows-Wheeler-Transformation};
				\node (pq1) [draw,below=of pq0] {Byte Remapping};
				\node (pq2) [below=of pq1] {Vertical Interpretation};
				\node (pq3) [dashed,below=of pq2] {Run Length Encoding};
				%
				\path[->,thick,cyan]
				(pq1) edge  (pq2)
				(pq2) edge  (pq3)
				(pq0) edge  (pq1);
				\end{tikzpicture}
			\end{center}
		\end{column}
\end{columns}}
}

\frame{\frametitle{Preprocessing - Burrows-Wheeler-Transformation}
\begin{figure}[h]
	\begin{tikzpicture}
	\begin{axis}[
	width=\textwidth,
	height=0.45\textwidth,
	axis x line=center,
	axis y line=left,
	xlabel={bits per run},
	x label style={at={(axis description cs:0.5,-0.1)},anchor=north},
	ylabel={Compression ratio},
	symbolic x coords={22223437,22333458,22233579,44444668,44444679,44445788,444457810},
	x tick label style={font=\small,text width=1cm,align=center},
	xtick=data,
	enlargelimits=true,
	ymax=135,
	legend style={
		at={(0.5,1.2)},
		anchor=north,
		legend columns=-1,
		/tikz/every even column/.append style={column sep=0.5cm}
	},
	ymajorgrids=true,
	grid style=dashed,
	ybar
	]
	\addplot[color=blue,fill]
	coordinates {
		(22223437,112.4)(22333458,120.4 )(22233579,125.6)(44444668,147.2)(44444679,151.3)(44445788,159.7)(444457810,160.8)
	};
	\addplot[color=red,fill]
	coordinates {
		(22223437,102.6)(22333458,98.2 )(22233579,94.99)(44444668,115.7)(44444679,115.1)(44445788,118)(444457810,118)
	};
	\addplot[color=black,fill]
	coordinates {
		(22223437,98.8)(22333458,86.1 )(22233579,85.3)(44444668,71.2)(44444679,70.3)(44445788,69.6)(444457810,69.4)
	};
	\legend{no preprocessing,byte mapping,byte mapping \& BWTS}
	\end{axis}
	\end{tikzpicture}
	%}
	%\end{scaletikzpicturetowidth}
	\caption{Byte mapping and varying maximum run lengths, all preprocessing steps.}
	\label{fig:3:Different run lengths with and without transformations}
\end{figure}
}

\frame{\frametitle{Preprocessing - Burrows-Wheeler-Transformation}
\begin{table}[h]
	\centering
	\begin{tabular}{r|r|r|r|r}
		file & size original & size encoded & ratio in \% & \textit{bps}\\
		\hline
		bib & 111261 & 73843 & 66.37 & 5.31 \\
		book1 & 768771 & 570348 & 74.19 & 5.94 \\
		book2 & 610856 & 409639 & 67.06 & 5.36 \\
		geo & 102400 & 145950 & 142.53 & 11.40 \\
		news & 377109 & 275396 & 73.03 & 5.84 \\
		obj1 & 21504 & 27023 & 125.66 & 10.05 \\
		obj2 & 246814 & 213392 & 86.46 & 6.92 \\
		paper1 & 53161 & 37344 & 70.25 & 5.62 \\
		paper2 & 82199 & 56490 & 68.72 & 5.50 \\
		pic & 513216 & 227914 & 44.41 & 3.55 \\
		progc & 39611 & 28275 & 71.38 & 5.71 \\
		progl & 71646 & 38144 & 53.24 & 4.26 \\
		progp & 49379 & 27029 & 54.74 & 4.38 \\
		trans & 93695 & 49314 & 52.63 & 4.21 \\
		\hline
		all files & 3145718 & 2184197 & 69.43 & 5.55
	\end{tabular}
	\caption{Calgary Corpus encoded, byte mapping and a BWTS as preprocessing, using bits per run (4, 4, 4, 4, 5, 7, 8, 10).}
	\label{tab:t5:Calgary Corpus encoded, all preprocessing steps, using bits per run: 4, 4,4, 4, 5, 7, 8, 10}
\end{table}
}

\frame{\frametitle{Preprocessing - Huffman Encoding RLE runs}
	\only<1>{
		\begin{columns}
			\begin{column}{0.40\textwidth}
				Current preprocessing steps:

			\end{column}
			\begin{column}{0.60\textwidth}
				\begin{center}
					\begin{tikzpicture}[
					every node/.style = {shape=rectangle,% is not necessary, default node's shape is rectangle
						draw=cyan, semithick,
						text width=0.8\linewidth,
						align=center}
					]
					\node (pq0) [draw] {Burrows-Wheeler-Transformation};
					\node (pq1) [draw,below=of pq0] {Byte Remapping};
					\node (pq2) [below=of pq1] {Vertical Interpretation};
					\node (pq3) [dashed,below=of pq2] {Run Length Encoding};
					%
					\path[->,thick,cyan]
					(pq1) edge  (pq2)
					(pq2) edge  (pq3)
					(pq0) edge  (pq1);
					\end{tikzpicture}
				\end{center}
			\end{column}
	\end{columns}}
	\only<2>{
		\begin{columns}
			\begin{column}{0.40\textwidth}
				Current preprocessing steps:

			\end{column}
			\begin{column}{0.60\textwidth}
				\begin{center}
					\begin{tikzpicture}[
					every node/.style = {shape=rectangle,% is not necessary, default node's shape is rectangle
						draw=cyan, semithick,
						text width=0.8\linewidth,
						align=center}
					]
					\node (pq0) [draw] {Burrows-Wheeler-Transformation};
					\node (pq1) [below=of pq0] {Byte Remapping};
					\node (pq2) [below=of pq1] {Vertical Interpretation};
					\node (pq3) [dashed,below=of pq2] {Run Length Encoding};
					\node (pq4) [below=of pq3] {Huffman Encoding of the RLE runs};
					%
					\path[->,thick,cyan]
					(pq1) edge  (pq2)
					(pq2) edge  (pq3)
					(pq3) edge  (pq4)
					(pq0) edge  (pq1);
					\end{tikzpicture}
				\end{center}
			\end{column}
		\end{columns}
}}

\frame{\frametitle{Preprocessing - Huffman Encoding RLE runs}
		\begin{table}[H]
			\centering
			\begin{tabular}{r|r|r|r|r}
				file & size original & size encoded & ratio in \% & \textit{bps}\\
				\hline
				bib & 111261 & 44156 & 39.69 & 3.17 \\
				book1 & 768771 & 340279 & 44.26 & 3.54 \\
				book2 & 610856 & 243092 & 39.80 & 3.18 \\
				geo & 102400 & 63006 & 61.53 & 4.92 \\
				news & 377109 & 173207 & 45.93 & 3.67 \\
				obj1 & 21504 & 14405 & 66.99 & 5.36 \\
				obj2 & 246814 & 119957 & 48.60 & 3.89 \\
				paper1 & 53161 & 24917 & 46.87 & 3.75 \\
				paper2 & 82199 & 35939 & 43.72 & 3.50 \\
				pic & 513216 & 82136 & 16.00 & 1.28 \\
				progc & 39611 & 18890 & 47.69 & 3.82 \\
				progl & 71646 & 24649 & 34.40 & 2.75 \\
				progp & 49379 & 17416 & 35.27 & 2.82 \\
				trans & 93695 & 31235 & 33.34 & 2.67 \\
				\hline
				all files & 3145718 & 1237380 & 39.33 & 3.14
			\end{tabular}
			\caption{Calgary Corpus encoded with vertical reading, byte mapping and a BWTS as preprocessing, using Huffman encoding for all counted runs, 8 bit per run.}
			\label{tab:t6:Calgary Corpus encoded, all preprocessing steps, using Huffman encoding for all counted runs}
		\end{table}
}

\section{Implementation}
\frame{\frametitle{Implementation}
	\begin{outline}
		\1 written in Kotlin
		\visible<2->{
			\1 used libraries:
			\2 Kotlin Binary Streams (IOStreams for Kotlin)
			\visible<3->{
			\2 LibDivSufSort (from Kanzi)
			\visible<4->{
			\2 miscellaneous
			\3 google/guava, junit5, staticlog ...
	}}}
\end{outline}
}

\frame{\frametitle{Implementation - Encoding}
	\begin{columns}
		\begin{column}{0.4\textwidth}
\only<1>{\\
	current bit = 0\\
	run = 1\\}
\only<2>{\\
	current bit = 0\\
	run = 2\\}
\only<3>{\\
	current bit = 0\\
	run = 3\\}
\only<4>{\\
current bit = 0\\
run = 4 \\}
\only<5>{\\
current bit = 0\\
run = 5\\}
\only<6>{\\
current bit = 0\\
run = 6\\}
\only<7>{\\
	current bit = 0\\
	run = 0\\
	result = \{[6]\}}
\only<8>{\\
	current bit = 0\\
	run = 0\\
	result = \{[6],[0]\}}
\only<9>{\\
	current bit = 1\\
	run = 1\\
	result = \{[6],[0]\}}
\only<10>{\\
	current bit = 1\\
	run = 2\\
	result = \{[6],[0]\}}
\only<11>{\\
	current bit = 1\\
	run = 3\\
	result = \{[6],[0,6],[0,6],[2,1,3],[6],[6],[1,2,1,1,1],[0,1,2,3]\}}
\only<12->{\\
	current bit = 1\\
	run = 3\\
	result = \{[6],[0,6],[0,6],[2,1,3],[6],[6],[1,2,1,1,1],[0,1,2,3]\}\\
	\medskip
	\begin{tabular}{r|r}
	run & amount\\
	\hline
	6 & 5\\
	1 & 4\\
	2 & 3 \\
	0 & 3\\
	3 & 2\\
	\end{tabular}
}
\end{column}
\begin{column}{0.6\textwidth}
\begin{center}

	\only<1>{
	\begin{equation}
	\begin{multlined}
	\\
	\textcolor{red}{0} 1 1 0 0 0 0 1 \\
	0 1 1 0 0 0 1 0 \\
	0 1 1 1 0 0 1 0 \\
	0 1 1 0 0 0 0 1 \\
	0 1 1 0 0 0 1 1 \\
	0 1 1 0 0 0 0 1 \\
	\end{multlined}
	\end{equation}
}
\only<2>{
	\begin{equation}
	\begin{multlined}
	\\
	0 1 1 0 0 0 0 1 \\
	\textcolor{red}{0} 1 1 0 0 0 1 0 \\
	0 1 1 1 0 0 1 0 \\
	0 1 1 0 0 0 0 1 \\
	0 1 1 0 0 0 1 1 \\
	0 1 1 0 0 0 0 1 \\
	\end{multlined}
	\end{equation}
}

\only<3>{
	\begin{equation}
	\begin{multlined}
	\\
	0 1 1 0 0 0 0 1 \\
	0 1 1 0 0 0 1 0 \\
	\textcolor{red}{0} 1 1 1 0 0 1 0 \\
	0 1 1 0 0 0 0 1 \\
	0 1 1 0 0 0 1 1 \\
	0 1 1 0 0 0 0 1 \\
	\end{multlined}
	\end{equation}
}

\only<4>{
	\begin{equation}
	\begin{multlined}
	\\
	0 1 1 0 0 0 0 1 \\
	0 1 1 0 0 0 1 0 \\
	0 1 1 1 0 0 1 0 \\
	\textcolor{red}{0} 1 1 0 0 0 0 1 \\
	0 1 1 0 0 0 1 1 \\
	0 1 1 0 0 0 0 1 \\
	\end{multlined}
	\end{equation}
}
\only<5>{
	\begin{equation}
	\begin{multlined}
	\\
	0 1 1 0 0 0 0 1 \\
	0 1 1 0 0 0 1 0 \\
	0 1 1 1 0 0 1 0 \\
	0 1 1 0 0 0 0 1 \\
	\textcolor{red}{0} 1 1 0 0 0 1 1 \\
	0 1 1 0 0 0 0 1 \\
	\end{multlined}
	\end{equation}
}

\only<6-7>{
	\begin{equation}
	\begin{multlined}
	\\
	0 1 1 0 0 0 0 1 \\
	0 1 1 0 0 0 1 0 \\
	0 1 1 1 0 0 1 0 \\
	0 1 1 0 0 0 0 1 \\
	0 1 1 0 0 0 1 1 \\
	\textcolor{red}{0} 1 1 0 0 0 0 1 \\
	\end{multlined}
	\end{equation}
}
\only<8-9>{
	\begin{equation}
	\begin{multlined}
	\\
	0 \textcolor{red}{1} 1 0 0 0 0 1 \\
	0 1 1 0 0 0 1 0 \\
	0 1 1 1 0 0 1 0 \\
	0 1 1 0 0 0 0 1 \\
	0 1 1 0 0 0 1 1 \\
	0 1 1 0 0 0 0 1 \\
	\end{multlined}
	\end{equation}
}

\only<10>{
	\begin{equation}
	\begin{multlined}
	\\
	0 1 1 0 0 0 0 1 \\
	0 \textcolor{red}{1} 1 0 0 0 1 0 \\
	0 1 1 1 0 0 1 0 \\
	0 1 1 0 0 0 0 1 \\
	0 1 1 0 0 0 1 1 \\
	0 1 1 0 0 0 0 1 \\
	\end{multlined}
	\end{equation}
}
\only<11->{
	\begin{equation}
	\begin{multlined}
	\\
	0 1 1 0 0 0 0 1 \\
	0 1 1 0 0 0 1 0 \\
	0 1 1 1 0 0 1 0 \\
	0 1 1 0 0 0 0 1 \\
	0 1 1 0 0 0 1 1 \\
	0 1 1 0 0 0 0 \textcolor{red}{1} \\
	\end{multlined}
	\end{equation}
}
\end{center}
\end{column}
\end{columns}
}

\frame{\frametitle{Implementation - Encoding}
	\centering
	\only<1>{
	\includegraphics[height=.8\textheight, width=.4\textwidth]{filestruct1.png}}

\only<2>{
	\includegraphics[height=.8\textheight, width=.4\textwidth]{filestruct2.png}}

\only<3>{
	\includegraphics[height=.8\textheight, width=.4\textwidth]{filestruct3.png}}

\only<4>{
	\includegraphics[height=.8\textheight, width=.4\textwidth]{filestruct4.png}}

\only<5>{
	\includegraphics[height=.8\textheight, width=.4\textwidth]{filestruct5.png}}
}

\frame{\frametitle{Implementation}
	\centering
	DEMO
}

\section{Evaluation and Discussion}
\frame{\frametitle{Evaluation and Discussion}
	\only<1>{
	\begin{columns}
		\begin{column}{0.30\textwidth}
			Efficiency with current preprocessing steps:\\\medskip$\approx112\%$
		\end{column}
		\begin{column}{0.70\textwidth}
			\begin{center}
				\begin{tikzpicture}[
				every node/.style = {shape=rectangle,% is not necessary, default node's shape is rectangle
					draw=cyan, semithick,
					text width=0.8\linewidth,
					align=center}
				]
				\node (pq2) [below=of pq1] {Vertical Interpretation};
				\node (pq3) [dashed,below=of pq2] {Run Length Encoding};
				%
				\path[->,thick,cyan]
				(pq2) edge  (pq3);
				\end{tikzpicture}
			\end{center}
		\end{column}
	\end{columns}
	}
\only<2>{
	\begin{columns}
		\begin{column}{0.30\textwidth}
			Efficiency with current preprocessing steps:\\\medskip$\approx94\%$
		\end{column}
		\begin{column}{0.70\textwidth}
			\begin{center}
				\begin{tikzpicture}[
				every node/.style = {shape=rectangle,% is not necessary, default node's shape is rectangle
					draw=cyan, semithick,
					text width=0.8\linewidth,
					align=center}
				]
				\node (pq1) [below=of pq0] {Byte Remapping};
				\node (pq2) [below=of pq1] {Vertical Interpretation};
				\node (pq3) [dashed,below=of pq2] {Run Length Encoding};
				%
				\path[->,thick,cyan]
				(pq1) edge  (pq2)
				(pq2) edge  (pq3);
				\end{tikzpicture}
			\end{center}
		\end{column}
	\end{columns}
}
\only<3>{
	\begin{columns}
		\begin{column}{0.30\textwidth}
			Efficiency with current preprocessing steps:\\\medskip$\approx69\%$
		\end{column}
		\begin{column}{0.70\textwidth}
			\begin{center}
				\begin{tikzpicture}[
				every node/.style = {shape=rectangle,% is not necessary, default node's shape is rectangle
					draw=cyan, semithick,
					text width=0.8\linewidth,
					align=center}
				]
				\node (pq0) [draw] {Burrows-Wheeler-Transformation};
				\node (pq1) [below=of pq0] {Byte Remapping};
				\node (pq2) [below=of pq1] {Vertical Interpretation};
				\node (pq3) [dashed,below=of pq2] {Run Length Encoding};
				%
				\path[->,thick,cyan]
				(pq1) edge  (pq2)
				(pq2) edge  (pq3)
				(pq0) edge  (pq1);
				\end{tikzpicture}
			\end{center}
		\end{column}
	\end{columns}
}
\only<4>{
	\begin{columns}
		\begin{column}{0.30\textwidth}
			Efficiency with current preprocessing steps:\\\medskip$\approx58\%$
		\end{column}
		\begin{column}{0.70\textwidth}
			\begin{center}
				\begin{tikzpicture}[
				every node/.style = {shape=rectangle,% is not necessary, default node's shape is rectangle
					draw=cyan, semithick,
					text width=0.8\linewidth,
					align=center}
				]
				\node (pq0) [draw] {Burrows-Wheeler-Transformation};
				\node (pq3) [dashed,below=of pq0] {Byte-wise Run Length Encoding};
				%
				\path[->,thick,cyan]
				(pq0) edge  (pq3);
				\end{tikzpicture}
			\end{center}
		\end{column}
	\end{columns}
}
\only<5>{
	\begin{columns}
		\begin{column}{0.30\textwidth}
			Efficiency with current preprocessing steps:\\\medskip$\approx39\%$
		\end{column}
		\begin{column}{0.70\textwidth}
			\begin{center}
				\begin{tikzpicture}[
				every node/.style = {shape=rectangle,% is not necessary, default node's shape is rectangle
					draw=cyan, semithick,
					text width=0.8\linewidth,
					align=center}
				]
				\node (pq0) [draw] {Burrows-Wheeler-Transformation};
				\node (pq1) [below=of pq0] {Byte Remapping};
				\node (pq2) [below=of pq1] {Vertical Interpretation};
				\node (pq3) [dashed,below=of pq2] {Run Length Encoding};
				\node (pq4) [below=of pq3] {Huffman Encoding of the RLE runs};
				%
				\path[->,thick,cyan]
				(pq1) edge  (pq2)
				(pq2) edge  (pq3)
				(pq3) edge  (pq4)
				(pq0) edge  (pq1);
				\end{tikzpicture}
			\end{center}
		\end{column}
	\end{columns}
}
}
\frame{\frametitle{Evaluation and Discussion}
		\begin{table}[h]
			\centering
			\begin{tabular}{r|r|r|r|r}
				file & size original & size encoded & ratio in \% & \textit{bps}\\
				\hline
				alice29.txt & 152089 & 65445 & 43.03 & 3.44 \\
				asyoulik.txt & 125179 & 59291 & 47.36 & 3.79 \\
				cp.html & 24603 & 11073 & 45.01 & 3.60 \\
				fields.c & 11150 & 5183 & 46.48 & 3.72 \\
				grammar.lsp & 3721 & 1923 & 51.68 & 4.13 \\
				kennedy.xls & 1029744 & 229823 & 22.32 & 1.79 \\
				lcet10.txt & 426754 & 170593 & 39.97 & 3.20 \\
				plrabn12.txt & 481861 & 215628 & 44.75 & 3.58 \\
				ptt5 & 513216 & 82136 & 16.01 & 1.28 \\
				sum & 38240 & 19616 & 51.30 & 4.10 \\
				xargs.1 & 4227 & 2515 & 59.50 & 4.76 \\
				\hline
				all files & 2814880 & 867322 & 30.81 & 2.46
			\end{tabular}
			\caption{Canterbury encoded, all preprocessing steps, using Huffman Encoding for all counted runs.}
			\label{tab:t100:Canterbury encoded, all preprocessing steps, using Huffman encoding for all counted runs}
		\end{table}
}
\frame{\frametitle{Evaluation and Discussion}
		\begin{table}[h]
			\begin{tabular}{r|r|r|r|r|r}
				method  &  size in bytes & compression & \textit{bps} & \multicolumn{2}{c}{time }\\
				& & & & encoding & decoding\\
				\hline
				uncompressed & 3,145,718 & 100.0\% & 8.00 & &\\
				compress 4.2.4 & 1,250,382 & 40.4\% & 3.24 & 0.039s & 0.025s\\
				modified vertical RLE & 1,237,380 & 39.3\%& 3.14 & 6.840s & 15.637s\\
				gzip v1.10 & 1,021,720 & 32.4\% & 2.60 & 0.232s & 0.025s\\
				ZIP v3.0 & 1,019,783 & 32.4\% & 2.59 & 0.214s & 0.022s\\
				zstandard 1.4.2& 887,004 & 28.1\% & 2.25 & 0.951s & 0.011s\\
				bzip2 v1.0.8 & 832,443 & 26.4\% & 2.11 & 0.191s & 0.088s\\
				brotli 1.0.7 & 826,638 & 26.3\%& 2.10 & 4.609s & 0.015s\\
				p7zip 16.02 (deflate) &  794,098 & 26.1\% & 2.08 & 0.431s & 0.045s \\
				p7zip 16.02 (PPMd) &  763,067& 24.2\% & 1.93 & 0.345s & 0.282s\\
				ZPAQ v7.15 & 659.700 & 20.9\% & 1.67 & 7.452s & 7.735s\\
				paq8hp* & - & - & - & - & -\\
				cmix v18 & 554,983 & 17.6\% & 1.41 & $>$3h & $>$2h
			\end{tabular}
			\label{tab:t100benchmark}
			\caption{Benchmark on the Calgary Corpus.}
		\end{table}
}

\begin{frame}[allowframebreaks]
	\frametitle{References}
	\bibliographystyle{cpc}
	\bibliography{kol.bib}
\end{frame}

\end{document}


\label{intro:chapter}
Scheduling an event for a group of agents is a challenging problem.
It tends to be tedious and time-consuming for everyone involved.
In practice, procrastination and strategic behavior of agents are often a problem, but even if we assume that agents are truthful, prompt, and indifferent among the possible outcomes, the group scheduling problem exhibits an interesting algorithmic problem.
We formally model this as an optimization problem in which we are allowed to query availability of agents in order to learn about their availability (which is unknown a priori) with the assumption that agents are prompt and truthful in responding to such queries. We wish to minimize a certain cost function such as the total number of queries. We provide an intuitive, efficient algorithm that solves this optimization problem for a fairly broad class of settings. We define the underlying problem as a general optimization problem, how it can be applied to other real world settings than group scheduling problems.

Another setting that is relevant to group scheduling comes from group assignment problems. Consider a setting where the organizer wishes to assign agents to social activities. Agents may have preferences over activities as well as the number of participants in the activity they are assigned to (for now, suppose agents have anonymous preferences in that they do not care who the participants are, but only the number of participants). For instance, agents may prefer more participants in social networking receptions, but wish to have not too many participants in a table tennis tournament. Naturally the organizer wishes to assign as many agents to activities as possible, but at the same time he wishes to ensure that every individual is satisfied with the assignment. We study the solution concept of individual rationality and stability which require that there is no single-agent deviation from an assignment. This problem is known to be NP-hard in general even if certain restrictions of preferences of agents are assumed. In this work we first show that the problem is still computationally difficult even if we seek a small, fixed-size solution in general. However, we also show that for a relaxed version of the stability requirement, the problem admits an efficient algorithm for finding a fixed-size, small solution.

We then further generalize the group assignment problem by considering the cases where agents have friend and/or enemy relationships which introduce additional constraints or preferences. Because most of the technical results we obtain for the anonymous case are already hardness results, we focus on a special case where there is only one activity, which is known to be easy (i.e., polynomial-time solvable) when agents have anonymous preferences. We show if the number of friends or enemies of an agent is large (namely, two or more), then the problem of finding a stable solution is NP-hard. Furthermore, finding a fixed-size, small solution also depends on the cardinality of the largest friend-set or enemy-set, which naturally categorizes the underlying problem into different complexity classes. We also show that the problem becomes computationally easier if the friends and enemies relationship is symmetric.

Lastly we consider strategic agents in this setting where agents may report false information to the event organizer. We show that in general finding a stable solution and strategy-proofness are incompatible in the activity selection problem, but we also provide a socially optimal, computationally efficient, and strategy-proof mechanism in the special case where there is only one activity and the preferences of agents align with the goal of the designer (so as to maximize the number of participants).

\section{Organization of the Thesis}
Chapter~\ref{bdoodle:chapter} introduces the Batched Doodle Problem which is motivated by a well-known tool for group scheduling, called ``Doodle''~\footnote{http://www.doodle.com/}. Through the Batched Doodle Problem, we propose an algorithmic approach to group scheduling by optimizing the duration of scheduling process and inconvenience caused by it. Chapter~\ref{matrix:chapter} generalizes the Batched Doodle Problem further to the Probabilistic Matrix Inspection Problem, which has many applications other than just group scheduling. In both problems, we focus on designing efficient algorithms that find a feasible solution at minimum (expected) cost.
We then turn our attention to group assignment problems in Chapter~\ref{GASP:chapter} by considering the Group Activity Selection Problem which was originally introduced by Darmann et al.~\cite{GASP12WINE} In the Group Activity Selection Problem, agents are assumed to have anonymous preferences over activities in that not only do agents care about which activity they are assigned to, but they also care about the number of participants. The objective is to assign agents to activities subject to individual rationality or Nash stability conditions. The problem is known to be NP-hard even under some natural restrictions on preferences of agents. In this work, we further investigate complexity of this problem by parameterizing the size of a solution, and show that the problem is still computationally difficult to solve. In Chapter~\ref{SIP:chapter}, we define the Stable Invitations Problem which is motivated by the Group Activity Selection Problem. In the Stable Invitations Problem, there is only one activity, rather than many, but agents are no longer assumed to have anonymous preferences. Instead, they have friend and enemy relationships. We investigate both classical and parameterized complexity of this problem, by considering different restrictions on preferences and friend/enemy relationships. Lastly, in Chapter~\ref{GT:chapter} we introduce strategic agents. When agents act strategically, we show that it is in general impossible to obtain a strategy-proof mechanism that can find a desirable solution in the Group Activity Selection Problem or the Stable Invitations Problem. However, in a special case when all agents prefer more participants than fewer participants and there is only one activity, we obtain a strategy-proof, optimal, and computationally efficient mechanism.
In Chapter~\ref{discussion:chapter}, we conclude the thesis by summarizing the findings and implications of each chapter.


\section{Motivating Example}

As a motivating example, imagine a user was to reconstruct the filter that was used to transform an audio clip, as shown in Figure~\ref{fig:test}.
In this example, a user provided a clip of a \texttt{cartoon-spring.wav} in Figure~\ref{fig:inEx}, and the same sound as it had been transformed with a low-pass filter at 800 Hz, $lpf(800)$, as shown in Figure~\ref{fig:outEx}.
However the nature of the transformation is unknown to the user and they wish to discover the filter needed.
Our DSP-PBE tool is able to synthesize a filter $lpf(1989)$, that when applied to the original sound, produces the waveform shown in Figure~\ref{fig:synthEx}.
While the solution is not exact, the difference is not significantly noticeable to an untrained ear.

\begin{figure}
\centering
\begin{subfigure}{.32\linewidth}
  \centering
  \includegraphics[width=.9\textwidth]{figs/original.png}
  \caption{Input example}
  \label{fig:inEx}
\end{subfigure}%
\begin{subfigure}{.32\linewidth}
  \centering
  \includegraphics[width=.9\textwidth]{figs/lpf800.png}
  \caption{Output example}
  \label{fig:outEx}
\end{subfigure}
\begin{subfigure}{.32\linewidth}
  \centering
  \includegraphics[width=.9\textwidth]{figs/lpf1989.png}
  \caption{Generated}
  \label{fig:synthEx}
\end{subfigure}
\caption{The waveforms (a) and (b) are provided as examples, and DSP-PBE synthesizes a filter that produces (c).}
\label{fig:test}
\end{figure}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  examples.tex
%
%  Some worked examples:
%  1. Conductance in simple porous media
%
%  Edinburgh Soft Matter and Statistical Physics Group and
%  Edinburgh Parallel Computing Centre
%
%  (c) 2010-2017 The University of Edinburgh
%
%  Contributing authors:
%  Kevin Stratford (kevin@epcc.ed.ac.uk)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Examples}
\label{section-examples}

\subsection{Permeability calculations in simple porous media}

Single fluid permeability calculations for a given porous structure
can be undertaken by driving a flow via the fluid body force. Note
that the structure must be periodic in the direction of the force
(this may mean duplicating a 'reflected' version of a given sample
to create the correct input). The body force can be specified so
that, e.g., to drive a flow in the positive $x-$direction
\begin{lstlisting}
force 0.001_0.000_0.000
\end{lstlisting}
The force should not be so large that the maximum velocity generated
threatens the Mach number constraint. To get a measurement of the
flow at equilibrium, the calculation should be run at least the
momentum diffusion time for the system ($L^2/\eta$ in LB time steps).

The net flow can be measured by combining the statistics for the
total momemnum and the total density (which is equal to the volume
with $\rho_0 = 1$). We will see an example of this later in the
section.

Note that in the case of porous media with narrow channels at the grid
scale, the wall velocity can be dependent on the viscosity of the fluid.
This is an artefact of the bounce-back on links and will result in a
viscosity-dependent permeability (see, e.g., \cite{lipanmiller}).
To minimise this effect, e.g.,  Ginzburg and d'Humi\`eres \cite{ginzburg}
corrects the viscosity-dependence of the apparent boundary position
using a three relaxation time scheme.

Before considering a concrete example, it's worth reviewing the basic
calculation of the conductance in ideal geometries.

\subsubsection{Circular and rectangular capillaries}

\label{section-examples-exact-conductance}

For an infinite  capillary of circular cross section radius $a$,
the conductance is known analytically\cite{papanastasiou}. The
flow per unit area $J$ is given by
\begin{equation}
J = - \frac{1}{8\eta} \frac{\partial p}{ \partial x} a^2.
\end{equation}
If the pressure gradient is replaced by a uniform body force
$-\partial p/ \partial x = \rho g$, then one can define a
viscosity-independent conductance $C$ via $ J = C \rho g / \eta$,
i.e., $C = a^2/8$. So, by measuring the volume flux at steady state
for a fixed applied body force, one can compute an estimate of the
conductance to compare with this result.

An analytical expression is also available for the conductance
of a square or rectangular capillary. For an infinite capillary
of square cross section width $w \times h$ (where $h$ is the
longer),
the volume flux per unit area $J$ is expected to be
\cite{papanastasiou,edo1}
\begin{equation}
J = - \frac{1}{3\eta} \frac{\partial p}{\partial x} (h/2)^2
\left[
1 - 6(h/w) \sum_{k=1}^{\infty} \frac{\tanh(\alpha_k w/h)}{\alpha_k^5}
\right]
\end{equation}
where $\alpha_k = (2k - 1)\pi/2$. The pressure gradient
$-\partial p / \partial x$ is replaced by the body force $\rho g$ and
one can difine the viscosity-independent conductance $C$ via
$J = C\rho g / \eta$. The calculation proceeds as above.

\subsubsection{Setting up a structure}

We will work out the conductance of a simple one-dimensional capillary
of circular cross section. We can set up the structure using the
utility program found in \texttt{util/capillary.c}.

We set the system size to be $(10,10,32)$ in the $x-$, $y-$, and
$z-$directions, respectively. The cross section in $x-y$ will be
a discrete  approximation to a circle. The nominal radius is
$a = 4$ lattice units (allowing for solid sites at each edge).
In \texttt{capillary.c} we
set
\begin{lstlisting}
const int xmax = 10;
const int ymax = 10;
const int zmax = 32;
\end{lstlisting}
Note that the conductance should be independent of the length of the
capillary in the $z-$direction. We will check this later.

We choose a circular cross section via:
\begin{lstlisting}
enum {CIRCLE, SQUARE, XWALL, YWALL, ZWALL, XWALL_OBSTACLES};
const int xsection = CIRCLE;
\end{lstlisting}
For this problem, the wetting parameters are irrelevant, and can be
ignored. In addition we set
\begin{lstlisting}
enum {STATUS_ONLY, STATUS_WITH_H, STATUS_WITH_SIGMA};
const int output_type = STATUS_ONLY;
\end{lstlisting}
to specify that the output will contain only the structural information.
The output filename containing the structure is set via
\begin{lstlisting}
const char * filename = "capillary.001-001";
\end{lstlisting}

The program may be compiled and run via
\begin{lstlisting}
$ make capillary.c -lm
$ ./capillary
\end{lstlisting}
The output provides a simple representation of the cross section,
and a count of the number of solid sites, the number of fluid sites,
and the total. Again, the wetting parameters are irrelevant. For this
case we have
\begin{lstlisting}
Cross section (0 = fluid, 1 = solid)
 1 1 1 1 1 1 1 1 1 1
 1 1 1 0 0 0 0 1 1 1
 1 1 0 0 0 0 0 0 1 1
 1 0 0 0 0 0 0 0 0 1
 1 0 0 0 0 0 0 0 0 1
 1 0 0 0 0 0 0 0 0 1
 1 0 0 0 0 0 0 0 0 1
 1 1 0 0 0 0 0 0 1 1
 1 1 1 0 0 0 0 1 1 1
 1 1 1 1 1 1 1 1 1 1
n = 3200 nsolid = 1536 nfluid = 1664
\end{lstlisting}
Note that the outermost sites in each direction here are solid. There
should be a file \texttt{capillary.001-001} in the current directory.
This should be moved to the executable directory.

\subsubsection{Setting up the input}

Assuming we have compiled the serial code, we must now set up the
input file to be consistent with the capillary structure we want
to use. The \texttt{src/input.ref} file can be used as a template.
We should set the system size
\begin{lstlisting}
size 10_10_32
\end{lstlisting}
The location of the porous media file is specified using
\begin{lstlisting}
porous_media_format BINARY
porous_media_file   capillary
porous_media_type   status_only
\end{lstlisting}
Note that the extension \texttt{.001-001} of the filename has been
removed in the input file (it gets added back automatically by the
main code at run time).

As this is a single fluid calculation with no free energy involved
we must set
\begin{lstlisting}
free_energy none
\end{lstlisting}
What are the fluid parameters? We will set the viscosity to
$1/6$ in lattice units (and the bulk viscosity to the default
value by commenting it out; the default value is the same as
the shear viscosity):
\begin{lstlisting}
viscosity 0.16666666666666666
#bulk_viscosity 0.1
\end{lstlisting}
We expect that the number of time steps to reach a steady state
will be of order $t \approx a^2/\eta$, which we estimate using
$a=4$ so $t \approx 100$ LB time steps. We will try
\begin{lstlisting}
N_cycles 200
\end{lstlisting}
Note that we will need output on the total momentum and the volume
flux of the system
as a function of time, so we set
\begin{lstlisting}
freq_statistics 50
\end{lstlisting}

Finally, we need to set a force in the $z$-direction to drive the
flow. Again, the final conductance should be independent of this
force providing the force is small enough that both the Mach number
and the Reynolds number are small compared to unity in steady stead.
We will set
\begin{lstlisting}
force 0.00_0.00_0.0000001
\end{lstlisting}

\subsubsection{Extracting the conductance}

With these parameters specified, we can run the code. The output
should reflect the parameters in the input file, and the time step
loop should start if the parameters, and the \texttt{capillary.001-001}
file has been read successfully. The code reports various fluid
properties. The density is \texttt{[rho]}, and we see that the
total is the same as the number of fluid sites reported by the
\texttt{capillary.c} program:
\begin{lstlisting}
Scalars - total mean variance min max
[rho]    1664.00  1.00000000000-2.2204460e-16  1.00000000000 1.00000000000
\end{lstlisting}
Note that the total density (ie., mass) should remain exactly unchanged
for the duration of the run; if not, there is something wrong.

The integrated volume flux of the fluid in each coordinate direction is
reported, and we should see, as a function of time
\begin{lstlisting}
Velocity - x y z
...
[vol flux]  3.1086245e-15  2.4868996e-14  1.9303426e-03
[vol flux] -6.8278716e-14  4.8849813e-15  2.0251488e-03
[vol flux]  8.4265928e-14  5.5178084e-14  2.0299067e-03
[vol flux]  1.6209256e-14  1.2212453e-14  2.0301454e-03
\end{lstlisting}
Note as we have applied an external force in the $z-$direction,
the $z$-flux increases with time while the volume flux in the
other two directions is constant (zero to machine accuracy, which is
around $10^{-16}$). Further, the $z$-volume flux
is still changing slightly after 200 time steps, so we have
not run long enough to reach a steady state. If we run for
400 steps, we should see that the $z$-flux is unchanged
over the last 100 time steps.
\begin{lstlisting}
Velocity - x y z
...
[vol flux]  6.6391337e-14 -2.2204460e-15  2.0301580e-03
[vol flux]  3.4638958e-14  3.6415315e-14  2.0301580e-03
\end{lstlisting}
Finally, note the maximum velocity in the flow direction
is small compared with unity, and so both Mach number and
Reynolds number are also small in this case.

The figure we are interested in is the volume flux in the
$z$-direction which is $2.030\times 10^{-3}$. As the mean
density is unity, this is also the integrated volume flux $J_v$.
The volume flux per unit area $J = J_v / a^2 L_z$, where $a^2 L_z$
is the volume of the discrete system (1664 in lattice units).
Following section \ref{section-examples-exact-conductance},
we can write a viscosity independent conductance
$C = J\eta / \rho g$, with $g$ the force in the $z-$direction.
Putting all this together, we have $C = (2.030\times 10^{-3} / 1664)
\times (1/6) / (1.0 \times 1\times 10^{-7}) = 2.033$. The theoretical
figure is $C = 2$, so the simulation is correct to within a discretisation
error of about 2\%.

\subsubsection{In parallel}

We can run the same calculation using the parallel code (recompile
with \texttt{make mpi}). In the input file we set
\begin{lstlisting}
size 10_10_32
grid 1_1_2
\end{lstlisting}
to set the parallel decomposition explicitly to two MPI tasks in the
$z$-direction. We also set
\begin{lstlisting}
porous_media_format BINARY_SERIAL
porous_media_file   capillary
porous_media_type   status_only
\end{lstlisting}
to ensure the structure file is read correctly in parallel.
We should run this on 2 MPI tasks, e.g.,
\begin{lstlisting}
$ mpirun -np 2 ./Ludwig.exe input
\end{lstlisting}
The final result should be exactly the same as the serial version
to machine accuracy. You may also be able to spot that the execution
time is approximately half that for the serial version (although this
problem is a little small for efficient parallelisation).

\subsubsection{General porous media}

For a general porous media, we can make use of Darcy's Law which
defines a permeability $k$ (with dimensions of area) via
\begin{equation}
J_v = - \frac{k A}{\eta} \frac{\partial P}{\partial z}
\end{equation}
where $J_v$ is the volume flux, $A$ is the cross-sectional area
of the sample, and $\partial P / \partial z$ is the pressure gradient
as before.

\subsubsection{Matching lattice and real units in porous media}

Following Succi \cite{succi} (Chapter~8) the following argument
can be made to match lattice quantities and real physical
quantities for a given system of interest.
Dimensionless lattice Boltzmann units set the lattice spacing
$\Delta x = 1$, the lattice time step $\Delta t = 1$ and the
mean density of the fluid to $\rho_0 = 1$. The speed of sound
in lattice units is $c_s = 1/ \sqrt{3}$. How do we match these
units to physical ones?

Suppose we have discretised an X-ray tomography image with a resolution
of 1 voxel equal to 1 $\mu$m. If we represent one voxel by one cubic
lattice with width $\Delta x$, then we can match $\Delta x = 1\mu$m. A
large data set might provide 1000 voxels on a side, giving
1000 lattice sites, which would represent 1 mm.
Similarly, if our real system is water at room temperature with density
$\rho = 1000$kg~m$^{-3}$, then we may equate the lattice density
$\rho_0 = 1$ to be equivalent to 1000~kg~m$^{-3}$. (This means the
mass of fluid at one lattice site of volume $\Delta x^3 = 1 \mu$m$^{3}$
is then 10$^{-15}$~kg, although this is not a very useful number.)

This leaves time. This is matched via the speed of sound. For the real
system, we take the speed of sound in water at 20$^o$C to be
1480 m~s$^{-1}$. So the speed of sound on the lattice
$(1/\sqrt{3}) \Delta x$ per $\Delta t$ matches 1480~m~s$^{-1}$,
or $\Delta t = 1/\sqrt{3} \times 10^{-6} / 1480 \approx 3.9 \times 10^{-10}$s.
Note that this is a small unit, i.e., it would require very many time
steps to reach a `macroscopic' time in any simulation.

We should also consider the Reynolds number $Re = \rho U L / \eta$.
Suppose our real structure has a characteristic pore size which is
just at the resolution of the X-ray tomography image: $L = h = 1\mu$m.
If the fluid (water) has viscosity $\eta = 10^{-3}$ Pa s, and
a typical flow is $U \sim 10^{-3}$ m~s$^{-1}$, then the pore scale
Reynolds number is $Re_h \sim 10^{-3}$. In the LB, if we choose a
lattice viscosity $\eta = 1/6$, and generate a typical flow in
lattice units of $10^{-4}$, then the Reynolds number in the
simulation (with $\rho_0 = 1$ and $L = \Delta x = 1$) is
$Re \sim 6 \times 10^{-4}$, which is similar.

There is one potential problem if we wish to study transport
phenomena where we might want to run a simulation long enough
for the flow to cross the whole sample. With $U \sim 10^{-4}$
in lattice units and a large sample size of, say,  1024$^3$ the
flow would take around 10$^7$ simulation time steps to propagate
information across the system. This is computationally expensive.
One solution is
to artificially raise the flow speed (and hence the Reynolds
number). This is acceptable as long as the Reynolds number
remains small compared with unity (all Reynolds numbers $< 0.1$
can be regarded as negligible \cite{batchelor}.) Here, for example,
if we raise the flow by two orders of magnitude to $10^{-2}$ in
lattice units,
the Reynolds number is still acceptable at $Re = 6\times 10^{-2}$,
and the number of simulation time steps is reduced to a more
managable $10^5$ (see also \cite{cates_scaling}).

% End examples
\vfill
\pagebreak


\section{Conclusion}
The problem of BFS in parallel is very fascinating because the task itself looks easy, but considering the fact that it is strongly dependent on the input, is non trivial to design a solution that in general achieves good performances. Graphs, as it is known, have many statistical and topological properties, and an accurate analysis requires a lot of effort. The work presented here tries to analyze the performance of the proposed parallel solutions by varying some of the main properties of the graphs. The work focused more on some types of graphs, exposing reasoning  specifically on Erdos-Renyi graphs and real networks.
\\
In conclusion, the proposed solution achieves fair performance provided that we find sufficiently large frontiers and that the nodes of the next frontier are equally distributed in the neighborhoods of the current one. Two possible improvements can be applied:
\begin{enumerate}
    \item The first one, is to handle the possibility that some frontiers may be very small, i`ntroducing a threshold on the number of nodes in the frontier under which the sequential version is used.
    \item Another possible improvement to mitigate the problem of the distribution of nodes of the next frontier in the neighborhoods is the introduction of the concept of partial visit of a node. A simple way to implement it is to check at the time of insertion into the frontier how many neighbors the node has: if the number is above a certain threshold its visit is split into multiple chunks.
\end{enumerate}


\documentclass{article}
\setlength{\oddsidemargin}{0.25 in}
\setlength{\evensidemargin}{-0.25 in}
\setlength{\topmargin}{-0.6 in}
\setlength{\textwidth}{6.5 in}
\setlength{\textheight}{8.5 in}
\setlength{\headsep}{0.75 in}
\setlength{\parindent}{0 in}
\setlength{\parskip}{0.1 in}
\usepackage{amsmath,amsfonts,graphicx}
\usepackage{tikz}
\usepackage{epsfig}
\usepackage{filecontents}
\usepackage{pgfplots, pgfplotstable}
\usepackage{mathtools}
\usepackage{breqn}
\usepackage{graphicx}
\usepackage{subcaption}
\usepgfplotslibrary{statistics}

\newcounter{lecnum}
\renewcommand{\thepage}{\thelecnum-\arabic{page}}
\renewcommand{\thesection}{\thelecnum.\arabic{section}}
\renewcommand{\theequation}{\thelecnum.\arabic{equation}}
\renewcommand{\thefigure}{\thelecnum.\arabic{figure}}
\renewcommand{\thetable}{\thelecnum.\arabic{table}}

\newcommand{\lecture}[4]{
  \pagestyle{myheadings}
  \thispagestyle{plain}
  \setcounter{lecnum}{#1}
  \setcounter{page}{1}
  \noindent
  \begin{center}
    \framebox{
      \vbox{\vspace{2mm}
        \hbox to 6.28in { {\bf Analysis of Uncertainties
	    \hfill Fall 2014} }
        \vspace{4mm}
        \hbox to 6.28in { {\Large \hfill Lecture #1: #2  \hfill} }
        \vspace{2mm}
        \hbox to 6.28in { {\it Lecturer: #3 \hfill Notes by: #4} }
        \vspace{2mm}}
    }
  \end{center}
  \markboth{Lecture #1: #2}{Lecture #1: #2}
  \vspace*{4mm}
}

\renewcommand{\cite}[1]{[#1]}
\def\beginrefs{\begin{list}%
    {[\arabic{equation}]}{\usecounter{equation}
      \setlength{\leftmargin}{2.0truecm}\setlength{\labelsep}{0.4truecm}%
      \setlength{\labelwidth}{1.6truecm}}}
\def\endrefs{\end{list}}
\def\bibentry#1{\item[\hbox{[#1]}]}

\newtheorem{theorem}{Theorem}[lecnum]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{claim}[theorem]{Claim}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{definition}[theorem]{Definition}
\newenvironment{proof}{{\bf Proof:}}{\hfill\rule{2mm}{2mm}}

\newcommand\E{\mathbb{E}}

\begin{document}
\lecture{3}{28 October 2014}{Prof. Kate Scholberg}{Douglas Davis}
\section{Estimating means \& errors from data}
In lecture one, we stated the following connection:
\begin{center}
  \begin{tabular}{ c | c }
    \emph{sample} quantities & \emph{truth}/parent quantities                                            \\
    \hline\hline
    $\overline{x}$           & $\mu$                                                                     \\
    $s^2$                    & $\sigma^2$                                                                \\
    \hline
  \end{tabular}
\end{center}
In many common situations the parent is a Gaussian or Poisson distribution
(Poisson for low mean, low rate). For now let's assume we have a parent which
is Gaussian. The probability $dQ$ of measuring between possibility $x$ and
$x+dx$ is given by
\begin{align}
  dQ = \frac{1}{\sigma\sqrt{2\pi}}\exp\left[
  {-\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^2}\right]dx.
  \label{eq:dq}
\end{align}
Let's say we our particular measurements are $x_i$ and the probability of
measuring $P_i$ is $P(x_i)$. We'll say that each $x_i$ has the same $\mu$
and $\sigma$. Our set is
\begin{align*}
  \{x_i\}: \{x_1,x_2,...,s_N\}.
\end{align*}
Using the notation $\mu = \text{truth distribution}$ and
$\mu' = \text{best estimate}$, let's work out $\mu'$ assuming
that $\sigma' = \sigma$ and is constant. We start by defining:
\begin{align}
  P_i(\mu_i)                 & = P(x_i|\mu_i), \text{ probability of getting } x_i \text{ given } \mu_i, \\
  P_i(\mu')                  & = \frac{1}{\sigma\sqrt{2\pi}}\exp\left[{-\frac{1}{2}\left(\frac{x_i-\mu'}{\sigma}\right)^2}\right].
\end{align}
We assume all probabilities are independent, therefore all probabilities can be multiplied to gather the probability of getting our entire set, recall that when $A$ and $B$ are independent:
\begin{align*}
  P(AB) = P(A)P(B).
\end{align*}
Therefore, given $\mu'$ the probability of getting $x_1\, ...\, x_N$ (our collection) is:
\begin{align}
  P(\mu') = \prod_i^N P_i(\mu') \equiv \text{``Likelihood''}.
  \label{eq:like}
\end{align}
For our current scenario:
\begin{align}
  P(\mu') = \prod_i^N P_i(\mu') = \left(\frac{1}{\sigma\sqrt{2\pi}}\right)^N\exp\left[-\frac{1}{2}\sum_i^N \left(\frac{x_i-\mu'}{\sigma}\right)^2\right].
  \label{eq:full_like}
\end{align}
To get the best estimate for the mean we need to ``maximize the likelihood.'' This is called the method of maximum likelihood. To do this, it is clear that we need to minimize the sum in equation~\ref{eq:full_like}. We'll minimize as a function of $\mu'$:
\begin{align*}
  \frac{d}{d\mu'}\left[\frac{1}{2}\sum_i^N\left(\frac{x-\mu'}{\sigma}\right)^2\right] = 0 = \sum_i^N\left(\frac{x_i-\mu'}{\sigma^2}\right) \quad \rightarrow \quad \sum_i^N x_i = \sum_i^N \mu' = N\mu'.
\end{align*}
This yields the familiar mean of the sample:
\begin{align}
  \mu' = \frac{1}{N}\sum_i^Nx_i.
  \label{eq:main_mean}
\end{align}
Therefore, using the general maximum likelihood method, we arrive at the simple mean of the sample maximizes the likelihood and is therefore the best estimate of the mean. Next, we will work out the uncertainty on $\mu'$. It's a common mistake to take $\sigma$ as the uncertainty on the mean, but this is actually incorrect -- we have more knowledge about the mean than that (the uncertainty is less than $\sigma$). We'll take our error propagation from lecture one. For some variable $y$ as a function of $u,v,w... = \{\alpha_i\}$:
\begin{align}
  \sigma_y^2 = \sum_{\alpha} \left|\frac{\partial f}{\partial x_{\alpha}}\right|^2\sigma_{\alpha}^2 + \text{ covariant terms}.
\end{align}
Here we are assuming no correlation so no covariant terms. Now we identify $\mu'$ as $y$ and the $x_i$'s as the $u,v,w...$ set.
\begin{align*}
  \sigma_{\mu'}^2 = \sum_i^N \sigma_i^2 \left|\frac{\partial \mu'}{\partial x_i}\right|^2 =  \sigma^2\sum_i^N \left|\frac{\partial \mu'}{\partial x_i}\right|^2,
\end{align*}
for constant $\sigma_i = \sigma$ (all $x_i$ drawn from same sample).
\begin{align*}
  \frac{\partial \mu'}{\partial x_i} = \frac{1}{N},
\end{align*}
therefore:
\begin{align*}
  \sigma_{\mu'}^2 = \sigma^2\sum_i^N \frac{1}{N^2} = \sigma^2N\frac{1}{N^2} = \frac{\sigma^2}{N}.
\end{align*}
And now we've arrived at the uncertainty on the mean:
\begin{align}
  \sigma_{\mu'} = \frac{\sigma}{\sqrt{N}}.
  \label{eq:main_unc}
\end{align}
Now we suppose that $\sigma_i$'s are not all constant $\sigma$. We begin by just taking equation~\ref{eq:full_like} and using $\sigma_i$ for $\sigma$. Now it is iterated over in the product.
\begin{align}
  P(\mu') = \prod_i^NP_i(\mu') = \left(\frac{1}{\sigma_i\sqrt{2\pi}}\right)^N\exp\left[-\frac{1}{2}\sum_i^N\left(\frac{x_i-\mu'}{\sigma_i}\right)^2\right].
\end{align}
We again maximize the likelihood by minimizing the sum in the exponential, now with unique $\sigma_i$:
\begin{align*}
  \frac{d}{d\mu'}\frac{1}{2}\sum_i^N\left(\frac{x_i-\mu'}{\sigma_i}\right)^2 = 0 = \sum_i^N \frac{x_i-\mu'}{\sigma^2} \quad \rightarrow \quad \sum_i^N \frac{x_i}{\sigma_i^2} - \mu'\sum_i^N \frac{1}{\sigma^2} = 0.
\end{align*}
We arrive at:
\begin{align}
  \mu' = \frac{\sum_i^N\frac{x_i}{\sigma_i^2}}{\sum_i^N\frac{1}{\sigma_i^2}}.
  \label{eq:vary_mean}
\end{align}
And the variance of the estimate of the mean (uncertainty on the mean):
\begin{align}
  \sigma_{\mu'}^2 = \frac{1}{\sum_i^N\frac{1}{\sigma_i^2}}.
  \label{eq:vary_unc}
\end{align}
Notice that if $\sigma_i\rightarrow \text{constant } \sigma$ equations~\ref{eq:vary_mean}~\&~\ref{eq:vary_unc} just go to equations~\ref{eq:main_mean}~\&~\ref{eq:main_unc}, respectively.

Let's take a minute to talk about Poisson. For Poisson distributions $\sigma \rightarrow \sqrt{\mu}$. When we think Poisson we think low rate counting, for example: a low number of events in some $\Delta t$. Let $\mu_t$ be the mean number of events in $\Delta t$. The Poisson distribution:
\begin{align}
  P(x;t) \rightarrow P(x;\mu) = \frac{\mu^xe^{-\mu}}{x!},
\end{align}
for $x = 0, 1, 2,...$ . Imagine $N$ measurements (for $\mu \geq 10$ this would $\sim$ Gaussian).
\begin{align}
  \mu_t \sim \overline{x}_t,
\end{align}
$\overline{x}_t$ is the best estimate of $\mu_t$, the best estimate of the variance is
\begin{align}
  \sigma_t = \sqrt{\mu_t} \sim \sqrt{\overline{x}_t}.
\end{align}
This is the spread. The error on the mean is
\begin{align}
  \sigma_{t\mu} = \frac{\sigma_t}{\sqrt{N}} \sim \sqrt{\frac{\overline{x}}{N}}.
\end{align}
We'll look at a quick example: Take $N = 4$, with measurements 3, 4, 7, and 2.
\begin{align*}
  \mu_t                    & = \overline{x}_t = \frac{1}{4}\times(3 + 4 + 7 + 2) = 4              \\
  \sigma_t                 & = 2                                                                  \\
  \sigma_{t\mu}            & = \sqrt{4/4} = 1                                                     \\
  \text{therefore, } \mu_t & = 4 \pm 1
\end{align*}
\section{Error Matrices Introduction}
Error matrices are helpful for understanding correlations. consider two variables $u,\,v$ -- each is a Gaussian with $\sigma_u,\,\sigma_v$ and $\mu_u = \mu_v = 0$ (binormal).
\begin{align*}
  P(u) = \frac{1}{\sigma_u\sqrt{2\pi}}e^{-u^2/2\sigma_u^2} \qquad P(v) = \frac{1}{\sigma_v\sqrt{2\pi}}e^{-v^2/2\sigma_v^2}.
\end{align*}
The uncorrelated combination (probability of $u$ and $v$):
\begin{align}
  P(uv) = P(u)P(v) = \frac{1}{2\pi\sigma_u\sigma_v}\exp\left[-\frac{1}{2}\left(\frac{u^2}{\sigma_u^2}+\frac{v^2}{\sigma_v^2}\right)\right].
\end{align}
Let's focus on the $\left(u^2/\sigma_u^2 + v^2/\sigma_v^2\right)$ term in the exponential. If the sum of this term is equal to one, then the probability is goes down by a factor of $e^{-1/2}$. The term equal to 1 is also the equation of an ellipse.
\begin{align}
  \frac{u^2}{\sigma_u^2}+\frac{v^2}{\sigma_v^2} = 1
  \label{eq:ell}
\end{align}
Figure~\ref{fig:tri}a shows the ellipse and Figure~\ref{fig:tri}b shows the ellipse overlayed with a chosen value of $u$. Equation~\ref{eq:ell} can be written in matrix form:
\begin{align*}
  \begin{pmatrix}
    u                      & v
  \end{pmatrix}
  \underbrace{
    \begin{pmatrix}
      1/\sigma_u^2         & 0                                                                    \\
      0                    & 1/\sigma_v^2
  \end{pmatrix}}_{M^{-1}}
  \begin{pmatrix}
    u                                                                                \\
    v
  \end{pmatrix}
  = 1,
\end{align*}
where
\begin{align}
  M =
  \begin{pmatrix}
    \sigma_u^2             & 0                                                                    \\
    0                      & \sigma_v^2
  \end{pmatrix}.
\end{align}
$M$ above represents uncorrelated $u$ and $v$. In general the matrix elements of $M$ are represented as:
\begin{align}
  M_{ij} = \left\langle\left(w_i - \overline{w}_i\right)\left(w_j-\overline{w}_j\right)\right\rangle,
\end{align}
where $w_i,w_j$ in our matrix above is either $u$ or $v$. Therefore:
\begin{align*}
  \text{for } i = j        & \rightarrow \left\langle(u-\overline{u})^2\right\rangle = \sigma_u^2 \\
                           & \rightarrow \left\langle(v-\overline{v})^2\right\rangle = \sigma_v^2 \\
  \text{for } i \neq j     & \rightarrow \left\langle(u-\overline{u})(v-\overline{v})\right\rangle = \sigma_{uv}^2 =
  \lim_{N\rightarrow\infty}\frac{1}{N}\sum_k^N\left(u_k - \overline{u}\right)\left(v_k - \overline{v}\right)
\end{align*}
Now we'll wrap up with a quick example: suppose we have uncorrelated $u$ and $v$ where:
\begin{align*}
  u'                       & = u\cos\theta - v\sin\theta                                          \\
  v'                       & = u\sin\theta + v\cos\theta
\end{align*}
Which allows us to write an equation similar in form to equation~\ref{eq:ell}, with $a,b,c$ some constants:
\begin{align*}
  \frac{u^{\prime 2}}{a} + \frac{v^{\prime2}}{b} + \frac{u'v'}{c} = 1
\end{align*}
Now this equation is no longer a standard ellipse with a major and minor axis, it has some tilt to it, which we show in Figure~\ref{fig:tri}c. The most likely values for $u$ and $v$ are no longer the easy find at the $0$ for the partner variable. This will continue in the next lecture.
\begin{figure}
  \centering
  \begin{subfigure}{.25\textwidth}
    \centering
    \begin{tikzpicture}[scale=.7,
        grid/.style={
          color=white!50!black,stealth-stealth
        }
      ]
      \node (o) at (0,0) {};
      \draw [grid] (-2.2,0) -- (2.2,0) node [below,xshift=-6pt] {$u$};
      \draw [grid] (0,-2.7) -- (0,2.7) node [right,yshift=-6pt] {$v$};
      \draw (o) ellipse [start angle=0, end angle=360, x radius=1.3, y radius=2.0];
      \draw [-stealth] (o)++(5pt, 5pt) -- +(0,1) node [midway, right] {$\sigma_v$};
      \draw [-stealth] (o)++(5pt,-5pt) -- +(1,0) node [midway, below] {$\sigma_u$};
    \end{tikzpicture}
    \caption{}
  \end{subfigure}
  ~
  \begin{subfigure}{.25\textwidth}
    \centering
    \begin{tikzpicture}[scale=.7,
        grid/.style={
          color=white!50!black,stealth-stealth
        }
      ]
      \node (o) at (0,0) {};
      \draw [grid] (-2.2,0) -- (2.2,0) node [below,xshift=-6pt] {$u$};
      \draw [grid] (0,-2.7) -- (0,2.7) node [right,yshift=-6pt] {$v$};
      \draw (o) ellipse [start angle=0, end angle=360, x radius=1.3, y radius=2.0];
      \draw [-stealth] (o)++(5pt, 5pt) -- +(0,1) node [midway, right] {$\sigma_v$};
      \draw [-stealth] (o)++(5pt,-5pt) -- +(1,0) node [midway, below] {$\sigma_u$};
      \draw [grid,dashed,color=blue!70] (-.5,-2.7) -- (-.5,2.7);
    \end{tikzpicture}
    \caption{}
  \end{subfigure}
  ~
  \begin{subfigure}{.25\textwidth}
    \centering
    \begin{tikzpicture}[scale=.7,
        grid/.style={
          color=white!50!black,stealth-stealth
        }
      ]
      \node (o) at (0,0) {};
      \draw [grid] (-2.2,0) -- (2.2,0) node [below,xshift=-6pt] {$u$};
      \draw [grid] (0,-2.7) -- (0,2.7) node [right,yshift=-6pt] {$v$};
      \draw (o) ellipse [start angle=0, end angle=360, x radius=1.3, y radius=2.0,rotate=45];
      \draw [-stealth] (o)++(5pt, 5pt) -- +(0,1) node [midway, right] {$\sigma_v$};
      \draw [-stealth] (o)++(5pt,-5pt) -- +(1,0) node [midway, below] {$\sigma_u$};
    \end{tikzpicture}
    \caption{}
  \end{subfigure}
  \caption{For (a), (b), and (c), the black ellipse is called the \emph{contour of equal probability}. In (b), the blue dash represents a chosen $u$, and here the maximum probability would be at $v = 0$. In (c), the ellipse has been rotated by some angle $\theta$, and at some chosen $v$ or $u$, the maximum probability is not longer at $u=0$ and $v=0$, respectively.}
  \label{fig:tri}
\end{figure}

\end{document}


\XtoCBlock{Mult}
\label{block:Mult}
\begin{figure}[H]\includegraphics{Mult}\end{figure}

\begin{XtoCtabular}{Inports}
In1 & Multiplicand 1\tabularnewline
\hline
In2 & Multiplicand 2\tabularnewline
\hline
\end{XtoCtabular}

\begin{XtoCtabular}{Outports}
Out & Product\tabularnewline
\hline
\end{XtoCtabular}

\subsubsection*{Description:}
Multiplication of input 1 with input 2.

% include optional documentation file
\InputIfFileExists{\XcHomePath/Library/Math/Doc/Mult_Info.tex}{\vspace{1ex}}{}

\subsubsection*{Implementations:}
\begin{tabular}{l l}
\textbf{FiP8} & 8 Bit Fixed Point Implementation\tabularnewline
\textbf{FiP16} & 16 Bit Fixed Point Implementation\tabularnewline
\textbf{FiP32} & 32 Bit Fixed Point Implementation\tabularnewline
\textbf{Float32} & 32 Bit Floating Point Implementation\tabularnewline
\textbf{Float64} & 64 Bit Floating Point Implementation\tabularnewline
\end{tabular}

\XtoCImplementation{FiP8}
\index{Block ID!4944}
\nopagebreak[0]
% Implementation details
\begin{tabular}{l l}
\textbf{Name} & FiP8 \tabularnewline
\textbf{ID} & 4944 \tabularnewline
\textbf{Revision} & 0.1 \tabularnewline
\textbf{C filename} & Mult\_FiP8.c \tabularnewline
\textbf{H filename} & Mult\_FiP8.h \tabularnewline
\end{tabular}
\vspace{1ex}

8 Bit Fixed Point Implementation

% Implementation data structure
\XtoCDataStruct{Data Structure:}
\begin{lstlisting}
typedef struct {
     uint16        ID;
     int8          *In1;
     int8          *In2;
     int8          Out;
} MULT_FIP8;
\end{lstlisting}

\ifdefined \AddTestReports
\InputIfFileExists{\XcHomePath/Library/Math/Doc/Test_Mult_FiP8.tex}{}{}
\fi
\XtoCImplementation{FiP16}
\index{Block ID!4945}
\nopagebreak[0]
% Implementation details
\begin{tabular}{l l}
\textbf{Name} & FiP16 \tabularnewline
\textbf{ID} & 4945 \tabularnewline
\textbf{Revision} & 0.1 \tabularnewline
\textbf{C filename} & Mult\_FiP16.c \tabularnewline
\textbf{H filename} & Mult\_FiP16.h \tabularnewline
\end{tabular}
\vspace{1ex}

16 Bit Fixed Point Implementation

% Implementation data structure
\XtoCDataStruct{Data Structure:}
\begin{lstlisting}
typedef struct {
     uint16        ID;
     int16         *In1;
     int16         *In2;
     int16         Out;
} MULT_FIP16;
\end{lstlisting}

\ifdefined \AddTestReports
\InputIfFileExists{\XcHomePath/Library/Math/Doc/Test_Mult_FiP16.tex}{}{}
\fi
\XtoCImplementation{FiP32}
\index{Block ID!4946}
\nopagebreak[0]
% Implementation details
\begin{tabular}{l l}
\textbf{Name} & FiP32 \tabularnewline
\textbf{ID} & 4946 \tabularnewline
\textbf{Revision} & 0.1 \tabularnewline
\textbf{C filename} & Mult\_FiP32.c \tabularnewline
\textbf{H filename} & Mult\_FiP32.h \tabularnewline
\end{tabular}
\vspace{1ex}

32 Bit Fixed Point Implementation

% Implementation data structure
\XtoCDataStruct{Data Structure:}
\begin{lstlisting}
typedef struct {
     uint16        ID;
     int32         *In1;
     int32         *In2;
     int32         Out;
} MULT_FIP32;
\end{lstlisting}

\ifdefined \AddTestReports
\InputIfFileExists{\XcHomePath/Library/Math/Doc/Test_Mult_FiP32.tex}{}{}
\fi
\XtoCImplementation{Float32}
\index{Block ID!4947}
\nopagebreak[0]
% Implementation details
\begin{tabular}{l l}
\textbf{Name} & Float32 \tabularnewline
\textbf{ID} & 4947 \tabularnewline
\textbf{Revision} & 0.1 \tabularnewline
\textbf{C filename} & Mult\_Float32.c \tabularnewline
\textbf{H filename} & Mult\_Float32.h \tabularnewline
\end{tabular}
\vspace{1ex}

32 Bit Floating Point Implementation

% Implementation data structure
\XtoCDataStruct{Data Structure:}
\begin{lstlisting}
typedef struct {
     uint16        ID;
     float32       *In1;
     float32       *In2;
     float32       Out;
} MULT_FLOAT32;
\end{lstlisting}

\ifdefined \AddTestReports
\InputIfFileExists{\XcHomePath/Library/Math/Doc/Test_Mult_Float32.tex}{}{}
\fi
\XtoCImplementation{Float64}
\index{Block ID!4948}
\nopagebreak[0]
% Implementation details
\begin{tabular}{l l}
\textbf{Name} & Float64 \tabularnewline
\textbf{ID} & 4948 \tabularnewline
\textbf{Revision} & 0.1 \tabularnewline
\textbf{C filename} & Mult\_Float64.c \tabularnewline
\textbf{H filename} & Mult\_Float64.h \tabularnewline
\end{tabular}
\vspace{1ex}

64 Bit Floating Point Implementation

% Implementation data structure
\XtoCDataStruct{Data Structure:}
\begin{lstlisting}
typedef struct {
     uint16        ID;
     float64       *In1;
     float64       *In2;
     float64       Out;
} MULT_FLOAT64;
\end{lstlisting}

\ifdefined \AddTestReports
\InputIfFileExists{\XcHomePath/Library/Math/Doc/Test_Mult_Float64.tex}{}{}
\fi


\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\author{Pranav Satheesh}
\title{GR and Black Holes Assignment}
\begin{document}
\maketitle

\section{Clocks, Gravity and Gravitational Redshift}

We will now consider a \emph{Gedanken experiment}. Alice, in the nose of the rocket, emits signals at equal intervals ($\Delta \tau_{A}$) on a clock at her height ($h$). Bob, in the tail, measures the time interval ($\Delta \tau_{B}$) between receipt of the signals on an identical clock at his location. As shown in the left figure \ref{figure1}, the rocket is stationary on Earth's surface where bodies fall with acceleration $g$.
We will derive the relation between $\Delta \tau_{A}$ and $\Delta \tau_{B}$.

\begin{figure}[!htb]
\includegraphics[scale=0.3]{gravity1.png}
\centering
\caption{The thought experiment showing equivalence between a stationary ship on earth where there is uniform acceleration due to gravity $g$. The second figure is an equivalent frame where the rocket is accelerating. }
\label{figure1}
\end{figure}

 \begin{enumerate}
 \item Consider the rocket accelerating along the z-axis. Suppose that t = 0 is the time the first pulse is emitted, $t_{1}$ is the time it is received. $\Delta \tau_{A}$ is the time second pulse is emitted, and $t_{1} + \Delta \tau_{B}$ is the time the second pulse is received as shown in the figure \ref{figure2}. Write down the distance travelled by the \textbf{first} and \textbf{second} pulse in terms of the times defined.

\begin{figure}[!htb]
\centering
\includegraphics[scale=0.3]{gravity2.png}
\caption{The pulse sent at different times}
\label{figure2}
\end{figure}

 \item Now keep only the \textbf{linear} terms in the equations after substituting $z(t)$ in terms of the uniform acceleration $g$, show that
 \begin{equation}
 	\Delta \tau_{B} =  \Delta \tau_{B} \bigg(1 - \frac{gh}{c^2}\bigg)
 	\label{eq:1}
 \end{equation}

 \item According to \emph{Equivalence Principle}, the same should apply to unifrom gravitational field $g$ on Earth. Relate \eqref{eq:1} to the gravitational potenmtials at Alice ($\Phi_{A}$) and Bob's($\Phi_{B}$) location. We arrive at a very general GR result for any general potential $\Phi$.

 \begin{equation}
 \Delta \tau_{B} = \bigg(1 + \frac{\Phi_{A} - \Phi_{B}}{c^2} \bigg) \Delta \tau_{A}
 \end{equation}

When the receiver is at a higher gravitational
potential than the emitter, the signals will be received more slowly than they were
emitted. When the receiver is at a lower potential than the emitter, the signals will
be received more quickly.

\item Let's have some fun now. Say you are working on the top floor of your department building. Your heart is like a clock, we wil use it for our measurements! Using \eqref{eq:1} figure out how fast a heart
will beat more times on the top floor in a given interval of time than the heart of a
your friend on the ground floor.Assume a heighr of 30m.

 \item We can apply \eqref{eq:1} to photons with frequency. Consider light emited from the surface of a star with frequency $\omega_{*}$ which is recieved at a very farway from the star with frequency $\omega_{\infty}$. This will be lesser than $\omega_{*}$ and this phenomena is called \textbf{gravitational redshift}. Since frequency is \emph{redshifted}. Arrive at this relation.

 \end{enumerate}

\section{Schwarschild Metric properties}
You will now derive some properties of Schwarschild Metric

\begin{equation}
ds^2 = -\bigg(1 - \frac{2 M}{r}\bigg) dt^2 + \bigg(1- \frac{2M}{r} \bigg)^{-1} dr^2 + r^2 ( d \theta^2 + sin^2 \theta d \phi)
\end{equation}

\begin{enumerate}
 \item Firstly, figure out the singularities in the metric i.e, find r where the metric coefficient(s) blow up.
 \item Do a coordinate transformation to \emph{Edington Finkelstein} coordinates $(v,r)$

 \begin{equation}
 t = v - r - 2M log \bigg|\frac{r}{2M}-1 \bigg|
 \end{equation}

 Show that in this coordinates the metric becomes
 \begin{equation}
 ds^2 = -\bigg(1 - \frac{2 M}{r}\bigg) dv^2 + 2 dv dr + r^2 ( d \theta^2 + sin^2 \theta d \phi)
 \end{equation}
 Notice that the singularity at $r=2M$ is removed here. This singularity was just a \emph{coordinate singularity}.

 \item If $|M/r| <<1$ then expand the metric to arrive at the static, weak field metric. Now using the newtonian potential,

 $$\Phi = - \frac{G M}{r}$$

 show that the weak field metric becomes:

 $$ds^2 = -\bigg(1 + 2 \Phi \bigg) dt^2 + \bigg(1- 2 \Phi \bigg)(dx^2 + dy^2 + dz^2)$$

\end{enumerate}

\section{Simple calculation of Chandrashekhar Mass Limit}

You will now do a back-of-the-envelope calculation of the Chandreshakar Mass limit.

White dwarfs support against their gravity by the pressure of electrons from Pauli exclusion principle. This pressure is called \emph{Fermi Pressure}.

\begin{enumerate}
\item Consider a spherical configuration of radius R consisting of A electrons and A protons. We can think of each of the electron to occupy a volume of characteristic size $\lambda$ such that there is a notat of A electrons occupying a spherical volume of radius R. Then,

$$\lambda \sim \frac{R}{A^{1/3}}.$$
Now uising the deBroglie relatiopn $p = 2 \pi \hbar / \lambda$, calculate the approx. Fermi momentum, $p_{F}$.

\item When the sphere is compressed, $p_{F}$ rises and has to compete the gravitational pressure. Using the relativistic energy $E = [(p_{F} c)^2 + (m_{e} c^2)^2]^{1/2} \approx p_{F} c$, show that the total Fermi energy is

\begin{equation}
E_{F} \sim A^{4/3} \frac{\hbar c}{R}
\label{eq:2}
\end{equation}

\item The protons supply most of the mass. The total mass of protons is $m_{p} A$. Calculate the gravitational energy $E_{G}$
\begin{equation}
E_{G} \sim -  \frac{G (m_{p} A)^2}{R}
\label{eq:3}
\end{equation}

\item Now equate \eqref{eq:2} and \eqref{eq:3} to arrive at the critical A to balance out the graviutational and fermi pressure.Plugging in the constants show that $A_{crit} \sim 10^{57}$.

If A is sufficiently large, the total energy $E = E_{F} + E_{G}$ will be negative and the white dwarf will collapse

\item Further show that the critical Mass associated with $A_{crit}$ is of the order of $M_{crit} \sim 1 M_{\odot}$. If you follow the careful calculation that requires a bit of Quantum and Statistical Mechanics, you will arrive at the number Chandra found:

\begin{equation}
M_{chandra} = 1.4 M_{\odot}
\end{equation}

\end{enumerate}

\end{document}