\chapter{Conclusion and Further Work}
\label{ch:8}

\section{Conclusion}

% In this thesis we studied how the data format of trajectories and outlined seven different approaches for quantifying the similarity distance between them. After describing how each of the algorithms were designed, a set up was created so for experimentally comparing them. A data set and an application of similarity scores were chosen so that the effects of the distance measure could be as isolated as possible for a perceptible comparison.

In this thesis, we studied seven similarity measures for trajectory data, five conventional ones and two recent ones.
First, we clarified what constitutes a trajectory, and then we discussed how the notion of similarity of them varies.
The measures we reviewed vary in how they defined similarity and we elaborated upon some of their advantages and disadvantages.

In order to experimentally compare the algorithms, we defined an application wherein the only thing that varied was the similarity distance computation.
The application we decided on was clustering and we used two techniques for creating them.
The clusters gave us a vantage point for further description of the measures, and from the clusters, we were able to observe the theoretical characteristics of the measures in practice.
We summarize what has been achieved in this thesis by referring back to the research objectives:

\subsubsection*{Research Objectives 1 and 2:}
The conventional similarity measures we examined were the Euclidean distance, Dynamic Time Warping, Hausdorff Distance, Edit Distance on Real Sequence, and Edit distance with Real Penalty.
The latter two are newer than the other ones, however, their prominence in the literature establishes them as conventional methods.
A commonality between these measures is that they are not context-aware.
In terms of noise tolerance, there was no consistency, and as for elasticity all but Ed are could adapt to local time shifts.

Both Move-Split-Merge and Symmetric Segment Path Distance are methods that were developed in order to address the shortcomings of the conventional methods.
Based on this we categorized them as the newer distance measures.

\clearpage
The development of MSM was a response to DTW and ERP while SSPD was an advancement of Hd.
A feature that is shared between MSM and SSPD is that they both were designed to account for whole trajectory similarity.
Additionally, they are more tolerant to noise than their respective conventional method inspirations.
We saw this experimentally as MSM producing crisper clusterings than DTW and ERP and SSPD producing crisper clusterings than Hd.

We were not able to determine any effects of metricity, neither for the conventional methods nor for the newer ones.
For the visual representation of how trajectory features were treated by the we refer to \Cref{app:ap-clu,app:h-clu}

\subsubsection*{Research Objective 3:}
In our set up, there was only one application that tested the algorithms’ performance against each other.
The lack of diverse applications and their removal from real-world observations are limiting how much insight we could gain regarding broader uses for the measures. Nevertheless, the variance of the cluster we generated demonstrates that similarity distance measure choice matters.

 We could have constructed arguments that would have framed a given measure as the most suited one for shape-based clustering. However, we reiterate could not have generalized its applicability to other tasks.

Optimizing for global shape-similarity should be prioritized if the intended application is computer vision or migration analysis.
On the other hand, locally shifted similarities are needed for database management tasks such as outlier detection and trajectory uncertainty. An outlier in this context could be either a trajectory element that stands out from its surrounding elements or a trajectory that stands out from the rest. Trajectory uncertainty management seeks to increase the utility of trajectories by approximating locations between observations.
In both cases, a reference model of local resemblance is more apt.

Consequently, we remark that the accuracy and reliability of analysis or management tasks depend on whether or not an appropriate algorithm was chosen.

% In terms of usage for different applications here was only one application in this thesis. While being limiting for the insight we gathered it was enough to demonstrate that choice matters. All methods described were supposedly spatial-only trajectory similarity but the results they gave varied a lot – this point further supports the theory of there not being a ground truth of what similarity is for time-series.
% e
% Algorithm selection had a substantial influence over the results, even in this scaled down experiment. We argue that one should not picking a method purely on the basis of it being prominent in the literature as it may biases that are not evident from the description resulting in misleading findings.

\clearpage
\section{Further Work}

% The work done in thesis a good foundation for more experiment.
The work we have done for this thesis explored just one class of trajectory similarity and one particular application for similarity measures.
There are aspects of trajectory similarity we did not inquire into.
Thus we suggest two extensions of our experiment which would facilitate a more comprehensive study.

% Larger data set, longer trajectories (trajectories that have not been arifically shortened), both.
As we noted in \Cref{ch:5}, our set up was not conducive to examining the differences in computational complexity.
If it were possible, we would have liked to include an evaluation of measures’ performances; both for the data set used here and sets where the lengths of the trajectories had not been artificially shortened.
As with most algorithms, it is good to be informed about how they will perform as the size of the data or the data set increases.

% There are are would be conductive to a more comprehensive study of trajectory similarly.
It would make sense to include more applications for the measures.
Along with clustering, classification is a commonly selected application for testing the measures.
However, we argue it would be interesting to run either an outlier detection or noise removal task.
This could hopefully highlight peculiarities of how the measures distinguish the trajectories.

% \subsection{Thematic Areas for Continued Research}


\section*{Arrays}

Arrays in Source are created using literal array expressions:
\begin{lstlisting}
let my_array_1 = [];
let my_array_2 = [42, 71, 13];
\end{lstlisting}
Arrays in Source are limited to integers as keys.
In statements like
\begin{lstlisting}
a[i];
a[j] = v;
\end{lstlisting}
the values \lstinline{i} and \lstinline{j} must be integers if \lstinline{a} is an array.

Note that pairs in Source are represented by arrays with two elements. Therefore,
\begin{lstlisting}
is_pair([1, 2]);
\end{lstlisting}
and
\begin{lstlisting}
equal(pair(1, 2), [1, 2]);
\end{lstlisting}
evaluate to \texttt{true}.

Access of an array with an integer index to which no prior assignment has been
made on the array, returns \texttt{undefined}.


\section{Symbolic constraints and propagation}

\paragraph{Principle of convergent intelligence} The world
manifest constraints and regularities. If a computer is to
exhibit intelligence, it must exploit those constraints and
regularities, no matter of what the computer happens to be made.

\paragraph{Describe-to-explain principle} The act of detailed
description may turn probabilistic regularities into entirely
deterministic constrains.

\paragraph{Marr's methodological principles}
\begin{enumerate}
  \item Identify the problem
  \item Select or develop an appropriate representation
  \item Expose constraints or regularities
  \item Create particular procedures
  \item Verify via experiments
\end{enumerate}

\paragraph{Contraction net} is a representation that is a \textit{frame
system}, in which:
\begin{itemize}
  \item Lexically and structurally, certain frame classes
    identify a finite list of application-specific
    interpretations
  \item Procedurally, demon procerures enforce compatibility
    constraints among connected frames
\end{itemize}

\subsection{Applications}

\subsubsection{3D object recognizion in 2D images}

\paragraph{Labeled drawing} is a representation that is a \textit{frame
system}, in which:
\begin{itemize}
  \item Lexically, there are line frames and junctions frames.
    Lines may be convex, cocave, or boundary lines. Junctions may
    be \textit{L}, \textit{Fork}, \textit{T}, or \textit{Arrow}
    junctions
  \item Structurally, junctions frames are connected by line
    frames. Also, each junction frame contains a list of
    interpretation combinations for its connecting lines
  \item Semantically, line frames denotee physical edges.
    Junction frames denote physical vertexes
  \item Procedurally, demon procedures enforce the constraint
    that each junction lavel must be compatible with at least one
    of the junction labels at each of the neighboring junctions
\end{itemize}

\subsubsection{Time-interval relations and scheduling}

\paragraph{Interval net} is a representation that is a
\textit{contraction net}, in which:
\begin{itemize}
  \item Lexically and semantically there are interval frames
    denoting time intervals and lik frames denoting time
    relations: specifically: $\overrightarrow{before}$,
    $\overrightarrow{during}$, $\overrightarrow{overlaps}$,
    $\overrightarrow{meets}$, $\overrightarrow{starts}$,
    $\overrightarrow{finishes}$, $\overrightarrow{is equal to}$,
    and their mirrors
  \item Structurally, interval frames are connected by link
    frames
  \item Procedurally, demon procedures enforce the constraint
    that the interpretations allowed for a link frame between two
    intervals must be consistent with the interpretations allowed
    for the two link frames joining the two intervals to a third
    interval
\end{itemize}

\subsection{Map coloring - Lecture notes}

\begin{definition}
  A \textbf{variable} $v$ is something that can have an assigment
\end{definition}

\begin{definition}
  A \textbf{value} $x$ is something that can be an assigment
\end{definition}

\begin{definition}
  A \textbf{domain} $D$ is a bag of values
\end{definition}

\begin{definition}
  A \textbf{constraint} $c$ is a limit on variable values
\end{definition}

Procedure:
\begin{itemize}
  \item For each \textit{DFS} assignment
  \item For each variable $v_i$ considered.  A \textit{considered
    variable} is some variable that may affect the assignment decision
  \item For each $x_i$ in $D_i$
  \item For each constraint $c(x_i, x_j)$ where $x_j \in D_j$
  \item If $\nexists x_j$ such that $c(x_i, x_j)$ is satisfied,
    then remove $x_i$ from $D_i$.
  \item If $D_i$ is empty, backtrack
\end{itemize}

Examples of \textit{considered variables}:
\begin{itemize}
  \item Nothing: leads to wrong outputs
  \item Assignment: constraints are too slack
  \item Neighbors' only assignment: can succeed but depends on
    assigment ordering. If most constrained assignments are
    considered first, then it is fast; vice versa, might not end
  \item Propagate checking through variables with reduced domain
    reduced to a single value
  \item Propagate checking through variables with reduced domains
  \item Everything: too computationally intensive
\end{itemize}


\chapter{Introduction}\label{ch:intro}

Floodlight is an open source and Java based controller. It works with the
OpenFlow protocol in order to produce flow tables for network switches and is
used for the SDN (Software Defined Networks) architecture in order to improve
flexibility for large scale and complex network management.

Normally Floodlight makes use of the Dijkstra's algorithm to find the minimum
cost broadcast tree for the network topology according to a certain metric
(bandwidth for example).

For this project we implement a new module which manages routing, implementing a
different type of algorithm to replace Dijkstra based on the Dual Ascent
approach, that is a dual version of the minimum Steiner tree problem.

We will then collect statistics on the total cost of the broadcast tree produced
by Dijkstra and the Dual Ascent algorithm and we will compare them. We will also
compare the throughput between hosts when the two algorithms are used using the
\code{iperf} tool.


\documentclass[12]{scrartcl}
\usepackage{amssymb,amsmath,gensymb,dsfont,calc,multicol,fullpage}
\makeatletter
\newcommand\Aboxed[1]{
   \@Aboxed#1\ENDDNE}
\def\@Aboxed#1&#2\ENDDNE{%
   &
   \settowidth\@tempdima{$\displaystyle#1{}$}
   \setlength\@tempdima{\@tempdima+\fboxsep+\fboxrule}
   \kern-\@tempdima
   \boxed{#1#2}
}
\makeatother

\begin{document}

\title{Homework 29, Section 5.3: 5, 21, 22, 25}
\author{Alex Gordon}
\date{\today}
\maketitle
\section*{Homework}
\subsection*{5.}
By the Diagonalization Theorem, eigenvectors form the columns of the left factor and they correspond respectively to the eigenvalues on the diagonal of the middle factor.
$\lambda = 5 \begin{bmatrix}  1 \\1 \\ 1  \end{bmatrix}; \lambda = 5 \begin{bmatrix}  -2 \\0 \\ 1  \end{bmatrix}, \begin{bmatrix}  0 \\1 \\ 0  \end{bmatrix}$
\subsection*{21. A)}
False. The symbol D does not automatically denote a diagonal matrix.
\subsection*{21. B)}
True. A is diagonalizable if and only if there are enough eigenvectors to form a basis of $R^n$. WE call such a basis an eigenvector basis of $R^n$
\subsection*{21. C)}
False. The 3x3 matrix in Example 4 has 3 eigenvalues but is not diagonalizable
\subsection*{21. D)}
False. Invertibility depends on - not being an eigenvalue. A Diagonalizable matrix may or may not have 0 as an eigenvalue.
\subsection*{22. A)}
False. The n eigenvectors must be linearly independent by the Diagonalization theorem.
\subsection*{22. B)}
False. The matrix in example 3 is Diagonalizable but it only has 2 different eigenvalues.
\subsection*{22. C)}
True. This follows from AP = PD and the first two formulas given in the section 5.3
\subsection*{22. D)}
False. In example 4 the matrix is invertible because 0 is not an eigenvalue, but the matrix is not Diagonalizable.
\subsection*{25.}
Let $\{ v_1 \}$be a basis for the one-dimensional eigenspace. Let $v_2$ and $v_3$ form a basis for the two dimensional eigenspace and let $v_4$ be any eigenvector in the eigenspace. By theorem 7, $v_1, ... , v_4$ has to be linearly independent. It then follows that since A is 4x4, the Diagonalization theorem shows that A is diagonalizable.

\end{document}


\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{dsfont, graphicx,color}

%opening
\title{Incomplete quantum tomography using neural networks}
\author{Olivia Di Matteo}

\begin{document}

\maketitle

\section{Problem formalism}

The goal of quantum tomography is, given (many identical copies of) some arbitrary quantum state, take a series of measurements in order to determine its density matrix. When the dimension of the system $d$ is prime ($p$), or power of prime ($p^n$), a complete set of $d + 1$ bases that are mutually unbiased comprise an optimal set of measurements. These can be written in vector form, but another common way of expressing them is as $d + 1$ sets of $d - 1$ commuting observables (total of $d^2-1$) which have as mutual eigenvectors bases that are MU.

A density matrix $\rho$ can be expressed in terms of $d^2 - 1$ parameters; while an arbitrary complex $d \times d$ matrix contains $2d^2$ entries, the hermiticity and the condition on the trace of a density matrix, i.e. $\hbox{Tr}(\rho) = 1$ reduce the number of parameters required. A convenient way of expressing the density matrix is in terms of its expansion coefficients in an operator basis:
\begin{equation}
 \rho = \frac{1}{d} \mathds{1} + \frac{1}{d} \sum_{i = 1}^{d^2 - 1} a_i \Lambda_i
\end{equation}
\noindent The operators in the basis should be traceless, and trace orthogonal $\hbox{Tr}(\Lambda_i \Lambda_j) = c \delta_{ij}$. Furthermore, if they are Hermitian, the  coefficients $a_i = \hbox{Tr}( \rho \Lambda_i )$ will be real. The canonical example is of course when $d = 2$ and $\Lambda = \{ \sigma_x, \sigma_y, \sigma_z \}$, so that the vector $\mathbf{a} = (a_1, a_2, a_3)$ is simply the 2-dimensional Bloch vector.

The goal of a tomographic process would then be, given some measurement data, to determine the values of the coefficients $a_i$, and consequently $\rho$. \emph{In what follows, we focus exclusively on the special case where $\rho$ is a unknown random pure state.}

\section{Basic version: Incomplete tomography using neural networks}

If we consider multi-qubit systems, i.e. $d = 2^n$, the number of measurements required scales poorly with the number of qubits. As larger numbers of qubits become experimentally tractable, we will need effective methods of incomplete tomography to make the reconstruction process feasible. Efforts in this direction have involved compressed sensing, and least-bias maximum-likelihood state estimation (LBMLE). We propose here a method based on neural networks. The idea here is that the networks can be trained to reconstruct states based on simulated incomplete experimental data; this allows the heavy lifting to be done computationally, as one needs only train the network once, and then feed it the ``real'' experimental results. There is also a huge amount of versatility as one can simply adapt the process to train using whatever measurements are taken in a particular experimental setup.

We propose a basic feed-forward neural network for this task, shown in figure \ref{fig:nn}. The input layer consists of measurement frequencies for the measured bases. These are generated `experimentally' by computing the set of projectors for each basis, and the probability of that outcome via the Born rule. Then we use MC simulation to generate frequencies of each outcome (10000 points seems to give us frequencies pretty close to the original). The output layer consists of the basis coefficients above, the $a_i$.

\begin{figure}
 \includegraphics[scale=0.5]{nn_schematic}
 \caption{Simple diagram of neural network. The measurement frequencies from each measured basis are passed in as input nodes. The hidden layer seems to work well with a quadratic number of nodes, after which there are diminishing returns. The output layer should have $d^2 - 1$ nodes.}
 \label{fig:nn}
\end{figure}

Through experimentation we need to determine the properties of the hidden layer(s) that are the most effective for this purpose. So far things that work well are:
\begin{itemize}
\item {We choose tanh as the activation function, as it takes a range (-1, 1) and the $a_i$ can be positive or negative.}
\item {We choose the cosine proximity as the loss function; this is physically motivated, as in the single-qubit case it can be thought of as the angle between Bloch vectors, which one should try to minimize to get as close as possible to the true state.}
\item {We use a single hidden layer. Adding more seems to give us no benefits, except for longer coffee breaks while the code runs.}
\item {The networks are trained using data taken from Haar-random pure states.}
\end{itemize}

\noindent We also need a way to quantify the performance of the network. We choose the \textbf{fidelity}, however there are a few hiccups here:
\begin{itemize}
 \item{The output of the network is not always normalized. As we assume we are working strictly with pure states, before computing the fidelity we normalize the vectors.}
 \item{Once normalized, the state is not necessarily a valid quantum state, i.e. is not positive semidefinite (PSD), in particular for $d > 2$. In cases I have looked at, there is some very tiny non-zero eigenvalue, even in the single qubit case. Therefore to get a physical state estimation we should look to the closest PSD matrix.}
\end{itemize}

\section{1 qubit}

As proof of concept, we train the network to reconstruct a single qubit pure state. We use a single hidden layer of size 64 (input size is 6 for all bases, 4 for two bases, and output size is always 3). We trained our network with 9000 Haar-random pure states, and tested on 1000 additional ones.

Training the network with all 3 MUBs yields an average fidelity of 0.9999, which is a solid sanity check. We then attempt to train it using simulated measurement data from only 2 of the 3 MUBs. The network takes only a second or two to train (data generation and comparison with LBMLE takes far longer!). Our network reconstructs states with a fidelity of 0.944 on average; this can be compared, using the same test data, with the LBMLE algorithm, which reconstructs the states with an average of 0.91. Results are discussed in more detail in Section \ref{sec:angdep}.

\textcolor{red}{To do: plots of dependence of fidelity on hidden layer size, and on number of training data points}

\section{1 qutrit}

We choose as our operator basis the Gell-Mann matrices. The qutrit is an interesting case because density matrices constructed using arbitrary vectors of norm 1 are Hermitian and have trace 1, but are not necessarily PSD. As a consequence there has been a lot of work done in attempt to characterize the regions of the qutrit Bloch sphere that produce `legal' states (add references).

Regardless of this fact, it seems that the neural network is able to learn quite well how to reconstruct qutrit states. We train again using largely the same parameters as the qubit case: 10000 Haar-random pure states split 9000/1000, and still a hidden layer of size 64. States that are not PSD after reconstruction are kicked over to the closest PSD state.

I put the results in Table \ref{tab:qutrit}. Measuring all 4 bases of course reconstructs the states with fidelity close to 1, so I've not included this in the table. With 3 bases, the two algorithms perform comparably with an average fidelity of around 0.958. What is more interesting is that when we measure in only 2 bases, the network begins to perform better.

\begin{table}[h!]
 \centering
 \begin{tabular}{|c||c|c|c|}
 \hline
  Num. meas. bases &  Fidelity NN & Fidelity LBMLE \\ \hline
  3 & 0.9582 &  0.9580 \\
  2 & 0.8978 & 0.8547  \\ \hline
 \end{tabular}
 \caption{Fidelity using incomplete measurements. Here I averaged together results of all choices of 2/3 bases, as they weren't really too different.}
 \label{tab:qutrit}
\end{table}

\section{2 qubits}

After successfully chasing down some rogue constants and normalization factors, I was able to get the 2 qubit case training. I used again 10000 states, which seems to be sufficient. The hidden layer here has size 128. I changed this randomly because I was messing around with things when they didn't work, and just didn't bother to change it back. The states produced are still quite close to being positive semi-definite, though not perfect.

Training is still extremely fast, in only a couple seconds. The LBMLE process begins to take a long time, however. Results are in table \ref{tab:2qubits}. This is quite interesting; LBMLE seems to slightly outperform the network until we are measuring in only 2 bases; then the network becomes significantly more successful.

\begin{table}[h!]
 \centering
 \begin{tabular}{|c||c|c|c|}
 \hline
  Num. meas. bases &  Fidelity NN & Fidelity LBMLE \\ \hline
  5 (All) & 0.99988 &  0.99798 \\
  4 & 0.96154 & 0.98728 \\
  3 & 0.91237 &  0.93492 \\
  2 &  0.84865 & 0.76785 \\
  1 & 0.76184 & 0.62757 \\ \hline
 \end{tabular}
 \caption{Fidelity using incomplete measurements. There are too many combinations, so I chose only one set of 4, 3, and 2 bases each time.}
 \label{tab:2qubits}
\end{table}

\section{3 qubits}

For 3 qubits, I had to increase significantly the amount of data as well as the size of the hidden layer (50000 points, 45000 for training, and hidden layer size 512). See Table \ref{tab:3qubits}. Unfortunately for this amount of data, comparison with the LBMLE algorithm takes over 1 hour or more, depending on the number of bases measured. Thus for the time being I have stopped doing the comparison and am looking mostly at the parameters of the network itself, as there are some interesting relationships appearing (plotted in figures \ref{fig:dim8_average_fidelity} and \ref{fig:dim8_training_time}.

\begin{table}[h!]
 \centering
 \begin{tabular}{|c||c|c|c|}
 \hline
  Num. meas. bases &  Fidelity NN & Training time \\ \hline
  9 (All) & 0.999 & 518.870 \\
  8 &0.976 & 501.368\\
  7 & 0.949 & 483.277 \\
  6 & 0.918 & 466.364 \\
  5 & 0.885&  448.547 \\
  4 & 0.846 & 428.746 \\
  3 & 0.798 &  412.304 \\
  2 &  0.737 & 394.760 \\
  1 & 0.650  & 357.285 \\ \hline
 \end{tabular}
 \caption{Fidelity using incomplete measurements. 50000 data points, 45000 for training, hidden layer size 512. Tried doubling the number of data points for 5 bases case, no change in fidelity, so I suspect 50000 is enough. The relationship between time and number of bases is linear; between fidelity and number of bases is exponential.}
 \label{tab:3qubits}
\end{table}

\begin{figure}
 \includegraphics[scale=0.8]{dim8_average_fidelity}
 \caption{Average fidelity vs number of bases measured in dimension 8 tests.}
 \label{fig:dim8_average_fidelity}
\end{figure}

\begin{figure}
 \includegraphics[scale=0.8]{dim8_training_time.eps}
 \caption{Network training time vs number of bases measured in dimension 8 tests.}
 \label{fig:dim8_training_time}
\end{figure}

It is interesting too look at the distribution of the fidelities for each case.

\begin{figure}
 \includegraphics[scale=0.6]{dim8_fidelity_distributions}
 \caption{Distributions of the fidelity for varying number of measured bases. As expected the range broadens as we take fewer measurements. The case for all 9 bases is so sharply peaked around 1 that it essentially washes out the others, so it's not plotted here.}
 \label{fig:dim8_fidelity_distributions}
\end{figure}

\section{Next questions}
 Some obvious questions to consider next:
 \begin{itemize}
  \item What happens for mixed states? Does the neural network still fare well? We cannot normalize it now, it may live inside the Bloch sphere. How do we ensure that the output is always a vector with norm $< 1$ still close to the original state?
 \end{itemize}

\section{Angular dependence of single qubit reconstructions} \label{sec:angdep}

\textcolor{red}{This is some interesting stuff that goes beyond the scope of doing tomo with neural networks, and focuses more on the specific choice of measurements in an incomplete tomography setting. However it's still quite a neat result, and allows us to see where exactly the neural network is outperforming the existing algorithm.}

One important thing to consider is the quality of the data set that goes into the network training. We used Haar-random states (HRS), which are generated by hitting a fiducial state by a Haar-random unitary (HRU). HRUs are distributed in a distinct way; in particular, the ``weight" factor in the measure of integration is
\begin{equation}
 dU \simeq \sin \beta d\alpha d\beta d\gamma
\end{equation}
where $\alpha, \beta, \gamma$ are the 3 parameters which allow us to construct the matrix
\begin{equation}
 U(\alpha, \beta, \gamma) = \left(
  \begin{array}{cc}
   e^{i \alpha} \cos( \beta/2) & -e^{i \gamma} \sin(\beta / 2) \\
    e^{-i \gamma} \sin(\beta / 2) & e^{-i \alpha} \cos( \beta/2)
  \end{array}
  \right)
\end{equation}
 (more technically this is SU(2) rather than U(2) I guess). This looks very similar to the integration measure in spherical coordinates, when integrating over a sphere of radius 1. In this sense, $\beta$ plays the role of the polar angle $\theta$. The extra factor of $\sin \beta$ takes its maximum value at $\beta = \pi / 2$, namely at the equator of the sphere; there is consequently more `weight' added to these states, meaning that \emph{equatorial states are more likely to occur than, say, polar states, when randomly sampling from the distribution of HRUs}.

 To that end, I was initially concerned that using a training dataset based on HRS would mean that there are more states around the equator, and that consequently we would be able to learn these states better than the polar states. So I decided to plot the polar angle of the states on the Bloch sphere vs the fidelity of the reconstruction from the two different methods. I did this for all 3 combinations of measurement bases, ZY, XY, and ZX. Results for ZY and ZX were practically identical; the main differences lie between e.g. ZY and XY.

 The first thing to note is that it doesn't seem that the distribution of the data set has much effect; I make this conclusion because when we reconstruct with the ZY bases, the states in the middle (i.e. angle ~ $\pi/2$) are more poorly reconstructed than the polar states, despite there being more of them in the training set (see, for example, the distribution of fidelities of \ref{fig:fid_v_angle_zy}. What \emph{does} make a huge difference is the bases we choose to measure in.

 The X and Y axes are those defining the equator of the Bloch sphere, and so it makes sense that measuring in those bases will give us better reconstructions simply because there is more `room to move around' in this portion of the sphere. There is, in a sense, greater chance for error here and so we want to learn as much as we can about how things related to these two axes vs. the polar one.

 What's more interesting though is the differences between the two algorithms. The average fidelity for the neural network is pretty much the same whether we use ZY or XY. However for both algorithms, the fidelity for the XY case is far more correlated with angle. The LBMLE looks normally distributed in both cases but for the ZY measurements the normal distribution is filled in, while for XY the points simply follow the outline of a bell curve.

 For the ZY case, the neural network looks like it fares worse closer to the middle (which I feel makes sense as we are using the cosine proximity as a loss function). However the average is still superior because the fidelity of the polar states is handled better than in LBMLE. In the XY case again the NN handles the polar states better, and it looks more paraboloid than it does normal. \\

 \begin{figure}[h]
  \includegraphics[scale=0.6]{fid_v_angle_zy}
  \caption{Fidelity of reconstruction vs angle with measurement data from the Z and Y MUBs. The red points are those of the neural network, and blue for the least-bias estimation.}
  \label{fig:fid_v_angle_zy}
 \end{figure}

  \begin{figure}[h]
  \includegraphics[scale=0.6]{fid_v_angle_xy}
  \caption{Fidelity of reconstruction vs angle with measurement data from the X and Y MUBs. Seems to be highly correlated with angle. The neural networks average fidelity seems to get a boost from its ability to better reconstruct the states closer to the poles of the Bloch sphere.}
  \label{fig:fid_v_angle_xy}
 \end{figure}

\end{document}


\documentclass[10pt, handout]{beamer}
\setbeamertemplate{navigation symbols}{}
\usefonttheme{serif}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{cite}
\usepackage{color}
\usepackage{setspace}
\usepackage{hyperref}

\newcommand{\xx}{{\bf{x}}}

\begin{document}
\title{Machine Learning I Lecture II:\\ Tutorial on probability theory}
\author{Jakob H Macke\\ Max Planck Institute for Biological Cybernetics\\ Bernstein Center for Computational Neuroscience}
\date{XY.XY.2012}

\frame{\titlepage}

%\frame{\frametitle{Today: Back to basics of probability theory}}

\frame{\frametitle{Plan for today}\tableofcontents}

\section{Discrete probability distributions}

\frame[shrink=10]{\frametitle{To specify a discrete random variable, we need a sample space and a probability mass function.}

\begin{itemize}
\item \alert{Sample space $\Omega$}: Possible 'states' $x$ of the random variable $X$ \\(outcomes of the experiment, output of the system, measurement). Examples: [on board]
\item \pause Discrete random variables either have a finite or countable number of states.
\item \pause \alert{Events:} Possible combinations of states ('subsets of $\Omega$')
\item \pause \alert{Probability mass function $P(X=x)$}: A function which tells us how likely each possible outcome is.
%\item %Rules:
\begin{align}
P(X=x)&=P_X(x)=P(x)\\
P(x)&\geq 0 \mbox{ for each } x\\
\sum_{x \in \Omega} P(x)&=1\\
P(A) = P(x \in A) &=\sum_{x \in A} P(X=x)\\
\end{align}
\item We write: $X|q \sim \mbox{Binomial}(q)$
\item Bernoulli, Binomial, Multinonomial, Poisson:  [on board]
\end{itemize}

}
\frame{\frametitle{Conditional probability: Updating probabilities after we obtain information.}
\begin{itemize}
\item \alert{Conditional probability:} 'Recalculated probability of event A after someone tells you that event A happened.'
\begin{align}
P(A|B)&= \frac{P(A \cap B)}{P(B)}\\
\pause P(A \cap B)&= P(A|B) P(B)
\end{align}
\item \pause Examples: Rolls of a die
 [on board]
\item \pause Bayes Rule:
\begin{align}
P(B|A) = \frac{P(A|B) P(B)}{P(A)}
\end{align}
\end{itemize}

}

\frame{\frametitle{Expectation and  variance characterize the mean value of a random variable and its dispersion.}
\begin{itemize}
\item Expectation (or mean): $E(X)= \sum_{x} P(X=x) x$
\item \pause Expectation of a function:  $E(f(X))= \sum_{x} P(X=x) f(x)$
\item \pause Moments= expectation of power of $X$: $M_k= E(X^k)$
\item \pause Variance: Average (squared) fluctuation from the mean
\begin{align}
 \mbox{Var}(X)&= E((X-E(X))^2)\\
 &= E(X^2)- E(X)^2\\
 &= M_2-M_1^2
\end{align}
\item \pause Standard devation: Square root of variance.
\item Illustration and examples: [on board]
\pause Aside: Difference between expectation/variance of random variable and empirical average/variance.
\end{itemize}

}

\section{Multivariate distributions: Joints, conditionals and marginals}
\frame{\frametitle{Bivariate distributions characterize systems with two observables.}
\begin{itemize}
\item Example [on board]
\item \alert{Joint distribution:} $P(X=x, Y=y)$, a list of all probabilities of all possible pairs of observations
\item \pause \alert{Marginal distribution:} $P(X=x)=\sum_y P(X=x, Y=y) $
\item \pause \alert{Conditional distribution:} $P(X=x|Y=y) = \frac{P(X=x, Y=y)}{P(y=y)}$
\item \pause $X |Y$ has distribution $P(X|Y)$, where $PX(|Y)$ specifies a 'lookup-table' of all possible $P(X=x| Y=y)$
\end{itemize}
\pause
\bf Conditioning and marginalization come up in Bayesian inference ALL the time: 'Condition on what you observe. Marginalize out the uncertainty'.

}

\frame{\frametitle{The importance of conditional probabilities: Interpreting medical tests}
%P(X=aids)=.001
%P(test positive|aids)=1
%P(test positive|heality)=.001
%P(aids|positive test)= 0.091
%Sensitivity: P(test positiv |disease)
%Specificity: P(test neagative | no disease)
%100 000 People

\begin{tabular}{l|ll|l}
~ & Positive Test & Negative Test & ~\\
\hline
HIV & 475 & 25 & 500\\
no HIV & 4975 & 94525 &  99500\\
\hline
~ & 5450 &  94550 & 100000
\end{tabular}

\vspace{1cm}
[on board]
\vspace{3cm}

\tiny Source: Statistical Methods for the Social Sciences, Agresti and Finaly, Prentice Hall-- not actual data
}

 \frame{\frametitle{Expectation and covariance of multivariate distributions:}
 \begin{itemize}
\item Conditional distributions are just distributions which have a (conditional) mean or variance.
\item \pause Note: $E(X|Y)= f(Y)$. 'If I tell you what $Y$ is, what is the average value of $X$?.
%\item $E(X,Y)= \sum_{x,y} P(X=x, Y=y) (x,y)= (E(X), E(Y))$
\item \pause Covariance is the expected value of the product of fluctuations:
\begin{align}
 \mbox{Cov}(X,Y)&= E\left((X-E(X) )(Y-E(Y) )\right)\\
 &= E(XY)- E(X)E(Y)\\
 \mbox{Var(X)}&= \mbox{Cov}(X,X)
\end{align}
 \end{itemize}
\pause Aside: One common way to construct bivariate random variables is to have a random variable whos parameter is another random variable.
 }

 \frame{\frametitle{Independence of random variables}
 \begin{itemize}
 \item Intuitively, two \alert{events are independent} if knowing that the first took places tells us nothing about the probability of the second:  $P(A|B)= P(A)$
 \item  \pause $P(A) P(B)= P(A \cap B)$
 \item \pause Two \alert{random variables} are independent if the joint p.m.f. is the product of the marginals: $P(X=x,Y=y)=P(X=x) P(Y=y)$.
 \item If $X$ and $Y$ are independent, we write $X \perp Y$. Knowing the value of $X$ does not tell us anything about $Y$.
 \item \pause If $X$ and $Y$ are independent, $\mbox{Cov}(X,Y)=0$.
 \end{itemize}
\pause Aside: Mutual information is a measure of how 'non-independent' two random variables are.
 }

\frame{\frametitle{Multivariate distributions are the same as bivariate distributions, just with more dimensions.}
\begin{itemize}
\item $\mathbf{X},\xx$ are vector valued.
\item Mean: $E(\mathbf{X})= \sum_{\xx} \xx P(\xx)$
\item Covariance matrix: \begin{align}
\mbox{Cov}(X_i, X_j)&= E(X_iX_j)-E(X_i) E(X_j)\\
\mbox{Cov}(\mathbf{X})&= E(\mathbf{X}\mathbf{X}^\top)-E(\mathbf{X})
E(\mathbf{X})^\top
 \end{align}
\item \pause Conditional and marginal distributions: Can define and calculate any (multi or single-dimensional) marginals or conditional distributions we need:  $P(X_1)$, $P(X_1, X_2)$, $P(X_1, X_2, X_3 |X_4)$, etc..
\end{itemize}

}
\section{}

\section{Continuous probability distributions}

\frame{\frametitle{Continous random variables}
\begin{itemize}
\item A random variable $X$ is \alert{continuous} if its sample space $X$ is uncountable.
\item In this case, $P(X=x)=0$ for each $x$.
\item \pause If $p_X(x)$ is a \alert{probability density function} for $X$, then
\begin{align}
P(a < X <b) &=\int_a^b p(x) dx\\
P(a<X <a+dx) \approx p(a) \cdot dx
\end{align}
\item \pause The \alert{cumulative distribution function} is $F_X(x)=P(X<x)$. We have that $p_X(x)=F'(x)$, and $F(x)=\int_{-\infty}^x p(s) ds$.
\item  \pause
More generally: If $A$ is an event, then
\begin{align}
P(A)&=P(X \in A) =\int_{x \in A}  p(x) dx\\
P(\Omega)&=P(X \in \Omega) =\int_{x \in \Omega} p(x) dx=1
\end{align}
\item Example: Uniform, Exponential, Beta  [on board]
\end{itemize}
}

\frame{\frametitle{People will often say probability when they mean probability density.}
\begin{itemize}
\item Probability density functions do not satisfy the definitions of probability (e.g. they can bigger than $1$). However, people (including your lecturer) will often be sloppy and write things like $P(X=x)$ and say 'the probability of $X$' when they really mean 'the probability density of $X$ evaluated at $x$'.
\item \pause Similarly, people (including your lecturer) will often be sloppy and write integrals or say 'we need to integrate our $X$' when they write down general formulas-- if these formulas are applied to discrete random variables, the integrals would need to be replaced by sums.
\item \pause This might be bad practice, but it is usually clear from the context whether a random variable is discrete or continuous. In addition, it is good preparation for reading papers---many machine learning papers are very sloppy about usage of these terms.
\end{itemize}
}

\frame{\frametitle{Mean, variance, and conditioning on events are the same as the discrete case, just with sums replaced by integrals.}
\begin{itemize}
\item Mean: $E(X)= \int_x x  \cdot p(x) dx$\\
\item Variance: $\mbox{Var}(X)= E(X^2)- E(X)^2$
\item Example: Uniform, Exponential [on board]
\item \pause If $X$ has pdf $p(x)$, then $X | (X \in A)$ has pdf
\begin{align}
p_{X|A}(x)=\frac{p(x)}{P(A)}=\frac{p(x)}{\int_{x \in A} p(x) dx}
\end{align}
\item \pause Only makes sense if $P(A)>0$~!
\item Example: Uniform, Exponential [on board]
\end{itemize}
}

%\frame{\frametitle{The univariate Gaussian}

%[on board]

%}

\frame{\frametitle{Bivariate continuous distributions: Marginalization, Conditioning and Independence}
\begin{itemize}
\item $p_{X,Y}(x,y)$, joint probablity density function of $X$ and $Y$
\item $\int_x \int_y p(x,y)dx dy=1$
\item \pause \alert{Marginal distribution:} $p(x)= \int_{-\infty}^\infty p(x,y) dy$
\item \pause \alert{Conditional distribution:} $p(x|y)= \frac{p(x,y)}{p(y)}$
\item Note: $P(Y=y)=0$! Formally, conditional probability in the continuous case can be derived using infinitesimal events.
\item \alert{Independence:} $X$ and $Y$ are independent if $p_{X,Y}(x,y)=p_X(x)p_Y(y)$
\end{itemize}
}

%\section{The Gaussian distribution}

%\frame{\frametitle{The multivariate Gaussian}

%[on board]

%}

%\frame{\frametitle{The magic formula: Conditional distributions in the multivariate Gaussian}

%[on board]

%}

\end{document}