\chapter{Experiments}
In this chapter, BVBMC is applied in a number of examples, as to show the algorithm behavior in different scenarios. The examples consists of estimating continuous probability densities in up to $10$ dimensions \footnote{In more than $10$ dimensions, performance was very poor. What was seen is that the algorithm got \enquote{stuck} in its first component proposal, and could not find new components to be proposed with acceptable weights.}.

\section{1-d Mixture of Gaussians}

As a showcase example, a one-dimensional mixture of Gaussians is considered
\begin{displaymath}
 f(x) = \sum_{i=1}^{12} w_i \mathcal{N}(x;\mu_i,\sigma^2_i),
\end{displaymath}
with $w_i = \frac{1}{12}$, $\mu_i \sim \mathcal{N}(0,\sqrt{5})$ and $\sigma^2_i = 1$. This results in a many-peaked distribution, with mean $\mu_0=-1.6585$ and variance $\sigma^2_0 = 25.0316$, whose density is shown in Figure \ref{target1dmixture}.

In each example, the quality of the approximation by the BVBMC algorithm is measured, by calculating both the difference between the estimated mean $\mu$ and the true mean $\mu_0$, in $\log_{10}|\mu - \mu_0|$, and the difference between the estimated variance $\sigma^2$ and the true variance $\sigma^2_0$, in $\log_{10}(|\sigma^2-\sigma^2_0|/|\sigma^2_0|)$. Code for this section can be found in \url{https://github.com/DFNaiff/Dissertation/tree/master/tests_dissertation/illustrative}.

\begin{figure}
	\centering
	\includegraphics[width=0.7\linewidth]{figs/targetexil1a.png}
	\caption{\label{target1dmixture} Target distribution.}
\end{figure}

\subsection{Passive evaluation}
In the first two examples, the target evaluations of $\log f(x)$ were done in a uniform grid from $-20$ to $20$ with $51$ points, resulting in the GP replicating almost exactly the target distribution. This is done to illustrate the algorithm's capacity to generate good approximate distributions, if the GP approximates closely the (unnormalized) target distribution. Output scaling was done by normalizing, as discussed in Section \ref{outputscaling}. The GP mean was chosen to be constant, setting it with the heuristic corresponding to the \textit{normalize} scaling, as discussed in Section \ref{meansection}.

\subsubsection{Influence of kernel in approximation}
It was tested the kernel influence on the final approximation. For this, the tested kernels were $k_{\text{PMat},1/2}$, $k_{\text{PMat},2/2}$, $k_{\text{PMat},5/2}$ and $k_{\text{SQE}}$. The algorithm was run for 50 iterations, with joint parameter updating done every 10 steps. The results are shown in Figure \ref{kernelcomparison}.

There is an interesting behavior to be seen, in that the GP approximation for the kernels $k_{\text{PMat},1/2}$ and  $k_{\text{PMat},3/2}$ were considerably more accurate than with kernels $k_{\text{PMat},5/2}$ and $k_{\text{SQE}}$. However, this accuracy in the GP approximation does not reflect in a better posterior approximation, that are seen with $k_{\text{PMat},5/2}$ and $k_{\text{SQE}}$. This may be due to the fact that the first two kernels makes for GP approximations that are too rough, making it difficult to be approximated by the BVBMC algorithm.

\begin{figure}
	\centering
	\subfloat[$k_{\text{PMat},1/2}$, moments.]{\label{fig11a}\includegraphics[width=0.4\linewidth]
		{figs/dmcil1fk12.png}}
	\subfloat[$k_{\text{PMat},1/2}$, final result.]{\label{fig11b}\includegraphics[width=0.4\linewidth]
	{figs/convgraphil1fk12.png}}

	\subfloat[$k_{\text{PMat},3/2}$, moments.]{\label{fig11a}\includegraphics[width=0.4\linewidth]
	{figs/dmcil1fk32.png}}
\subfloat[$k_{\text{PMat},3/2}$, final result.]{\label{fig11b}\includegraphics[width=0.4\linewidth]
	{figs/convgraphil1fk32.png}}

	\subfloat[$k_{\text{PMat},5/2}$, moments.]{\label{fig11a}\includegraphics[width=0.4\linewidth]
	{figs/dmcil1fk52.png}}
\subfloat[$k_{\text{PMat},5/2}$, final result.]{\label{fig11b}\includegraphics[width=0.4\linewidth]
	{figs/convgraphil1fk52.png}}

	\subfloat[$k_{\text{SQE}}$, moments.]{\label{fig11a}\includegraphics[width=0.4\linewidth]
	{figs/dmcil1fkSQE.png}}
\subfloat[$k_{\text{SQE}}$, final result.]{\label{fig11b}\includegraphics[width=0.4\linewidth]
	{figs/convgraphil1fkSQE.png}}
	\caption[Accuracy analysis for different kernels.]{\label{kernelcomparison} Accuracy analysis for different kernels. Each row corresponding to one kernel, in order being $k_{\text{PMat},1/2}$, $k_{\text{PMat},2/2}$, $k_{\text{PMat},5/2}$ and $k_{\text{SQE}}$. The first column (MC) shows the accuracy of mean (blue), and variance (red), while the second column shows the the predicted density, the true density and the GP approximation of the density.}
\end{figure}

\subsubsection{Influence of training routine in approximation}
Next, it was tested the difference that the training routine makes on both accuracy and algorithm running time. For this, using the same setting as above with kernel $k_{\text{PMat},5/2}$, three training routines were tested:
\begin{itemize}
	\item Running the algorithm for 50 iterations, with joint parameter updating done every step (training routine A).
	\item Running the boosting algorithm for 50 iterations, with joint parameter updating done every 10 steps (training routine B).
	\item Running the boosting algorithm for 50 iterations, with no joint parameter updating (training routine C).
\end{itemize}

The results are shown in Figure \ref{trainingcomparison}.  It can be seen that training routine B performs considerably better than routine A and routine C, while training routine A and training routine B has comparable final performance, with routine A converging in fewer iterations. As of running time, it can be see that for training routine A it increases quadratically in relation to the number of iterations, while for training routine C it increases linearly. As for training routine B, the running time increases linearly except to jumps corresponding to joint parameter updating, with each jump size growing with the iteration.

It is interesting to pause and consider the behavior of training routine B, since in the next set of examples this were the routine used, with some differences of number of iterations and intervals between joint parameter updating. Notice that boosting improves considerably accuracy up to the first joint parameter updating, in 10 iterations, and after this many intervals between two joint parameter updating essentially shows no improvements. This suggests that a smarter training routine, involving boosting only in the initial steps may be desirable. This idea was not explored further in this dissertation.

\begin{figure}
	\centering
	\subfloat[Routine A, moments]{\label{fig11a}\includegraphics[width=0.35\linewidth]
		{figs/dmcil1ati1.png}}
	\subfloat[Routine A, final result.]{\label{fig11b}\includegraphics[width=0.35\linewidth]
		{figs/convgraphil1ati1.png}}
	\subfloat[Routine A, running time.]{\label{fig11b}\includegraphics[width=0.35\linewidth]
	{figs/timegraphil1ati1.png}}

	\subfloat[Routine B,moments.]{\label{fig11a}\includegraphics[width=0.35\linewidth]
		{figs/dmcil1ati10.png}}
	\subfloat[Routine B, final result.]{\label{fig11b}\includegraphics[width=0.35\linewidth]
		{figs/convgraphil1ati10.png}}
	\subfloat[Routine B, running time.]{\label{fig11b}\includegraphics[width=0.35\linewidth]
	{figs/timegraphil1ati10.png}}

	\subfloat[Routine C, moments.]{\label{fig11a}\includegraphics[width=0.35\linewidth]
		{figs/dmcil1ati1000.png}}
	\subfloat[Routine C, final result.]{\label{fig11b}\includegraphics[width=0.35\linewidth]
		{figs/convgraphil1ati1000.png}}
	\subfloat[Routine C, running time.]{\label{fig11b}\includegraphics[width=0.35\linewidth]
	{figs/timegraphil1ati1000.png}}

	\caption[Accuracy analysis for different training routines.]{\label{trainingcomparison} Accuracy analysis for different training routines. Each row corresponding to training routine A, B and C, respectively. The first column shows the accuracy of mean (blue) and (red), the second column show the difference between the predicted density, the true density and the GP approximation of the density, and the third column shows the algorithm running time at each step.}
\end{figure}

\subsection{Active evaluation}
In this example, it is considered how BVBMC performs with active evaluation. For all examples, $5$ initial evaluation points are sampled randomly, with distribution $\mathcal{N}(0,\sqrt{10})$. Subsequently, at each iteration an evaluation point is chosen according to the running acquisition function. Four acquisition functions were tested: uncertainty sampling (US, \eqref{us_vbmc}), prospective prediction (PROP, \eqref{prospective_vbmc}), moment-matched log transform (MMLT, \eqref{mmlt_vbmc}), and prospective moment-matched log transform (MMLT$_P$, \eqref{mmltprop_vbmc}). The results are shown in Figure \ref{acquisition}. There it can be seen that all acquisition function performed well, although the GP approximation is better for the PROP and MMLT acquisitions.

\begin{figure}
	\centering
	\subfloat[US, moments.]{\label{fig11a}\includegraphics[width=0.35\linewidth]
		{figs/dmcil1g_aq_uncertainty_sampling.png}}
	\subfloat[US, final result.]{\label{fig11b}\includegraphics[width=0.35\linewidth]
		{figs/convgraphil1g_aq_uncertainty_sampling.png}}
	\subfloat[US, sampling.]{\label{fig11b}\includegraphics[width=0.35\linewidth]
		{figs/explopattern1g_aq_uncertainty_sampling.png}}

	\subfloat[PROP, moments.]{\label{fig11a}\includegraphics[width=0.35\linewidth]
	{figs/dmcil1g_aq_prospective.png}}
\subfloat[PROP, final result.]{\label{fig11b}\includegraphics[width=0.35\linewidth]
	{figs/convgraphil1g_aq_prospective.png}}
\subfloat[PROP, sampling.]{\label{fig11b}\includegraphics[width=0.35\linewidth]
	{figs/explopattern1g_aq_prospective.png}}

	\subfloat[MMLT, moments.]{\label{fig11a}\includegraphics[width=0.35\linewidth]
	{figs/dmcil1g_aq_mmlt.png}}
\subfloat[MMLT, final result.]{\label{fig11b}\includegraphics[width=0.35\linewidth]
	{figs/convgraphil1g_aq_mmlt.png}}
\subfloat[MMLT, sampling.]{\label{fig11b}\includegraphics[width=0.35\linewidth]
	{figs/explopattern1g_aq_mmlt.png}}

	\subfloat[MMLT$_P$, moments.]{\label{fig11a}\includegraphics[width=0.35\linewidth]
	{figs/dmcil1g_aq_mmlt_prospective.png}}
\subfloat[MMLT$_P$, final result.]{\label{fig11b}\includegraphics[width=0.35\linewidth]
	{figs/convgraphil1g_aq_mmlt_prospective.png}}
\subfloat[MMLT$_P$, sampling.]{\label{fig11b}\includegraphics[width=0.35\linewidth]
	{figs/explopattern1g_aq_mmlt_prospective.png}}

	\caption[Accuracy analysis for different acquisition function.]{\label{acquisition} Convergence analysis for different acquisition function. Each row corresponds to acquisitions US, PROP, MMLT and MMLT$_P$, respectively. The first column shows the accuracy of mean and covariance, the second column show the difference between the predicted density, the true density and the GP approximation of the density, and the third column shows the places where the function was evaluated.}
\end{figure}

\newpage
\section{N-d toy examples}
In this section, we consider the algorithm performance on a set of toy examples, the same ones considered in \cite{Acerbi_2018}. Code for this section can be found in \url{https://github.com/DFNaiff/Dissertation/tree/master/tests_dissertation/toy}.

Three classes of test cases were considered:
\begin{itemize}
\item \textit{Lumpy}, a mixture of multivariate Gaussians
\begin{equation}
f(x) = \sum_{i=1}^{12} w_i \mathcal{N}(x;\mu_i,\Sigma_i),
\end{equation}
with $(w_1,\ldots,w_{12}) \sim \text{Dir}(1,\ldots,1)$, $\mu_i \sim \text{Unif}([0,1]^D)$ and $\Sigma = \text{diag}(\sigma_1^2,\ldots,\sigma_n^2)$, with $\sigma_i^2 \sim \text{Unif}(0.2,0.6)$. This distribution tests the algorithm performance in presence of possible multimodalities.

\item \textit{Cigar}, a anisotropic Gaussian distribution
\begin{equation}
f(x) = \mathcal{N}(x;0,\Sigma),
\end{equation}
where $\Sigma = Q \Lambda Q^T$, with $\Lambda = (10.0,0.1,\ldots,0.1)$, and $Q$ sampled from the uniform measure in the special orthogonal group. This distribution tests the algorithm performance in presence of large anisotropy.

\item \textit{Student-t}, a product of t distributions
\begin{equation}
f(x) =  \prod_{d=1}^D \mathcal{T}(x_i;\nu_i),
\end{equation}
with $\nu_i \sim \text{Unif}(2.5,2+0.5D)$. This distribution tests the algorithm performance in presence of heavy tails \footnote{For both \textit{Cigar} and \textit{Student-t}, BVBMC was applied to an unnormalized density.} \footnote{Originally, $\nu_i = 2.5$ for every $i$, which assured reasonably heavy tails at every dimension. However, for comparison with \cite{Acerbi_2018}, this later case is not shown here}.
\end{itemize}

For each case, dimensions $D = 2,6,10$ where tested, and the BVBMC algorithm was run for $100$ iterations, with $10D$ initial samples. The GP kernel used were $k_{\text{PMat},\nu=2.5}$, with active evaluation at each iteration, according to an acquisition function randomly chosen between the pair $(\alpha_\text{PROP},\alpha_\text{MMLT})$. Every 20 steps, joint parameter updating was done, and pruning was done at each iteration, with $\beta = 10^{-3}$.

The algorithm performance was compared by checking the divergence between the true mean $\mu_0$ and the estimated mean $\mu$, in $\log_{10}||\mu - \mu_0||_2$, and between the true covariance $\Sigma_0$ and estimated covariance $\Sigma$, in $\log_{10}||\Sigma - \Sigma_0||_F/||\Sigma_0||_F$, where $||\cdot||_F$ denotes the Frobenius norm. The results are shown in Figure \ref{ndtoy}. For comparison with results given by the VBMC algorithm, shown in \cite{Acerbi_2018}, the "Gaussianized" symmetric KL divergence (gsKL) between the true distribution and estimated distribution is computed, which is defined as the symmetric KL divergence between two multivariate distributions with mean and covariance equals to the true distribution and the estimated distribution, respectively \footnote{In \cite{Acerbi_2018}, what is done are 15 evaluations for each case, and the median is taken. A better approach here would be doing the same thing for BVBMC, however due to time constraints this couldn't be done.}. The results are shown in Table \ref{toytable}. There it can be seen that, in general performance between BVBMC and VBMC was comparable, excluding the experiment with the \textit{Cigar} distribution with $D=10$, in which VBMC performed much better, and $D=2$, in which BVBMC performed better. \footnote{It should be noted that the BVBMC algorithm have used fewer evaluations, namely $120$,$160$ and $200$ for $D=2,6,10$, respectively, than the VBMC algorithm, which used $200$,$400$,$600$, for $D=2,6,10$. In this toy example this doesn't make a large computational difference, however in applications where likelihood evaluation is expensive it does.}

\begin{table}[]
	\begin{tabular}{l|l|l|l|l|l|l|}
		\cline{2-7}
		& \multicolumn{2}{l|}{Lumpy} & \multicolumn{2}{l|}{Cigar} & \multicolumn{2}{l|}{Student-t} \\ \cline{2-7}
		& BVBMC         & VBMC        & BVBMC         & VBMC        & BVBMC         & VBMC        \\ \hline
		\multicolumn{1}{|l|}{D=2}  & $3.12 \times 10^{-3}$        & $6.5 \times 10^{-4}$         & $8.12 \times 10^{-3}$           & $2.1 \times 10^{-1}$         & $2.9 \times 10^{-1}$          & $2.0 \times 10^{-3}$         \\ \hline
		\multicolumn{1}{|l|}{D=6}  & $6.59 \times 10^{-2}$         & $ 3.5 \times 10^{-2}$         & $5.56 \times 10^{-1}$           & $ 1.07 \times 10^{-1}$        & $1.14 \times 10^{-1}$           & $2.3 \times 10^{-1}$         \\ \hline
		\multicolumn{1}{|l|}{D=10} & $1.19 \times 10^{-1}$           & $ 4.2 \times 10^{-1}$         & $1.29 $           &  $ 1.0 \times 10^{-1}$        & $2.56 \times 10^{-1}$           & $ 2.7 \times 10^{-1}$        \\ \hline
	\end{tabular}
	\caption{gsKL divergence between true distribution and estimated distribution. The values for VBMC were taken from the graphs in \cite{Acerbi_2018}.}\label{toytable}
\end{table}

\begin{figure}
	\centering
	\subfloat[Lumpy, means accuracy.]{\label{fig11a}\includegraphics[width=0.5\linewidth]
		{figs/ex1b_mean.png}}
	\subfloat[Lumpy, covariances accuracy.]{\label{fig11b}\includegraphics[width=0.5\linewidth]
		{figs/ex1b_cov.png}}

	\subfloat[Cigar, means accuracy.]{\label{fig11a}\includegraphics[width=0.5\linewidth]
		{figs/ex4b_mean.png}}
	\subfloat[Cigar, covariances accuracy.]{\label{fig11b}\includegraphics[width=0.5\linewidth]
		{figs/ex4b_cov.png}}

	\subfloat[Student-t, means accuracy.]{\label{fig11a}\includegraphics[width=0.5\linewidth]
	{figs/ex5b_mean.png}}
\subfloat[Student-t, covariances accuracy.]{\label{fig11b}\includegraphics[width=0.5\linewidth]
	{figs/ex5b_cov.png}}

	\caption[Accuracy analysis for different N-d examples.]{\label{ndtoy} Accuracy analysis for different N-d examples. Each row corresponding to \textit{Lumpy}, \textit{Cigar} and \textit{Student-t}, respectively. The first column shows the accuracy of means, while the second column shows the accuracy of covariances.}
\end{figure}

\section{Contamination source estimation}
In this example, a contamination source location problem was considered, inspired by a problem in \cite{Bilionis_2013}. This problem is a toy example of an actual inverse problem, that is, given some sensor measurements of a contaminated field (the contamination may be, for instance, radiation), find where the contaminant as located, as well as its nature. Code for this section can be found in \url{https://github.com/DFNaiff/Dissertation/tree/master/tests_dissertation/source1d}.

The example consider a one-dimensional domain $B = [0,1]$, in which a contamination source $q(x,t)$ is inserted from $t=0$ to $t=t_s$. This source is modeled as
\begin{equation}
q(x,t) = q_0 \exp \left(-\frac{(x-x_0)^2}{2 \rho^2} \right) \mathbf{1}_{[0,t_s)}(t).
\end{equation}
The contaminant itself is assumed to follow the diffusion equation
\begin{equation}
\frac{\partial}{\partial t} u(x,t) = \frac{\partial^2}{\partial x^2} u(x,t) + q(x,t), \quad x \in \text{int} B.
\end{equation}
Moreover, the initial contamination is considered to be $0$, while the walls are considered insulated, resulting in the boundary and initial value conditions
\begin{equation}
u(x,0) = 0, \; \frac{\partial}{\partial x} u(0,t) = \frac{\partial}{\partial x} u(1,t) = 0.
\end{equation}
It must be noticed that, for general domain length $L$ and diffusion coefficient $k$, using adimensionalization one can reduce the general problem to the above.

In this setting, at each wall $x=0,1$, four measurements of $u$ are made, for $t_m \in T_m = \{0.075,0.15,0.225,0.3,0.4\}$, resulting in the data
\begin{displaymath}
 \mathcal{D} = \{\hat{u}(x_m,t_m)\}_{x_m \in \{0,1\},t_m \in T_m}.
\end{displaymath}
Moreover, the measurements are assumed to be noisy, with $\hat{u}(x_m,t_m) = u(x_m,t_m) + \epsilon$, $\epsilon \sim \mathcal{N}(0,\sigma^2)$. The noise parameter $\sigma^2$ is assumed to follow a prior $\text{InvGamma}(\alpha,\beta)$. This allows us to marginalize out $\sigma^2$, letting $\hat{u}(x_m,t_m)$ be distributed according to the generalized t-distribution \footnote{If $T_0$ follows a (standardized) t-distribution, with $nu$ degrees of freedom, then $T = \sigma T_0 + \mu$ follows a generalized t-distribution denoted by $\mathcal{T}(\mu,\sigma^2,\nu)$} with $2\alpha$ degrees of freedom $\mathcal{T}(u(x_m,t_m),\beta/\alpha,2 \alpha)$.

The setting above results in a 4-dimensional inference problem, for the variables $(x_0,t_s,q_0,\rho)$, with likelihood
\begin{equation}
 p(\mathcal{D}|x_0,t_s,q_0,\rho) = \prod_{x_m \in \{0,1\},t_m \in T_M} \mathcal{T}(\hat{u}(x_m,t_m);u(x_m,t_m),\beta/\alpha,2 \alpha).
\end{equation}
Given priors for $x_0$,$t_s$,$q_0$ and $\rho$, the associated posterior distribution for the parameters becomes
\begin{equation}\label{posteriorsource}
p(x_0,q_0,t_s,\rho|\mathcal{D}) \propto p(\mathcal{D}|x_0,q_0,T_s,\rho) p(x_0)p(q_0)p(\rho)p(t_s).
\end{equation}

A synthetic data $\mathcal{D}$ was generated, with the parameters given in Table \ref{sourcetable}, first row. The measurement noise was $\sigma^2 = 10^{-2}$, and the equation was simulated using a finite differences routine. The priors for the values to be inferred were set as \footnote{The Half-Cauchy distribution was used here as to represent a non-informative prior.}
\begin{equation}
\begin{split}
& p(x_0) = \text{Unif}(x_0;0,1) \\
& p(t_s) = \text{Unif}(t_s;0,0.4) \\
& p(q_0) = \text{HalfCauchy}(q_0;10) \\
& p(\rho) = \text{HalfCauchy}(\rho;0.1)
\end{split}
\end{equation}
In \eqref{posteriorsource}, $u(x,t)$ is also calculated by finite differences.

\begin{table}[h]
	\centering
	\begin{tabular}{l|l|l|l|l|}
		\cline{2-5}
		& $x_0$ & $t_s$ & $q_0$  & $\rho$ \\ \hline
		\multicolumn{1}{|l|}{True}  & 0.230 & 0.300 & 6.366  & 0.050  \\ \hline
		\multicolumn{1}{|l|}{BVBMC mean} & 0.328 & 0.213 & 5.435  & 0.140  \\ \hline
		\multicolumn{1}{|l|}{EMCEE mean} & 0.352 & 0.206 & 10.228 & 0.218  \\ \hline
		\multicolumn{1}{|l|}{BVBMC HDP 70\%} & $(1.1 \cdot 10^{-4},0.43)$ & $(0.12, 0.36)$ & $(1.0, 6.7)$ & $(2.7 \cdot 10^{-3}, 0.1)$  \\ \hline
		\multicolumn{1}{|l|}{EMCEE HDP 70\%} & $(3.4 \cdot 10^{-4}, 0.45)$ & $(0.08, 0.33)$ & $(0.4,10.3)$ & $(2.1 \cdot 10^{-3}, 0.1)$  \\ \hline
	\end{tabular}
	\caption{\label{sourcetable} Comparison of the true parameter of the problem (first row), the estimated means using BVBMC (second row) and EMCEE (third row), and 70\% highest posterior density interval for BVBMC and EMCEE.}
\end{table}

The BVBMC algorithm assumes that the distribution to be estimated has support in $\mathbb{R}^D$. This is not the case for the problem above, since $x_0$ and $t_s$ have both bounded support, while $q_0$ and $\rho$ have positive support. In order to apply the BVBMC algorithm, inference was made on the warped variables $\tilde{x}_0,\tilde{t}_s,\tilde{q}_0,\tilde{\rho}$, all of them with support in $\mathbb{R}$, such that  \footnote{The 0.4 factor here is due to the fact that $t_s$ lies between 0 and 0.4.}:
\begin{equation}
\begin{split}
 & x_0 = \text{sigmoid}(\tilde{x}_0) \\
 & t_s = 0.4 \times \text{sigmoid}(\tilde{t}_s)  \\
 & q_0 = \exp(\tilde{q}_0) \\
 & \rho = \exp(\tilde{\rho}), \\
\end{split}
\end{equation}
with
\begin{equation}
\text{sigmoid}(x) = \frac{1}{1+e^{-x}}.
\end{equation}
This results in the posterior distribution for the warped variables
\begin{equation}
 p(\tilde{x}_0,\tilde{t}_s,\tilde{q}_0,\tilde{\rho}|\mathcal{D}) \propto p(x_0,q_0,t_s,\rho|\mathcal{D}) \text{sigmoid}'(\tilde{x}_0) \text{sigmoid}'(\tilde{t}_s) \exp(\tilde{q}_0) \exp(\tilde{\rho})
\end{equation}

The BVBMC algorithm was applied to the problem, with the following setup:
\begin{itemize}
	\item The kernel used was $k_{\text{PMat},3/2}$ (both $k_{\text{PMat},5/2}$ and $k_{\text{SQE}}$ were also tested, with mixed results).
	\item The algorithm was initialized with 40 samples from the prior. After this, before the training loop, 40 more evaluations points were chosen by using the $\alpha_{MMLT}$ acquisition function.
	\item The algorithm was then run for 100 iterations, with an evaluation point chosen at each iteration, with the acquisition function chosen randomly between $\alpha_\text{{MMLT}}$ and $\alpha_\text{{PROP}}$. At each 20 iterations, the parameters were jointly optimized.
\end{itemize}

The predicted mean is shown in Table \ref{sourcetable}, second row. It can be seen that the estimated source location was relatively accurate, compared to the original one, while estimates for $\rho$ and $q_0$ where reasonable, and the estimate for $t_s$ did not deviate far from the prior mean. The resulting marginal univariate and bivariate distributions are shown in Figure \ref{sourcevbhistogram}.

\begin{figure}
	\centering
	\includegraphics[width=0.8\linewidth]{figs/sourceproblemhistogramsvb.png}
	\caption[KDE plots of estimated marginals with BVBMC. On diagonal.]{KDE plots of estimated marginals with BVBMC. On diagonal, marginal univariate distributions for $x_0$,$t_s$,$q_0$ and $\rho$ are shown, while off-diagonal, the corresponding bivariate marginals for each pair is shown.}
	\label{sourcevbhistogram}
\end{figure}

For comparison, the EMCEE algorithm \cite{Foreman_Mackey_2013}, which is a MCMC algorithm usually used for problems in astrophysics, was also tested. The EMCEE ran with $10$ walkers and $10000$ steps for each walker, using burn-in in the first $1000$ steps. The resulting estimated means is shown in Table \ref{sourcetable}, third row. It can be seem that in general the estimates were in the BVBMC algorithm, except for $q_0$, in which BVBMC seems to be more precise. The resulting marginal univariate and bivariate distributions are shown in Figure \ref{sourcevbhistogram}, showing some resemblance with the results found in BVBMC.

\begin{figure}
	\centering
	\includegraphics[width=0.8\linewidth]{figs/sourceproblemhistogramsemcee.png}
	\caption[KDE plots of estimated marginals with EMCEE. On diagonal.]{KDE plots of estimated marginals with EMCEE. On diagonal, marginal univariate distributions for $x_0$,$t_s$,$q_0$ and $\rho$ are shown, while off-diagonal, the corresponding bivariate marginals for each pair is shown.}
	\label{sourceemceehistogram}
\end{figure}

\section{Checking performance}
In practice, one does not know the true posterior for doing comparison, and there must be some way to check whether BVBMC arrived at a good posterior.

Two sources of error may arise in the BVBMC estimate and the true posterior: Whether the variational proposal does not approximate well the GP surrogate model, or the GP surrogate model does not approximate well the true  unnormalized posterior. The first case may be checked using some rough estimate of the KL divergence between the variational proposal and the surrogate model, and is implemented in the method \textit{kl\_vb\_bmc} of the associated package.

Checking whether the GP surrogate model resembles the true model may be harder. One option is to use leave-one-out testing \cite{Rasmussen06}, but one must consider that one does not care about accuracy in places where the unnormalized posterior does not contribute in probability mass. A heuristic to address this problem was not developed by the author.


\input{preamble}

\begin{document}
    \section{Subjects}
    \begin{itemize}
        \item Bagging
        \item Boosting
    \end{itemize}

    \section{Notes}

    \subsection{Decision trees}
    Decision trees simply split the feature space into a set of rectangles, and
    then fit a simple model (e.g. a constant) in each one.

    So one might say that, we we take some input $x$ and ask a series of
    questions. Is $x < 21$? Then go down the left path of the tree of
    questions. So decision trees are very simple to understand but gain are
    also very expressive. One of the major benefits of decision trees, is that
    they are very easy to read and understand. It's very easy to look at it and
    figure out what questions it asks and how much does it weigh that question
    (e.g. what pixels does it look at to understand what the image is, what
    pixels are ``important'').

    If we just look at a very simple form of decision trees, i.e. binary trees
    then things will be a bit simpler. Then every question is of the form ``if
    this then go left, otherwise go right'' so every node in the tree is a
    single dividing line in the feature space. If we look at tree where the
    values of the regions are constant, then we can predict the value of
    some input $x$ as follows:
    \begin{equation*}
        h(x)=\sum_{\text{regions } r.} 1_{[x\in r]} \cdot c_r(x)
    \end{equation*}
    That is the constant value of the region that $x$ is in.

    \subsubsection{Growing a regression tree}
    Using the binary regression tree described earlier, with constant region
    values, we will then describe how to grow a regression tree (learn).

    Given some input of $N$ observations $(x_i,y_i)$ for $i=1,2,\dots,N$ with
    $x_i = (x_{i1}, x_{i2},\dots,x_{id})$ and $y_i$ being the label or the
    ``true'' value, we then need to figure out how to approximate $y$ for some
    unknown $x$ outside of the training set. The algorithm then needs to decide
    on the splitting variables and split points, as well as the topology of the
    tree.

    Suppose we have a partition into $M$ regions $R_1, R_2, \dots, R_M$ and we
    model the response as mentioned earlier:
    \begin{equation*}
        h(x)=\sum_{\text{regions } r}1_{[x\in r]} \cdot c_r(x)
    \end{equation*}
    As usual with regression, we can use the squared error measure: $(h(x_i)
    -y_i)^2$ to evaluate our performance. Then, we can easily see that the best
    constant for region $R_m$ is simply the average of $y_i$ which ended up in
    region $R_m$, because least squares measure punishes distance the target.
    I.e. one point which is off by $2$ is punished more than two points that
    are off by $1$, and thus the mean is the smallest distance on average:
    \begin{equation*}
        \hat{c}_m=\frac{1}{|D|}\sum_{(x,y) \in D}1_{[x\in r]} \cdot y
    \end{equation*}

    Now, actually finding the best partition of the feature space into the
    $R_m$ optimal regions is, in general, computationally infeasible. Thus, we
    will proceed with a greedy approximation algorithm.

    Consider some splitting variable $j$ and splitting point $s$, we can then
    define the pair of half-planes:
    \begin{equation*}
        R_1(j,s)=\{X|X_j \leq s\} \text{ and } R_2(j,s)=\{X|X_j > s\}
    \end{equation*}
    Note here that the point $X$ can be any point in the feature space and is
    not necessarily a point from $D$.

    We then seek to find the splitting variable $j$ and split point $s$ that
    solve:
    \begin{equation*}
        \min_{j,s}\left[\min_{c_1}\left[\sum_{x_i\in
        R_1(j,s)}(y_i-c_1)^2\right] + \min_{c_2}\left[\sum_{x_i \in
        R_2(j,s)}(y_i-c_2)^2\right]\right]
    \end{equation*}

    If we use the mean, as mentioned earlier, we can simplify this to:
    \begin{equation*}
    \min_{j,s}\left[ \left(\sum_{x_i \in R_1(j,s)} (y_i - \hat{c}_1)^2 \right)
    + \left(\sum_{x_i \in R_2(j,s)} (y_i - \hat{c}_2)^2 \right) \right]
    \end{equation*}
    Or, stated differently:
    \begin{equation*}
    \min_{j,s}\left[ \left(\sum_{(x, y) \in D, x_j \leq s} (y - \hat{c}_1)^2
    \right) + \left(\sum_{x,y \in D, x_j > s} (y_i - \hat{c}_2)^2 \right)
    \right]
    \end{equation*}
    For each splitting variable $j$, we can simply pick $s$ as the midpoints
    between two $x_j$ values, which results in $|D| - 1$ different split-points
    to consider.

    Now that we know how to compute the ``best'' split, we simply follow the
    following greedy algorithm:
    \begin{itemize}
        \item Select best ``split'' variable $j$, and the split-point $s$
        \item Make a new node in the tree with $(j,s)$ (i.e. a new split)
        \item Make a child for each new region (outcome of testing $j$)
        \item Split the training examples up between the two regions
        \item Call recursively on the new children (the new regions)
        \item Stop when done
    \end{itemize}

    \subsubsection{Size of the tree}
    How large should the tree become? If we make it too large, we might
    overfit. Too small and we might not capture the structure of the data
    properly.

    Tree size is a hyper-parameter, and it should be chosen adaptively based on
    the data. We could, for example, stop if the decrease in error drops below
    some is under some threshold. This is fairly short-sighted however, as a
    bad split at some level might result in a crucial split later on.

    The usual strategy is to grow a large tree $T_0$ and stop it when the size
    of the nodes (i.e. how many data-points we have for each node) drops below
    some set threshold (e.g. $5$) and then pruning this tree.

    One way to prune the tree, is to simply compute the accuracy gained by
    removing on some validation set and greedily deleting the splits that
    increases accuracy the most. Repeating this as long as it helps.

    Limiting the size of the tree is the same as regularizing for decision
    trees. So variance will go down and bias will go up etc.

    \subsection{Classification trees}
    For regression trees, we used the squared error impurity measure $Q_m(T)$:
    \begin{equation*}
        Q_m(T)=\frac{1}{N_m}\sum_{x_i \in R_m}(y_i - \hat{c}_m)^2
    \end{equation*}
    Where $N_m = |\{x_i | x_i\in R_m\}|$ If the target is a classification
    outcome, taking values $1,2,\dots,K$, then this measure is not suitable.

    If we let $\hat{p}_{mk}$ be the proportion of observations that had class
    $k$ in node $m$. We can then predict the class of points in region $m$ to
    have class $k(m)=\arg\max_k \hat{p}_{mk}$, i.e. the majority class in
    region $m$. Then, different measures of $Q_m(T)$ of node impurity includes
    the following:
    \begin{description}
        \item[Misclassification error (0-1 Loss)]
        \begin{equation*}
            \frac{1}{N_m} \sum_{(x,y) \in R_m}1_{[k(m) \neq y]} = 1-
            \hat{p}_{mk(m)}
        \end{equation*}
        \item[Gini index]
        \begin{equation*}
            \sum_{k\neq k'} \hat{p}_{mk}\hat{p}_{mk'} =
            \sum_{k=1}^{K}\hat{p}_{mk}(1-\hat{p}_{mk})
        \end{equation*}
        \item[Cross-entropy]
        \begin{equation*}
            - \sum_{k=1}^{K} \hat{p}_{mk} \log \hat{p}_{mk}
        \end{equation*}
    \end{description}

    \subsubsection{Why binary splits?}
    We can represent multiway splits by a series of binary splits (e.g. a
    tertiary split can be represented by two binary splits) so we don't lose
    generality. Furthermore, multiway splits split the data too quickly, so we
    are left with too little information at the lower levels.

    \subsection{Ensemble methods}
    Decision trees have a high variance, just one data-point can completely
    change the outcome of the tree. When we did the pruning and size-limitation
    we sought to decrease the variance (through regularization). Another option
    for reducing variance is ensemble methods.

    \subsubsection{Bootstrapping datasets}
    Bootstrapping is a general tool for assessing statistical accuracy. Suppose
    we have our data-set $D$ as before. The basic idea is then to pick random
    points from this such that we have $B$ different data-sets $D_i$ that each
    have a random selection of points from $D$ (which may be overlapping). We
    can use these data-sets $D_i$ as ``independent'' data-sets. This method is
    often used to measure statistics like variance, confidence bounds, std.err.
    etc. in other, more statistical oriented, domains.

    \subsubsection{Bagging}
    Bagging uses bootstrapped data-sets in order to improve on our predictions.
    What we do in bagging (bootstrap aggregation) is simply to get our $B$
    bootstrapped data-sets $D_i$, train our model on all the different
    data-sets producing $h_1,\dots,h_B$ (our ensemble of models). We can then
    perform predictions by doing a majority vote (for classification) or
    returning the mean of the predictions.
    \begin{equation*}
        h_{\text{bag}}(x)=\frac{1}{B}\sum_{i=1}^{B} h_i(x)
    \end{equation*}
    This should bring down variance while not touching bias. Ideally we would
    get:
    \begin{equation*}
        Var(Bagging(T))=\frac{Var(T)}{m}
    \end{equation*}
    But in practice, the reduction is less since the bagged models are still
    fairly correlated. Furthermore, some classifiers are better than others.
    Let's look at the following example with a trivial target function $f(x)=1,
    \forall x$. If we then bagged ``poor'' classifiers that return $1$ with
    probability $0.4$, then if we had many classifiers, the probability would
    converge to $0$ as the number of classifiers increases and $E_{out}=1$. If
    we instead bagged ``better'' classifiers which return $1$ with probability
    $0.6$, then the opposite would happen. This has been popularized as
    ``Wisdom of Crowds'', which states that as long as the persons in the crowd
    are smarter than just guessing, then if we ask many people we will improve
    on our result, by either taking mean or majority vote (depending on
    regression or classification).

    In order to improve on this, we can use process called ``boosting'' which
    improves the quality on individual learners, such that the learners we put
    into our ``crowd'' perform better than just guessing.

    A final note: the main draw-back of bagging is that it mostly works on
    unstable models, which are also often the models that are easy to
    interpret. Bagging, however, ruins the simplicity of the model and makes it
    harder to interpret the model as the model will no longer be e.g. a tree,
    but in fact it is a more complex structure.

    \todo[inline]{Random forests?}

    \subsubsection{Boosting}
    Boosting works in similar way to bagging, but the similarity is mostly
    superfluous. In boosting we, similar to bagging, produce $M$ modified
    versions of the data-set, producing a sequence of weak classifiers
    $h_1,h_2,\dots,h_M$ (classifiers whose error rate is only slightly better
    than random guessing) and then we find a weighted majority-vote, to produce
    the final prediction:
    \begin{equation*}
        h_{boost}(x)=\sign \left(\sum_{m=1}^{M}\alpha_m h_m(x)\right)
    \end{equation*}
    Here, $\alpha_1,\alpha_2,\dots,\alpha_M$ are computed by the boosting
    algorithm. The $\alpha$'s are supposed to give the more accurate
    classifiers in the sequence more influence.

    Now let's look at an example of a boosting algorithm, AdaBoost. The ides is
    that at each boosting step, we produce the data-set $D_i$ by applying some
    weights to each of the training points $(x,y)$. Initially all weights $w_i$
    are set to: $w_i=\frac{1}{N}$ so that the first step simply trains in the
    usual manner. Then for the data-set $D_i$ at step $i$ we have modified the
    weights such that those observations that were misclassified by
    $h_{i-1}(x)$ have their weights increased, and those that were classified
    correctly have their weights decreased, such that the observations that are
    difficult to classify, receive more and more influence. The algorithm for
    AdaBoost (or rather AdaBoost.M1) is as follows:
    \begin{enumerate}
        \item Initialize the observation weights
        \begin{equation*}
            w_i=\frac{1}{N}, \quad i=1,2,\dots,N
        \end{equation*}
        \item For $m=1$ to $M$:
        \begin{enumerate}[a)]
            \item Fit a classifier $h_m(x)$ to the training data using weights
            $w_i$.
            \item Compute:
            \begin{equation*}
                err_m=\frac{\sum_{i=1}^{N}w_i \cdot 1_{[y_i \neq
                h_m(x_i)]}}{\sum_{i=1}^{N}w_i}
            \end{equation*}
            \item Compute:
            \begin{equation*}
                \alpha_m=\log\left(\frac{1-err_m}{err_m}\right)
            \end{equation*}
            \item Set:
            \begin{equation*}
                w_i \leftarrow w_i \cdot \exp\left[\alpha_m \cdot 1_{[y_i \neq
                h_m(x_i)]}\right], \quad i=1,2,\dots,N
            \end{equation*}
        \end{enumerate}
        \item Output:
        \begin{equation*}
            h_{boost}(x)=\sign \left[\sum_{m=1}^{M}\alpha_m h_m(x)\right]
        \end{equation*}
    \end{enumerate}
    Note that this is the ``discrete'' version of AdaBoost, there are versions
    of AdaBoost that work on regression problems as well.

    Since AdaBoost only needs weak classifiers, then just a shallow tree of
    depth $2$ for example, can produce impressive results after a lot of
    iterations. Even classifiers as weak as $45\%$ quickly improves their
    accuracy.

    \subsubsection{Additive models}
    An additive model is described as:
    \begin{equation*}
        h(x) = \sum_{m=1}^{M} \alpha_m h_m(x;\theta_m)
    \end{equation*}
    Where $\alpha_m$ is the vote importance, $h_m$ is the base learner and
    $\theta_m$ is the parameters that define the specific version of the base
    learner.
    These models are typically fit by minimizing a loss function averaged over
    the training data (e.g. squared-error or cross-entropy):
    \begin{equation*}
        \arg\min_{\alpha_j,\theta_j,j=1,\dots,M} \sum_{x,y \in D}
        \error\left(y, \sum_{m=1}^{M}\alpha_m h(x, \theta_m)\right)
    \end{equation*}

    We can then formulate the forward stagewise additive modelling algorithm:
    \begin{enumerate}
        \item $h_0(x) = 0$
        \item For $m=1,\dots,M$
        \begin{enumerate}[a)]
            \item Compute:
            \begin{equation*}
                (\beta_m,\bar{h}_m)=\arg\min_{\beta,h}\sum_{i=1}^{N}\error\left(y_i,
                 h_{m-1}(x_i)+\beta h(x_i)\right)
            \end{equation*}
            \item Compute:
            \begin{equation*}
                h_m(x)=h_{m-1}(x)+\beta_m \bar{h}(x)
            \end{equation*}
        \end{enumerate}
        \item Output $h_M$
    \end{enumerate}
    For example, given the squared error: $\error(y, h(x))=(y-h(x))^2$, then we
    have that, at each step $m$ we minimize:
    \begin{equation*}
        \error(y_i, h_{m-1}(x_i)+\beta_m h_m(x_i))=(y_i-h_{m-1}(x_i)-\beta_m
        h_m(x_i))^2
    \end{equation*}
    Since $y_i-h_{m-1}(x_i)$ is simply the error of the current model, then we
    see that we are repeatedly trying to fit the errors of the current model.

    If we instead use the cost function:
    \begin{equation*}
        \error(y,h(x))=\exp(-y\cdot h(x))
    \end{equation*}
    Which is small if $y$ and $h(x)$ has the same sign, otherwise large. Then
    it turns out that this is exactly what AdaBoost.M1 is minimizing, thus
    AdaBoost.M1 is a a forward-stagewise additive modeling approach.
\end{document}


\documentclass[letterpaper, 10 pt, conference]{ieeeconf}
\IEEEoverridecommandlockouts
\usepackage{graphicx}
\usepackage{hyperref}

\overrideIEEEmargins

\title{\Huge Image Mosaicing}
\author{Jiyu Tian}

\begin{document}

\maketitle
\thispagestyle{empty}
\pagestyle{empty}

%-------------------------------------------------------------------------

\section{INTRODUCTION}
In this project we implement a technique for image mosaicing with feature matching.
Harris corner detector is applied to find corners in two images. With corresponding features, a homography between the two images can then be estimated. Finally we warp one image into the coordinate system of the second one to produce a mosaic containing the union of all pixels in the two images.
%-------------------------------------------------------------------------
\section{ALGORITHMS DESCRIPTION}
\subsection{Grayscale Conversion}
After reading in two images, we first make them grayscale.We apply the conversion as the following eqaution:
\begin{equation}
Gray = 0.299 \times R + 0.587 \times G + 0.114 \times B
\end{equation}

If, in the worst case, input images do not have all the three $RGB$ channels, we simply regard the first channel as its grayscale value.
\subsection{Harris Corner Detector}
The image gradient $I_x$ and $I_y$ is computed using horizontal and vertical components of Prewitt/Sobel mask. Then at each pixel we compute products of derivatives $I^2_x$, $I^2_y$ and $I^2_{xy}$. A window centering at the pixel is selected for averaging the sums of the products $S^2_x$, $S^2_y$ and $S^2_{xy}$.
At each pixel, a matrix $M$ is defined as
\begin{equation}
M=\left[ \begin{array}{cc}
S^2_x & S^2_{xy}\\
S^2_{xy} & S^2_y
\end{array} \right]
\end{equation}

And the response $R$ can be computed as
\begin{equation}
R=det(M) - k\times trace(M)^2
\end{equation}

\subsection{Correspondences}
Given two set of corners from the two images, we compute normalized cross correlation ($NCC$) of image patches centered at each corner.
\begin{equation}
N_{fg} = \sum_{[i, j]\in R}\hat{f}(i, j)\hat{g}(i, j),\ \ \hat{f} = \frac{f}{||f||}, \ \  \hat{g} = \frac{g}{||g||}
\end{equation}

We choose potential corner matches by finding pair of corners (one from each image) such that they have the highest $NCC$ value. We also set a threshold to keep only matches pairs that have a large $NCC$ score.
\subsection{Homography Estimation}
Given a set of 4 points pairs $(x,y)\ (x', y')$, we can compute the homography from
\begin{equation}
\left[ \begin{array}{c}
x'\\
y'\\
1
\end{array} \right] = \left[ \begin{array}{ccc}
h_{11} & h_{12} & h_{13} \\
h_{21} & h_{22} & h_{23} \\
h_{31} & h_{32} & h_{33}
\end{array} \right]\left[ \begin{array}{c}
x\\
y\\
1
\end{array} \right]
\end{equation}

We use RANSAC to robustly estimate the homography from the noisy correspondences:
\begin{itemize}
\item Repeatedly sample 4 random points
\item Compute a homography from these four points
\item Map all points using the homagraphy and comparing distances between predicted and observed locations to determine the number of inliers
\item At the end, compute a least-squares homgraphy from \textbf{all} the inliers in the largest set of inliers.
\end{itemize}

\subsection{Image Warp}
After generating the homography, we can warp one image onto the other one, blending overlapping pixels together to create a single image that shows the union of all pixels from both input images.

The steps are as follows:
\begin{itemize}
    \item Determine how big to make the final output image so that it contains the union of all pixels in the two images
    \item Copy the image that does not have to be warped into the appropriate location in the output
    \item Warp the other image into the output image based on the estimated homography
    \item Blend pixels in the area of overlap between both images
\end{itemize}
%-------------------------------------------------------------------------
\section{EXPERIMENTAL RESULTS}
The two raw images we adopt for report are shown in Fig \ref{raw}. They are converted into grayscale for the following steps. Please refer to the Appendix A for a complete flowchart.
\begin{figure}[thpb]
\centering
\includegraphics[width=0.5\textwidth]{raw.png}
\caption{Raw Images}
\label{raw}
\end{figure}
%--------------------------------------
\subsection{Corner Detection}
After applied by Harris corner detector, the corner features within two images are shown in Fig \ref{corner}.

The gradient is computed with Sobel mask. We utilize a $7\times7$ Gaussian averaging window with $\sigma=1.4$ to find matrix $M$ at each pixel. A threshold of $R = 1\times 10^8$ is set to filtered pixels with low response, and $k$ is set to $0.05$.

\begin{figure}[thpb]
\centering
\includegraphics[width=0.5\textwidth]{corner.png}
\caption{Corner Detection Result}
\label{corner}
\end{figure}

We compute non-maximum suppression to find local peaks within $3\times3$ neighbors.

%--------------------------------------
\subsection{Correspondences}
For each pair of corners from two images, we compute their $NCC$ in a $3\time3$ window. We find the potential corner pairs from the highest to the lowest $NCC$ score larger than $0.5$.

The corresponding pairs with outliers are shown in Fig \ref{corr}. There are over $100$ pairs in total.

\begin{figure}[thpb]
\centering
\includegraphics[width=0.5\textwidth]{correspondence.png}
\caption{Corresponding Pairs with Outliers}
\label{corr}
\end{figure}

%--------------------------------------
\subsection{Homography Estimation}
We run RANSAC to find final point correspondences. A total of $1\times10^4$ iterations are executed. A projected point is considered to be inlier if its Euclidien distance from matched point is less than $2$.

In a iteration, if $10\%$ of total points pairs are inliers, this
\newpage
\noindent homography is good enough; or a new set of four random point pairs is selected to compute homography.

\begin{figure}[thpb]
\centering
\includegraphics[width=0.5\textwidth]{ransac.png}
\caption{Cleaned Corresponding Pairs}
\label{clean}
\end{figure}

%--------------------------------------
\subsection{Final Mosaic}
As shown in Fig \ref{mosaic}, image $1$ is wrapped into image 2 with homography computed. In this part we utilize OpenCV for implementation.

\begin{figure}[thpb]
\centering
\includegraphics[width=0.4\textwidth]{mosaic.png}
\caption{Final Mosaic}
\label{mosaic}
\end{figure}

%--------------------------------------
\subsection{Limitation}
One key limitation of our algorithm is its high computing consumption. Plenty of time is spent on corner detection and correspondences computing, since the are $O(n^2)$ complexity.

We also notice that RANSAC process depends on the initial selection of point pairs. If luckily enough, iteration time can be reduced significantly.

%-------------------------------------------------------------------------
\section{CONCLUSION}
In this project, we explored various application of feature matching, and creatively applied them to image mosaicing. This is a very useful technique for constructing panoramic image mosaics from sequences of images.
\vfill

\end{document}


\section{The \protect\EcoLab{} Model}\label{model}

The \EcoLab{} model is but one model implemented using the \EcoLab{}
software. This section documents the model itself, and may be skipped
if your intention is to use \EcoLab{} for other models.

We start with a generalised form of the Lotka-Volterra equation
\begin{equation}\label{lotka-volterra}
\dot{\bn} = \br*\bn + \bn*\bbeta\bn.
\end{equation}
Here \bn\ is the population density, the component $n_i$ being the
number of individuals of species $i$, \br\ is the difference
between reproduction and death, \bbeta\ is the interaction matrix,
with $\beta_{ij}$ being the interaction between species $i$ and $j$, *
referring to elementwise multiplication and {\tt mutate} is the
mutation operator.

\subsection{Lotka-Volterra Dynamics}

The most obvious thing about equation (\ref{lotka-volterra}) is its
fixed point
\begin{equation}\label{fixed point}
\hat{\bn} = -\bbeta^{-1}\br,
\end{equation}
where $\dot{\bn}=0$. For this point to be biologically meaningful, all
components of $\hat{\bn}$ must be positive, giving rise to the following
inequalities:
\begin{equation}\label{positive species}
\hat n_i = \left(\bbeta^{-1}\br\right)_i>0, \forall i
\end{equation}
The stability of this point is related to the
negative definiteness of derivative of $\dot{\bn}$ at $\hat{\bn}$. The
components of the derivative are given by
\begin{equation}\label{derivative}
\frac{\partial\dot{n}_i}{\partial n_j} =
\delta_{ij}\left(r_i+\sum_k\beta_{ik}n_k\right) + \beta_{ij}n_i
\end{equation}
Substituting eq (\ref{fixed point}) gives
\begin{equation}
\left.\frac{\partial\dot{n}_i}{\partial n_j}\right|_{\hat{\bn}}=
-\beta_{ij}\left(\bbeta^{-1}\br\right)_i
\end{equation}

Stability of the fixed point requires that this matrix should be
negative definite. Since the $\left(\bbeta^{-1}\br\right)_i$ are
all negative by virtue of (\ref{positive species}), each minor
determinant of this matrix is equal to a minor determinant of \bbeta\
multiplied by a positive number, stability of the equilibrium is
equivalent to \bbeta\ being negative definite.

A weaker condition is to require that the system remain bounded with
time:
\begin{equation}\label{boundedness}
\sum_i\dot{n_i}=\br\cdot\bn + \bn\cdot\bbeta\bn < 0, \;\forall \bn:
\sum_in_i>N \;\exists N
\end{equation}

As \bn\ becomes large in any direction, this functional is dominated
by the quadratic term, so this implies that  $\bn\cdot\bbeta\bn\leq0
\; \forall\bn: n_i>0$. Negative definiteness of \bbeta\ is sufficient,
but not necessary for this condition. For example, the predator-prey
relations (heavily normalised) have the following matrix as \bbeta:
\begin{math}
\bbeta=\left(\begin{array}{cc}
-1 & 2\\
-2 & 0\\
\end{array}\right)
\end{math}
which has eigenvalues $3/2, -5/2$. If we let $\bn=(x,y), x,y\geq0$, then
$\bn\cdot\bbeta\bn=-2x^2$, which is clearly non-positive
for all $x$.

Consider adding a new row and column to \bbeta. What is condition is
the new row and column required to satisfy such that equation
(\ref{boundedness}) is satisfied. Break up \bbeta\ in the following
way:
\begin{displaymath}
\left(
  \mbox{
     \begin{tabular}{c|c}
       $\begin{array}{ccc}\ddots\\&{\bf A}\\&&\ddots\end{array}$ &
       $\begin{array}{c}\vdots\\{\bf B}\\\vdots\end{array}$ \\
       \hline
       $\begin{array}{ccc}\cdots&{\bf C}&\cdots\end{array}$ & D
     \end{tabular}
   }
\right)
\left(
  \mbox{
     \begin{tabular}{c}
     $\begin{array}{c}\vdots\\{\bf n_1}\\\vdots\end{array}$\\
     \hline
     $n_2$
     \end{tabular}
    }
\right)
\end{displaymath}

Condition (\ref{boundedness}) becomes:
\begin{equation}\label{boundedness2}
{\bf n_1}\cdot{\bf A}{\bf n_1} + {\bf n_1}\cdot({\bf B}+{\bf C})n_2 +
Dn_2^2 \leq 0
\end{equation}

Let
\begin{displaymath}
a=\max_{n=1} \bn\cdot A\bn,\mbox{ and } b=\max_{i}B_i+C_i.
\end{displaymath}
 Then a sufficient but
not necessary condition for condition (\ref{boundedness2}) is
\begin{displaymath}
an_1^2+bn_1n_2+Dn_2^2\leq0
\end{displaymath}

The maximum value with respect to $n_2$ is $an_1^2-(bn_1)^2/4D$, so
this requires that
\begin{equation}\label{boundedness3}
b \geq 2\sqrt{aD}
\end{equation}

\subsection{Mutation}\label{mutation}

With mutation, equation (\ref{lotka-volterra}) reads
\begin{equation}
\dot{\bn} = \br*\bn + \bn*\bbeta\bn + {\tt mutate}(\bmu,\br,\bn).
\end{equation}

The difficulty with adding mutation to this model is how to define the
mapping between genotype space and phenotype space, or in other words,
what defines the {\em embryology}. A few studies, including Ray's
Tierra world, do this with an explicit mapping from the genotype to to
some particular organism property (e.g. interpreted as machine language
instructions, or as weight in a neural net). These organisms then
interact with one another to determine the population dynamics. In
this model, however, we are doing away with the organismal layer, and
so an explicit embryology is impossible. The only possibility left is
to use a statistical model of embryology. The mapping between
genotype space and the population parameters $\br$,
$\bbeta{}$  is expected to look like a rugged
landscape, however, if two genotypes are close together (in a Hamming
sense) then one might expect that the phenotypes are likely to be
similar, as would the population parameters. This I call {\em random
embryology with locality}.

In the simple case of point mutations, the probability $P(x)$ of any
child lying distance $x$ in genotype space from its parent follows a
Poisson distribution. Random embryology with locality implies that the
phenotypic parameters are distributed randomly about the parent
species, with a standard deviation that depends monotonically on the
genotypic displacement. The simplest such model is to distribute the
phenotypic parameters in a Gaussian fashion about the parent's values,
with standard deviation proportional to the genotypic displacement.
This constant of proportionality can be conflated with the species'
intrinsic mutation rate, to give rise another phenotypic parameter
$\bmu$.  It is assumed that the probability of a mutation generating a
previously existing species is negligible, and can be ignored. We also
need another arbitrary parameter $\rho$, ``species radius'', or
\verb+ecolab.sp_sep+,\index{sp\_sep} which can be understood as the
minimum genotypic distance separating species, conflated with the same
constant of proportionality as $\bmu$.

In summary, the mutation algorithm is as follows:
\begin{enumerate}
\item The number of mutant species arising from species $i$ within a
timestep is $\mu_i\alpha_in_i/\rho$. This number is rounded
stochastically to the nearest integer, e.g. 0.25 is rounded up to 1
25\% of the time and down to 0 75\% of the time.

\item Roll a random number from a Poisson distribution
$e^{-x/\mu+\rho}$ to determine the standard deviation $\sigma$ of phenotypic
variation.

\item Vary $\br$ according to a Gaussian distribution about the
  parents' values, with $\sigma\alpha_0$ as the standard deviation,
  where $\alpha_0$ is the range of values that $\br$ is initialised to,
  ie $\alpha_0$=\verb|ecolab.repro_max|\index{ecolab.repro\_max}$-$
  \verb|ecolab.repro_min|\index{ecolab.repro\_min}

\item The diagonal part of $\bbeta$ must be negative, so vary $\bbeta$
according to a log-normal distribution. This means that if the old
value is $\beta$, the new value becomes
$\beta'=-\exp(\log_e(\beta)+\sigma)$. These values cannot become
arbitrarily small, however, as this would imply that some species make
arbitrarily small demands on the environment, and will become infinite
in number. In \EcoLab{}, the diagonal interactions terms are prevented from
becoming larger than $-r/(.1*{\tt INT\_MAX})$.

\item The offdiagonal components of $\bbeta$, are varied in a similar
fashion to $\br$. However new connections are added, or old ones
removed according to $\lfloor 1/r\rfloor$, where $r\in(-2,2)$ is
chosen from a stepped uniform distribution
\begin{displaymath}
P(x)=\left\{
\begin{array}{ll}
0.25(1-g) & \mathrm{if}\; x\leq0\\
0.25(1+g) & \mathrm{if}\; x>0\\
\end{array}
\right.
\end{displaymath}
where $g\in[-1,1]$ (default of 0) is specified by the TCL variable
\verb+generalization_bias+\index{generalization\_bias}. The values on
the new connections are chosen from the same initial distribution that
the offdiagonal values where originally set with, ie the range
\verb|ecolab.odiag_min|\index{ecolab.odiag\_min} to
\verb|ecolab.odiag_max|\index{ecolab.odiag\_max}. Since $a$ in
condition (\ref{boundedness3}) is computationally expensive, we use a
slightly stronger criterion that is sufficient, computationally
tractable yet still allows ``interesting'' non-definite matrix
behaviour namely that the sum $\beta_{ij}+\beta_{ji}$ should be
nonpositive.

\item $\bmu$ must be positive, so should evolve according to the
  log-normal distribution like the diagonal components of $\bbeta$.
  Similar to $\bbeta$, it is a catastrophe to allow $\bmu$ to become
  arbitrarily large. In the real world, mutation normally exists at
  some fixed background rate --- species can reduce the level of
  mutation by improving their genetic repair algorithms. In \EcoLab{},
  this ceiling on $\bmu$ is given by the
  \verb|ecolab.mut_max|\index{ecolab.mut\_max} variable.

\end{enumerate}

\subsection{Input Parameters}\label{input parameters}

The model's parameters are set by TCL variables in {\tt model.tcl}.
The actual data structures of the model are initialised the first time
the model's generate step is called. An example input set is:
\begin{verbatim}
# initial condition
ecolab.species {1 2}
ecolab.density {100 100}
ecolab.create {0 0}
ecolab.repro_rate {.1 -.1}
ecolab.interaction.diag {-.0001 -1e-5}
ecolab.interaction.val {-0.001 0.001}
ecolab.interaction.row {0 1}
ecolab.interaction.col {1 0}
ecolab.migration {.1 .1}

# mutation parameters
ecolab.mutation {.01 .01}
ecolab.sp_sep .1
ecolab.repro_min -.1
ecolab.repro_max .1
ecolab.odiag_min -1e-3
ecolab.odiag_max 1e-3
ecolab.mut_max .01
\end{verbatim}

Model variables define a TCL command of the same name as they appear
in the C++ source. So in the \EcoLab{} model, the C++ object {\tt
  ecolab} defines a set of TCL commands such as {\tt ecolab.density}
that can be used for setting or querying the values of {\tt ecolab}'s
members.  If an argument is specified, then that argument is used to
set the variable's value, otherwise, the variable's value is returned.
Array members in the model are initialised by specifying an TCL list
argument to the variables name, and return TCL lists when no argument
is specified. The above example starts the ecology off with a single
predator and prey (based on {\tt pred-prey.tcl}\index{pred-prey.tcl}).

\subsection{\protect\EcoLab{} Model commands}

\subsubsection{generate}\index{generate}

This implements the basic Lotka-Volterra equations:

\begin{math}
\dot{\bn} = \br*\bn + \bn*\bbeta\bn
\end{math}

with \br\ being the reproduction rate and \bbeta\ being the
interspecies interaction. This is implemented as a single line:

\begin{verbatim}
  density += repro_rate * density + (interaction * density) * density;
\end{verbatim}

This command also increments the timestep counter {\tt tstep}.

An optional argument specifies a number of timesteps to run the
generate step. This improves the speed by amortising the real to
integer conversion operation over a number of timesteps. The downside
is that computation may fail if the problem is ill-conditioned
(offdiagonal elements of \bbeta\ too large with respect to the
diagonal elements).

\subsubsection{condense}\label{condense}\index{condense}

This command compacts the systems of equations by removing extinct
species where $n_i=0$.

\subsubsection{mutate}\label{mutate}\index{mutate}

This applies the point mutations to the system. The precise algorithm
is described in \S\ref{mutation}.

\subsubsection{migrate}\label{migrate}\index{migrate}

This operator implements migration within cellular \EcoLab{}. This
updates density values according to the difference with the 4 nearest
neighbours: $\bn+=\bgamma*(0.25(\bn_n+\bn_e+\bn_s+\bn_w)-\bn)$, where the
$n,e,s,w$ index the north, east, south and west neigbouring cells.

\subsubsection{maxeig}\label{maxeig}\index{maxeig}

\verb|maxeig| returns the maximum eigenvalue of \bbeta. If this number
is negative, the equilibrium point is stable, if positive, it is
unstable. As reported in Standish (1994)\cite{Standish94}, the mutation
drives the maximum eigenvalue slightly positive, then instabilities
act to push the eigenvalue back to zero. This command requires LAPACK\index{LAPACK}).

\subsubsection{lifetimes}\label{lifetimes}\index{lifetimes}

\verb|lifetimes| records the timestep when a
species passes a threshold (hardwired at 10) in the {\tt create}\index{create}
iarray. If a species has yet to pass the threshold, or has gone
extinct, the value in {\tt create} is zero. Upon return, this routine
returns the lifetime of the species that have gone extinct. This can
then be passed to a histogram routine, or written to a file.

\subsubsection{random\_interaction}\label{random_interaction}
\index{random\_interaction}

Calls \hyperref{{\protect\tt sparse\_mat::init\_rand()}}{(See \S}{)}{sparse_mat} to randomly initialising the nonzero pattern of
the offdiagonal elements. The average number of nonzeros per row is
{\tt conn}, and the standard deviation of the number of nonzeros is
{\tt sigma}.

\subsubsection{set\_grid}

Synopsis

{\tt ecolab.set\_grid} {\em x} {\em y}

\noindent Set up an $x\times y$ grid in spatial \EcoLab. See
\verb+ecolab_spatial.tcl+ for an example using this.

\subsubsection{get}

Synopsis

{\tt ecolab.get} {\em x} {\em y}

\noindent Create TCL method for accessing the internals of cell $x$
$y$. The new commands look like array elements, eg
\begin{verbatim}
ecolab(1,0).density
\end{verbatim}

\subsubsection{forall}

Synopsis

{\tt ecolab.forall ecolab.}{\em command} {\em args}

Run {\em command} on all cells.

\subsection{Spatial Variation}\label{spatial}

The ecolab model can run in multicellular mode by calling
\verb+ecolab.set_grid+ from TCL, specifying the dimensions of the
grid.\index{set\_grid}. See
\verb+ecolab_spatial.tcl+\index{ecolab\_spatial} for an example.

Only population density varies between the cells --- all other
variables are members of the ecolab variable so can be set or queried
in the usual way.

The usual ecolab model methods (generate, mutate, condense and
lifetimes)\index{generate}\index{mutate}\index{condense}\index{lifetimes}
can now be called, but operate on the entire grid. A new {\tt
migrate}\index{migrate} is defined to handle migration between
cells. You can also call a method of the ecolab cell on all cells
using the \verb+forall+\index{forall} command. For instance, to set
all cells to same initial density, use:
\begin{verbatim}
ecolab.forall ecolab.density [constant $nsp 100]
\end{verbatim}

Access to the individual cells can obtain by creating a TCL\_obj to
refer to it by using the \verb+ecolab.get+\index{get} method, which
creates commands like {\tt ecolab({\em x},{\em y})} to refer to the
cell. These can be fed to visualisers in the usual way.

\subsubsection{Parallel Execution}

Since the cells are pins in a \hyperref{graphcode Graph}{graphcode
  Graph (\S}{)}{graphcode}\index{graphcode}, they are distributed over
parallel processes if available.

Remember to call the \verb+gather+\index{gather} method to ensure node
0 is updated before running a visualiser on global data.

\begin{description}
\item[ecolab.gather] Bring processor 0's data up to date with the rest
  of the grid
\item[ecolab.distribute\_cells] Broadcast processor 0's data out to the
  rest of the grid.
\end{description}

\section{Palauan Jellyfish model}\label{jellyfish}

This is a model being developed by Mike Dawson and Russell Standish to
model the behaviour of jellyfish in a number of lakes on the island of
Palau. Jellyfish are photosynthetic animals, so have have a preference
for the sun and avoiding shadows. In this model, the jellyfish are
represented by agents that have a position and velocity. If the
jellyfish moves into shadow, or bumps into the side of the lake, it
will reverse its direction. From time to time, the jellyfish will
change direction and speed. The random generators governing these are
selectable at runtime through the experimental script. Also, jellyfish
do bump into each other. In the model display, a jellyfish will flash
green if it bumps into another one.

To run the jellyfish model, run the jellyfish.tcl script (located in
the models directory), specifying the lake as an argument, eg:
\begin{verbatim}
jellyfish.tcl lakes/OTM
\end{verbatim}

You can choose whether to compile the 2D version of the model or the
3D version, by (not) defining the preprocessor flag
\verb+THREE_D+\index{THREE\_D} (see Makefile).

The lake itself is represented by a Tk pixmap, with the blue component
representing water. The lake shapes were scanned into a GIF file, and
edited with a run-of-the-mill paint program to produce the lakes.

Visualising the lake involved creating a Tk canvas widget, displaying
the lake image in it, then overlaying it with shadow lines extending
from the pixels lying on the boundary, and finally representing the
jellyfish with arrow symbols (to indicate position and velocity).

This model illustrates the use of probes. Mouse clicks in the canvas
region are bound to a short method that determines which agent is
closest to the mouse position. It then colours that agent red (for
tracking purposes), creates a TCL\_obj representing that agent, and
returns the name back to TCL. TCL then calls the object browser
(\S\ref{object-browser}) on that TCL\_obj. In all, 14 lines of C++
code, and 3 lines of TCL code. The result is very effective.

The jellyfish model is written to be run in parallel using
\hyperref{Graphcode}{Graphcode
  (\S}{)}{graphcode}\index{graphcode}. The strategy is effectively a
{\em particle-in-cell} method. The lake is subdivided into a Cartesion
grid of cells, and each Jellyfish only needs to consult the cell that
it is in, as well as neighbouring cells to determine if it will
collide with any other jellyfish.


\documentclass[11pt]{amsart}
\usepackage{geometry}                % See geometry.pdf to learn the layout options. There are lots.
\geometry{letterpaper}                   % ... or a4paper or a5paper or ...
%\geometry{landscape}                % Activate for for rotated page geometry
%\usepackage[parfill]{parskip}    % Activate to begin paragraphs with an empty line rather than an indent
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{epstopdf}
\DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .tif`.png}

\title{Discretization of Elliptic Linear PDE and Neural Network}
%\author{The Author}
%\date{}                                           % Activate to display a given date or no date

\begin{document}
\maketitle
%\section{}
%\subsection{}

\section{Problem setup}
\subsection{HJB}
We want to solve a d-dimensions linear PDE given below:
\begin{itemize}
 \item Domain
 $$O = \{x\in \mathbb R^{d}: 0<x_{i}< 1, i =1,2, \ldots d\}.$$
 \item Equation on $O$:
 $$(\frac 1 2 \Delta -  \lambda) v(x) +
 \sum_{i=1}^db_i(x)  \frac{\partial v(x)}{\partial x_i}
  + \ell(x) = 0.$$
 \item Dirichlet data on $\partial O$:
 $$v(x) = g(x).$$
\end{itemize}

\subsection{Examples}

\subsubsection{Multidimensional PDE with quadratic function as its solution}
Consider a class of PDE with coefficients satisfying,
$$d - \lambda \|x - \frac 1 2 {\bf 1}\|_{2}^{2}
+ b(x)\cdot (2x - {\bf 1})+ \ell(x) = 0,$$
where ${\bf 1}$ is an $\mathbb R^{d}$-vector with each element being $1$.
The exact solution is
$$
v(x) = \|x - \frac 1 2 {\bf 1}\|_{2}^{2} = \sum_{i=1}^{d} (x_{i} - \frac 1 2)^{2}.
$$

\section{Discretization}

\subsection{FDM}
We introduce some notions of finite difference operators.
Commonly used first order finite difference operators
are FFD, BFD, and CFD.
Forward Finite Difference (FFD) is
$$\frac{\partial}{\partial x_{i}}v(x) \approx \delta_{he_{i}} v(x)
:= \frac{v(x+he_{i}) - v(x)}{h}.$$
Backward Finite Difference (BFD) is
$$\frac{\partial}{\partial x_{i}}v(x) \approx \delta_{-he_{i}} v(x)
:= \frac{v(x-he_{i}) - v(x)}{-h}.$$
Central Finite Difference (CFD) is
$$\frac{\partial}{\partial x_{i}}v(x) \approx
\bar \delta_{h e_{i}} v(x)
:= \frac 1 2 (\delta_{-he_{i}} + \delta_{he_{i}}) v(x)
.$$
It can be verified that the CFD has the following explicit form:
$$\bar \delta_{h e_{i}} v(x) = \frac{v(x+he_{i}) - v(x-he_{i})}{2h}.$$
Second order finite difference operators are the followings:
$$
\frac{\partial^{2}}{\partial x_{i}^{2}} v(x)
\approx
\delta_{-he_{i}} \delta_{he_{i}} v(x)
= \frac{v(x+he_{i}) - 2 v(x) + v(x- he_{i})}{h^{2}}.
$$
Although the next operator will not be used below, we will write it for its completeness. If $i \neq j$, we use
$$
\begin{array}
 {ll}
\frac{\partial^{2}}{\partial x_{i} \partial x_{j}} v(x) &\approx
\frac 1 2 (\delta_{he_{i}} \delta_{-he_{j}} v(x) +
\delta_{he_{j}} \delta_{-he_{i}} v(x))
\end{array}
$$

\subsection{CFD on PDE}
Approximations for PDE are
$$
\frac{\partial v(x)}{\partial x_i} \leftarrow
\delta_{\pm h e_{i}} v(x)
$$
and
$$
\frac{\partial^2 v(x)}{\partial x_i^2} \leftarrow
\delta_{-he_{i}} \delta_{he_{i}} v(x).$$
For simplicity, if we set
$$
\gamma = \frac{d}{d+ h^{2} \lambda}, \
p^{h}(x \pm he_{i}|x) = \frac 1 {2d} (1 \pm h b_{i}(x)), \
\ell^{h}(x) = \frac{h^{2} \ell(x)}{d},
$$
then it yields DPP
$$
v (x) = \gamma
\Big\{ \ell^{h}(x) +
\sum_{i=1}^{d}
p^{h}(x+he_{i}|x) v(x+he_{i})
+ p^{h}(x-he_{i}|x) v(x-he_{i})
\Big\}.
$$

\subsection{UFD on PDE}
Upwind finite difference(UFD) is the following:
$$
\frac{\partial v(x)}{\partial x_i} \leftarrow
\delta_{ h e_{i}} v(x) \cdot I(b_{i}(x)\ge 0) +
\delta_{-he_{i}} v(x) \cdot I(b_{i}(x) <0)
$$
and
$$
\frac{\partial^2 v(x)}{\partial x_i^2} \leftarrow
\delta_{-he_{i}} \delta_{he_{i}} v(x).$$
Then, with
$$c = d+h\sum_{i} |b_{i}(x)|, \
\gamma = \frac{c}{c+h^{2}\lambda}, \
\ell^{h} = \frac{\ell(x) h^{2}}{c}, \
p^{h}(x \pm he_{i}|x) = \frac{1+ 2hb_{i}^{\pm}(x)}{2c},
$$
then it yields DPP
$$
v (x) = \gamma
\Big\{ \ell^{h}(x) +
\sum_{i=1}^{d}
p^{h}(x+he_{i}|x) v(x+he_{i})
+ p^{h}(x-he_{i}|x) v(x-he_{i})
\Big\}.
$$

\end{document}


\documentclass{article}
\usepackage{amsthm, amsmath, amssymb}
\usepackage{graphicx}
\title{Second order graph convolutional networks}
\date{}
\author{Elnur Gasanov}
\parindent=0.0mm
\begin{document}
\maketitle

\section{Introduction}

Many important business-oriented tasks (such as implicit social relation prediction, log data and paper classification) highly depend on graph-structured data which is a non-euclidean domain. For the given graph with the description of nodes we aim to classify each node. Solution of this problem related to, for example, citation graphs may enable automatic determination of conference section to which the given paper relates the most.

\section{Related work}

The idea to use spectral graph information in order to construct convolutional layers has been first proposed in~\cite{first_paper}. Later, in~\cite{CNN_LSF} authors proposed practical version of CNNs on graphs with fast, trainable filters. Further simplification to linearly approximated filters has lead to Graph Convolutional Network~\cite{GCN}, which became a state-of-art technique in 2015.
\section{Second order graph convolutional network (SO~-~GCN)}
\subsection{Spectral graph convolutions}

General form of filtering is the following~\cite{first_paper}:
\[
g_\theta \star x = Ug_\theta U^\top x
\]

Chebyshev parametrization of the filter has been proposed in~\cite{CNN_LSF}:
\begin{align}
g_\theta(L) = \sum\limits_{k=0}^{K-1} \theta_k T_k(\tilde{\Lambda}), \label{eq}
\end{align}
where $\tilde{\Lambda} = \frac{2}{\lambda_{\max}} \Lambda - I$ and  $T_k$ is the Chebyshev polynomial of order $k$.

$T_k(x) = 2 x T_{k-1}(x) - T_{k-2}(x), T_0(x) = 1, \ T_1(x) = x$.
\subsection{Layer-wise quadratic model}
Second order model according to the formula~\ref{eq} has got the following form:
\[
g_\theta \star x = (\theta_0' I + \theta_1' \tilde{L} + \theta_2' (2 \tilde{L}^2 - I))x,
\]
where $\tilde{L} = \frac{2}{\lambda_{\max}} L - I$ and $L = I - D^{-\frac12} A D^{-\frac12}$ is the Laplacian matrix of the graph. We will relax first two terms as it has been done in~\cite{GCN} (so that $\theta_0' I + \theta_1' \tilde{L} = \theta_1 \tilde{D}^{-\frac12} \tilde{A} \tilde{D}^{-\frac12} $). For the sake of calculation simplification, we will assume $\lambda_{\max} = 2$, so quadratic term will get the form: $ 2 \tilde{L}^2 - I = 2 D^{-\frac12} A D^{-1} A D^{-\frac12} - I$. In order to perform a kernel trick, as it has been done in~\cite{GCN}, we will get rid of the identity matrix, so finally the quadratic term will have the following form:
$$
\theta_2 (2 D^{-\frac12} A D^{-1} A D^{-\frac12} - I) \approx \theta_2' \tilde{D}_2^{-\frac12} A^2 \tilde{D}_2^{-\frac12},
$$
where $\tilde{D}_{2, ii} = \sum_j [A^2]_{ij}$. One layer's otput is:

\begin{align*}
Z = \text{ReLU} (\tilde{D}^{-\frac12} \tilde{A} \tilde{D}^{-\frac12} X W^{(1)} + \tilde{D}_2^{-\frac12} A^2 \tilde{D}_2^{-\frac12} X W^{(2)} )
\end{align*}

Let us denote $\hat{A}_1 = \tilde{D}^{-\frac12} \tilde{A} \tilde{D}^{-\frac12}, \ \hat{A}_2 = \tilde{D}_2^{-\frac12} A^2 \tilde{D}_2^{-\frac12}$, the final classification model $Z$ is:
$$
Z' = \text{ReLU} (\hat{A}_1 X W^{(0, 1)} + \hat{A}_2 X W^{(0, 1)})
$$
$$
Z = \text{SoftMax}(\hat{A}_1 Z' W^{(1, 1)} + \hat{A}_2 Z' W^{(0, 1)})
$$

\section{Computational experiments}

\subsection{Datasets}

We use two group of datasets: citation graph networks CiteSeer and Cora(\cite{Sen}) and web graph networks Texas and Wisconsin. We summarize information about the graphs in the table below.
\begin{table}[h]
\centering
\caption{Dataset statistics}
~\\
\begin{tabular}{c c c c c c}
{\bf Datasets} & {\bf Type} & {\bf Nodes} & {\bf Edges} & {\bf Classes} & {\bf Features}\\
\hline
Citeseer & Citation network & 3327 & 4732 & 6 & 3703\\
Cora & Citation network & 2708 & 5429 & 7 & 1433 \\
Texas & Web & 187 & 328 & 5 & 1703\\
Wisconsin & Web & 265 & 530 & 5 & 1703 \\
\end{tabular}
\end{table}

\subsection{Experimental setup}

We train two-layer graph convolutional network with a dropout layer between the layers. Weights of the model has been trained with Adam optimizer with stepsize 0.01. Each model has been trained for 200 epochs. For citation networks, training has been performed on 140 nodes, testing on 1000 nodes. For web networks, training has been performed on ten percent of data, testing on 70 percent (20 percent has been picked for validation).

\subsection{Results}

Classification accuracy of each model is summarized in the table below.

\begin{table}[h]
\centering
\caption{Summary of results in terms of classification accuracy}
~\\
\begin{tabular}{c c c c c}
{\bf Method} & {\bf CiteSeer} & {\bf Cora} & {\bf Texas} & {\bf Wisconsin}\\
\hline
GCN & 61.4 & 82.6 & 51.9 & 47.3\\
SO GCN & 64.1 & 83.6 & 56.5 & 48.9\\
\end{tabular}
\end{table}

As can be seen from it, for described experimental setup, SO GCN is always better than GCN.

\section{Conclusion}

Second order GCN is a good approach for solving classification problems as experiments show. Further extension of the work may lie in increasing the number of orders, comparison of time needed to train the model with performance and applying more advanced regularization techniques.

\bibliography{references}
\bibliographystyle{plain}
\end{document}


\documentclass{article}
\usepackage[minionint,mathlf,textlf]{MinionPro} % To gussy up a bit
\usepackage[margin=1in]{geometry}
\usepackage{graphicx} % For .eps inclusion
%\usepackage{indentfirst} % Controls indentation
\usepackage[compact]{titlesec} % For regulating spacing before section titles
\usepackage{adjustbox} % For vertically-aligned side-by-side minipages
\usepackage{array, mathrsfs, mhchem, amsmath} % For centering of tabulars with text-wrapping columns
\usepackage{hyper ref}

\pagenumbering{gobble}
\setlength\parindent{0 cm}
\begin{document}
\large
\section*{Introduction}
Transition from discussion of diffusion to cooperativity. Reminder of the scale imposed by diffusion and the dependence of the rate of oxygen transfer on the concentration gradient.
\[ c(x) = c(0) e^{-x\sqrt{k/D}} \]

\[ J = -D \frac{\partial c}{\partial x} \]

\section*{Heme and hemoglobin}

See slides.

\section*{Independent sites}
If the binding sites on each subunit of hemoglobin are truly independent, then we can treat each hemoglobin subunit separately. Consider the single site on one hemoglobin molecule. We'll represent the protein with $P$ and the oxygen molecule, its ligand, with an $L$ to emphasize the generality of the finding:

\begin{eqnarray*}
\ce{P + L <=>[K_D] PL}
\end{eqnarray*}

The dissociation constant $K_D$ is the ratio of the bound complex to its constituent parts:
\[ K_D = \frac{\left[ P \right]\left[ L \right]}{\left[ PL \right]} \]

We expect that as more ligand (oxygen) is added, the balance of this reaction will shift to a higher concentration of $[PL]$ than $[P]$. Therefore the fraction of bound sites should increase with $[L]$, and we would like to know more precisely how they vary together.\\

The total number of binding sites is equal to the total concentration of the protein, which is:

\[ \left[ P \right]_{tot} = \left[ PL \right] + \left[ P \right] \]

So the fraction of sites bound, which by convention is called $Y$, will be:

\[ Y = \frac{\left[ PL \right]}{\left[ P \right]_{tot}} = \frac{\left[ PL \right]}{\left[ PL \right] + \left[ P \right]} \]

We can rearrange the definition of the binding constant to find $[P] = K_D[PL]/[L]$ and plug in to eliminate $[P]$ from this expression:

\[ Y = \frac{\left[ PL \right]}{\left[ PL \right] + K_D\left[ PL \right]/\left[ L \right]} = \frac{1}{1 + K_D/\left[ L \right]} = \frac{\left[ L \right]}{\left[ L \right] + K_D} \]

This is a \textit{hyperbolic} curve. In this form the relationship to the familiar $y=c/x$ is probably not apparent. However, consider the asymptotes of this function: when the ligand concentration is large, $Y \to 1$; and although negative ligand concentrations are not physically meaningful, $Y \to - \infty$ as the ligand concentration goes to $-K_D$. Suppose that we shifted to the new coordinates $\left[ L' \right] = \left[ L \right] + K_D$ and $Y' = Y - 1$:

\begin{eqnarray*}
Y & = & \frac{\left[ L' \right] - K_D}{\left[ L' \right]}\\
Y' & = & Y - 1 = \frac{\left[ L' \right] - K_D}{\left[ L' \right]} - \frac{\left[ L' \right]}{\left[ L' \right]} = \frac{- K_D}{\left[ L' \right]}
\end{eqnarray*}

$\ldots$ which hopefully clarifies why we called this a hyperbolic function.\\

Point out that $K_D$ is equal to the concentration of ligand at half-saturation. Plot and point out how the approach to low binding fraction is quite slow, then suddenly abrupt at a ligand concentration very near zero.

``How bad is it": show that you need an 81-fold change in concentration to go from 10\% bound to 90\% bound. Yeesh -- hopefully your tissues never come close to this!

\section*{Cooperativity}
Let's suppose that the rate of oxygen binding or dissociation at any given site depends on the status of the other three sites. For example, once one oxygen molecule has been bound, it may be easier to bind a second one. (Later we'll discuss mechanistically how this could occur; but for now, we'll focus on demonstrating that this assumption is enough to give us the desired binding properties.) The ``on" and ``off" rates for ligand at a single site ($k_i$ and $k_{-1}$, respectively) may differ depending on how many ligands are currently bound to the protein:

\begin{eqnarray*}
\ce{P + L <=>[4k_1][k_{-1}] PL}\\
\ce{PL + X <=>[3k_2][2k_{-2}] PL_2}\\
\ce{PL_2 + X <=>[2k_3][3k_{-3}] PL_3}\\
\ce{PL_3 + X <=>[k_4][4k_{-4}] PL_4}
\end{eqnarray*}

Note that each rate $k_i$ is scaled by the number of equivalent sites on the protein at which binding or dissociation could take place. For example, the singly-bound complex PL has three sites at which a second ligand could bind and therefore a binding rate of $3k_2$; PL has only one bound ligand, so the dissociation rate is simply $k_{-1}$. With these rate constants, we can relate the concentrations of proteins in each state:

\begin{eqnarray*}
\left[ \textrm{PL} \right] & = & \frac{4k_1}{k_{-1}} \left[ \textrm{P} \right]\left[ \textrm{L} \right] = 4K_1 \left[ \textrm{P} \right]\left[ \textrm{L} \right]\\
\left[ \textrm{PL}_2 \right] & = &  \frac{3k_2}{2k_{-2}} \left[ \textrm{PL} \right]\left[ \textrm{L} \right] = \frac{6k_1k_2}{k_{-1}k_{-2}} \left[ \textrm{P} \right]\left[ \textrm{L} \right]^2 = 6K_1K_2 \left[ \textrm{P} \right]\left[ \textrm{L} \right]^2\\
\left[ \textrm{PL}_3 \right] & = &  \frac{2k_3}{3k_{-3}} \left[ \textrm{PL}_2 \right]\left[ \textrm{L} \right] = \frac{4k_1k_2k_3}{k_{-1}k_{-2}k_{-3}} \left[ \textrm{P} \right]\left[ \textrm{L} \right]^3 = 4K_1K_2K_3 \left[ \textrm{P} \right]\left[ \textrm{L} \right]^3\\
\left[ \textrm{PL}_4 \right] & = &  \frac{k_4}{4k_{-4}} \left[ \textrm{PL}_3 \right]\left[ \textrm{L} \right] = \frac{k_1k_2k_3k_4}{k_{-1}k_{-2}k_{-3}k_{-4}} \left[ \textrm{P} \right]\left[ \textrm{L} \right]^4 = K_1K_2K_3K_4 \left[ \textrm{P} \right]\left[ \textrm{L} \right]^4
\end{eqnarray*}

where we have introduced the constants $K_i = k_i/k_{-i}$ to simplify notation. Recall that the fraction of bound sites is:

\[ Y = \frac{\textrm{Number of sites bound by ligand}}{\textrm{Total number of binding sites}} = \frac{\sum_{i=1}^4 i \left[ \textrm{PL}_i \right]}{4 \sum_{i=0}^4 \left[ \textrm{PL}_i \right]} = \frac{\left[ \textrm{PL} \right] + 2 \left[ \textrm{PL}_2 \right] + 3 \left[ \textrm{PL}_3 \right] + 4 \left[ \textrm{PL}_4 \right]}{4 \left( \left[ \textrm{P} \right] + \left[ \textrm{PL} \right] + \left[ \textrm{PL}_2 \right] + \left[ \textrm{PL}_3 \right] + \left[ \textrm{PL}_4 \right] \right)}\]

Plugging in our expressions for the relative concentrations of proteins in each state:

\begin{eqnarray}
Y & = & \frac{\left[ P \right] \left( 4 K_1 \left[ L \right] + 12K_1K_2 \left[ L \right]^2 + 12K_1K_2K_3 \left[ L \right]^3 + 4K_1K_2K_3K_4 \left[ L \right]^4 \right)}{4\left[ P \right] \left( 1 + 4K_1 \left[ L \right] + 6K_1K_2 \left[ L \right]^2 + 4K_1K_2K_3 \left[ L \right]^3 + K_1K_2K_3K_4 \left[ L \right]^4\right)} \nonumber\\
Y & = & \frac{K_1 \left[ L \right] + 3K_1K_2 \left[ L \right]^2 + 3K_1K_2K_3 \left[ L \right]^3 + K_1K_2K_3K_4 \left[ L \right]^4}{1 + 4K_1 \left[ L \right] + 6K_1K_2 \left[ L \right]^2 + 4K_1K_2K_3 \left[ L \right]^3 + K_1K_2K_3K_4 \left[ L \right]^4 \label{adair}}
\end{eqnarray}
Equation \ref{adair} is the \textit{Adair equation} for a molecule with four binding sites. The relationship between $Y$ and $L$ will depend on the $K_i$ in a potentially complicated way. However, if we assume that the protein has a relatively high affinity for the final ligand (i.e. $K_4 \gg K_1, K_2, K_3$), this equation simplifies greatly to:
\begin{eqnarray*}
Y & \approx & \frac{K_1K_2K_3K_4 \left[ L \right]^4}{1 + K_1K_2K_3K_4 \left[ L \right]^4} = \frac{\left[ L \right]^4}{K + \left[ L \right]^4}
\end{eqnarray*}
where $K = 1/K_1K_2K_3K_4$ functions as an effective dissociation constant averaged over all of the binding events. This is a specific instance of the Hill equation:
\begin{eqnarray}
Y & = & \frac{\left[ X \right]^n}{K + \left[ X \right]^n\label{hill}}
\end{eqnarray}
where the exponent $n$ is called the \textit{Hill coefficient}. Notice that when $n=1$, the function is hyperbolic: this is equivalent to the non-cooperative case. For $n > 1$, the function is instead \textit{sigmoidal}, i.e. s-shaped.\footnote{The term refers to the lowercase Greek sigma glyph $\varsigma$, not $\sigma$.} This sigmoidal shape indicates that binding is more ``switch-like": it transitions from a low fractional saturation to a high fractional saturation at a ligand concentration potentially far from zero.\\

Why is this reaction scheme suggested by the Hill approximation not realistic for oxygen binding to hemoglobin?
\begin{eqnarray*}
\ce{P + 4L <=>[K] PL_4}
\end{eqnarray*}

A good measure of how ``switch-like" the behavior is can be given by the maximum slope of the curve, which we can of course find through differentiation:

\[ \frac{dY}{d\left[X\right]} = \frac{n[X]^{n-1}\left(K^n + [X]^n\right) - [X]^n \cdot -n [X]^{n-1}}{\left([X]^n + K^n\right)^2} = \frac{nK^n [X]^{n-1}}{\left([X]^n + K^n\right)^2} \]

Taking a second derivative (or simply examining the original curve) informs us that the maximum slope occurs when $[X]=K$, at which point $dY/d[X] = n/4K$. In other words, the slope at the inflection point increases linearly with the Hill coefficient.\\

Earlier we saw that for a hyperbolic curve, we would need an 81-fold difference in ligand concentration to go from 10\% to 90\% saturation. How much improvement have we bought with cooperativity? Let $A$ and $B$ be the concentrations of ligand at which $Y=0.1$ and $Y=0.9$, respectively, Then from the Hill equation:
\begin{eqnarray*}
0.1 = \frac{A^n}{K^n + A^n} & \implies & A = K\sqrt[n]{\frac{1}{9}}\\
0.9 = \frac{B^n}{K^n + B^n} & \implies & B = K\sqrt[n]{9}\\
\frac{B}{A} & = & \sqrt[n]{81}
\end{eqnarray*}
So for example if $n=4$, we need only a three-fold change in ligand concentration to move from 10\% to 90\% saturation, making it much easier to pick up and let go of, say, oxygen over a physiological range of partial pressures.\\

Is the Hill function a good fit to the hemoglobin data. To address this we will want to fit both parameters, $n$ (to keep ourselves honest) and $K$. Remember that for oxygen/hemoglobin we do have experimental control over the partial pressure of oxygen ([$L$]) and we can measure the fraction of heme groups bound by oxygen ($Y$) by spectrophotometry. We'll use linear regression to fit the parameters, using an algebraic trick to transform the Hill equation:
\begin{eqnarray*}
Y = \frac{\left[ L \right]^n}{K^n + \left[ L \right]^n} & \implies & 1 - Y = \frac{K^n}{K^n + \left[ L \right]^n}\\
\frac{Y}{1-Y} & = & \frac{\left[ L \right]^n}{K^n}\\
\log \left( \frac{Y}{1-Y} \right) & = & n \log \left[ L \right] - n \log K
\end{eqnarray*}

Notice that this equation has the form of a line, with slope $n$ and y-intercept $-n\log K$. We simply use our measurements of [$L$] and $T$ to plot $\log (Y/1-Y)$ vs. $\log [L]$, then find $n$ and $K$\footnote{Of course, we will need to fit $n$ and $-n\log K$ first, then back out what the value of $K$ should be.} by linear regression.\\

We see that the best-fit slope is $n=2.8$, which is lower than the $n=4$ we might have predicted naively. The reason is that our approximation ($K_4 \gg K_1, K_2, K_3$) was unrealistic: cooperative binding of the final ligand is not so large that the other terms of the Adair equation can be fully ignored while assuming $n=4$. Relaxing the constraint on $n$ allowed us to obtain a good fit to the Hill equation anyway, by choosing a smaller value of $n$. The best-fit value of $n$ is still useful, however: it provides a lower bound to the number of ligand binding sites.

\section*{Monod-Wyman-Changeux Model}
We have now seen that cooperativity provides the switch-like binding behavior we hoped for, as well as the Adair and Hill equations which fit the data well. We still lack a mechanistic insight: how does hemoglobin achieve the change in binding coefficients? Which of the binding coefficients in the Adair equation are likely to differ and why?\\

We have a clue, of course: each heme group sits in a subunit of hemoglobin, and when oxygen binds, the surrounding subunit changes shape. (This change is at least partly mediated by the physical connection of an amino acid side chain to the heme group.) We have the structures for fully bound and unbound hemoglobin: this animation is just an inferred transition between them. But the concerted motion is a simplified model for what might be causing the transition from low to high affinity.

Let's assume the ratio $K = [P_T]/[P_R]$ is relatively large: when no ligand is bound, the taut state is highly favored. However, the ratio $[P_TL_4]/[P_TL_4]$ for the fully bound complex is somewhat small, favoring the relaxed state. Each state has its own binding constant, $K_T$ or $K_R$, that does \textit{not} vary depending on the number of ligands bound (modulo the multiplicities in the rate constants). Choose $K_T < K_R$ so that most hemoglobins will have either none or all sites bound. We'll see that these three parameters -- $K$, $K_T$, and $K_R$ -- are all we need to get cooperativity.\\

Let's start by relating all of our concentrations, as we did before for Adair equation:
\begin{eqnarray*}
\left[ P_RL \right] = 4K_R \left[ P_R \right] \left[ L \right] &  & \left[ P_TL \right] = 4K_T \left[ P_T \right] \left[ L \right] = 4\alpha K_R K \left[ P_R \right] \left[ L \right]\\
\left[ P_RL_2 \right] = 6K_R^2 \left[ P_R \right] \left[ L \right]^2 &  & \left[ P_TL_2 \right] = 6\alpha^2 K_R^2 K \left[ P_R \right] \left[ L \right]^2\\
\left[ P_RL_3 \right] = 4K_R^3 \left[ P_R \right] \left[ L \right]^3 &  & \left[ P_TL_3 \right] = 4 \alpha^3 K_R^3 K \left[ P_R \right] \left[ L \right]^3\\
\left[ P_RL_4 \right] = K_R^4 \left[ P_R \right] \left[ L \right]^4 &  & \left[ P_TL_4 \right] = \alpha^4 K_R^4 K \left[ P_R \right] \left[ L \right]^4\\
\end{eqnarray*}

This is all of the information needed to find the fraction of all sites bound:

\begin{eqnarray*}
 Y & = & \frac{\textrm{Number of sites bound by ligand}}{\textrm{Total number of binding sites}} = \frac{\sum_{i=1}^4 i \left[ \textrm{P$_R$L}_i \right] \, + \, \sum_{i=1}^4 i  \left[ \textrm{P$_T$L}_i \right]}{4 \left(\sum_{i=0}^4 \left[ \textrm{P$_R$L}_i \right] \, + \, \sum_{i=0}^4 \left[ \textrm{P$_T$L}_i \right]\right)}\\
& = & \frac{K_R \left[ L \right] \left( 1 + 3 K_R\left[ L \right] + 3 K_R^2\left[ L \right]^2 + K_R^3\left[ L \right]^3\right) + \alpha K_R K \left[ L \right] \left( 1 + 3 \alpha K_R\left[ L \right] + 3 \alpha^2 K_R^2\left[ L \right]^2 + \alpha^3 K_R^3\left[ L \right]^3\right)}{1 + 4 K_R\left[ L \right] + \ldots +  K_R^4\left[ L \right]^4 + K\left( 1 + 4 \alpha K_R\left[ L \right] + \ldots +  \alpha^4 K_R^4\left[ L \right]^4 \right)}\\
& = & K_R \left[ L \right]  \frac{\left( 1 + K_R \left[ L \right]\right)^3 + \alpha K \left( 1 + \alpha K_R \left[ L \right]\right)^3}{\left( 1 + K_R \left[ L \right]\right)^4 + K \left( 1 + \alpha K_R \left[ L \right]\right)^4}
\end{eqnarray*}
More generally for $b$ binding sites:
\begin{eqnarray}
Y & = & K_R \left[ L \right]  \frac{\left( 1 + K_R \left[ L \right]\right)^{b-1} + \alpha K \left( 1 + \alpha K_R \left[ L \right]\right)^{b-1}}{\left( 1 + K_R \left[ L \right]\right)^b + K \left( 1 + \alpha K_R \left[ L \right]\right)^b}
\end{eqnarray}
Although probably not obvious, this corresponds to a sigmoidal binding curve. What was the trick?\\

You can make a Hill plot this function (numerically or, with even more gnarly algebra, through rearrangement) to get [INSERT GRAPHIC]. As you can see the slope of the curve is one at both very large and very small concentrations of ligand. The y-intercepts are different for the two asymptotic lines, however: from before we know this must mean that the binding constants differ. In other words, the protein has sites that bind non-cooperatively (Hill coefficient $n=1$) but the protein's effective binding constant transitions from $K_T$ to $K_R$ as the concentration of ligand increases.\\

This model does a very good job of fitting the data and we may now feel we have a plausible explanation for the transition in affinity.

\section*{Koshland Model}
...however we know that at least some of the conformational changes associated with oxygen binding really are induced by the presence of the ligand. For example, the histidine chain movement is caused by the change in coordination at the iron atom. It is not likely that all these changes really propagate from one subunit to all of the others or that the change is ``all-or-nothing." A more plausible model perhaps is that the nearest neighbors of a bound subunit change to a conformational state that is slightly more receptive to oxygen binding. The Koshland model -- which I'll introduce only philosophically here -- captures that intuition. The fit to the data is not, unfortunately, really any better upon accounting for differences in parameter number.

\section*{Another Mechanism: Tethering}
We have been trying to justify why the binding constants would be different using conformational changes in the protein. However sometimes the explanation is much simpler.\\

Another case where switch-like behavior is desirable is gene regulation, as you saw in section 1's discussion of the Lac operon. As a reminder this is a set of genes which are only required when lactose is present and are therefore normally repressed by the transcription factor LacI. LacI is a dimer-of-dimers: each tetramer is capable of binding to two binding sites called lac operators or lacO sites. There are three twenty-something basepair Lac operators in the 6 Mbp \textit{E. coli} genome and they are all within a few hundred basepairs of each other. For a LacI protein scanning the genome, the hard part is unquestionably finding one of the three Lac operators. However, once that ``first" operator has been bound, the probability of binding a second operator substantially increases.\\

The reason is not due to a conformational change, but rather tethering. You can think of it like the cup-and-ball game. The other operators cannot be very far away from the first one that LacI found, since they are connected by a relatively short stretch of DNA. Eventually the random coil of DNA will bend such that LacI's other end encounters that site and binds it. So we have effectively changed the ``on" rate at the second site by ensuring that other operators are close at hand.

\end{document}

lectures/Lecture 7 - Inhibition and Cooperativity/ls200 cooperativity lecture.tex