[
  {
    "path": ".gitignore",
    "content": "*.log\n*.toc\n*.aux\n*.idx\n*.out\n*.synctex.gz"
  },
  {
    "path": "README.md",
    "content": "Machine learning cheat sheet\n============================\n\nThis cheat sheet contains many classical equations and diagrams on machine learning, which will help you quickly recall knowledge and ideas on machine learning.\n\nThe cheat sheet will also appeal to someone who is preparing for a job interview related to machine learning.\n\n\n## Download PDF\n[machine-learning-cheat-sheet.pdf](https://github.com/soulmachine/machine-learning-cheat-sheet/raw/master/machine-learning-cheat-sheet.pdf) \n\n\n## How to compile\n\n    docker pull soulmachine/texlive\n    docker run -it --rm -v $(pwd):/data -w /data soulmachine/texlive xelatex -synctex=1 --enable-write18 -interaction=nonstopmode machine-learning-cheat-sheet.tex\n\n\n## LaTeX template\nThis open-source book adopts the [Springer latex template](http://www.springer.com/authors/book+authors?SGWID=0-154102-12-970131-0).\n\n\n## How to compile on Windows\n1. Install [Tex Live 2014](http://www.tug.org/texlive/), then add its `bin` path for example `D:\\texlive\\2012\\bin\\win32` to he PATH environment variable.\n2. Install [TeXstudio](http://texstudio.sourceforge.net/).\n3. Configure TeXstudio.  \n    Run TeXstudio, click `Options-->Configure Texstudio-->Commands`, set `XeLaTex` to `xelatex -synctex=1 -interaction=nonstopmode %.tex`.\n    \n    Click `Options-->Configure Texstudio-->Build`,   \n    set `Build & View` to `Compile & View`,  \n    set `Default Compiler` to `XeLaTex`,  \n    set `PDF Viewer` to `Internal PDF Viewer(windowed)`, so that when previewing it will pop up a standalone window, which will be convenient.\n4. Compile. Use Open `machine-learning-cheat-sheet.tex` with TeXstudio，click the green arrow on the menu bar, then it will start to compile.  \n    In the messages window below we can see the compilation command that TeXstudio is using is `xelatex -synctex=1 --enable-write18 -interaction=nonstopmode \"machine-learning-cheat-sheet\".tex`\n"
  },
  {
    "path": "acknow.tex",
    "content": "%%%%%%%%%%%%%%%%%%%%%%acknow.tex%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% sample acknowledgement chapter\n%\n% Use this file as a template for your own input.\n%\n%%%%%%%%%%%%%%%%%%%%%%%% Springer %%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\extrachap{Acknowledgements}\n\nUse the template \\emph{acknow.tex} together with the Springer document class SVMono (monograph-type books) or SVMult (edited books) if you prefer to set your acknowledgement section as a separate chapter instead of including it as last part of your preface.\n\n"
  },
  {
    "path": "acronym.tex",
    "content": "%%%%%%%%%%%%%%%%%%%%%%acronym.tex%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% sample list of acronyms\n%\n% Use this file as a template for your own input.\n%\n%%%%%%%%%%%%%%%%%%%%%%%% Springer %%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\extrachap{Acronyms}\n\nUse the template \\emph{acronym.tex} together with the Springer document class SVMono (monograph-type books) or SVMult (edited books) to style your list(s) of abbreviations or symbols in the Springer layout.\n\nLists of abbreviations\\index{acronyms, list of}, symbols\\index{symbols, list of} and the like are easily formatted with the help of the Springer-enhanced \\verb|description| environment.\n\n\\begin{description}[CABR]\n\\item[ABC]{Spelled-out abbreviation and definition}\n\\item[BABI]{Spelled-out abbreviation and definition}\n\\item[CABR]{Spelled-out abbreviation and definition}\n\\end{description}"
  },
  {
    "path": "cblist.tex",
    "content": "%%%%%%%%%%%%%%%%%%%%clist.tex %%%%%%%%%%%%%%%%%%%%%%%%\n%                                                    \n% sample list of contributors and their addresses    \n%                                                    \n% Use this file as a template for your own input.    \n%                                                    \n%%%%%%%%%%%%%%%%%%%%%%%% Springer %%%%%%%%%%%%%%%%%%%%\n\\contributors\n\n\\begin{thecontriblist}\nWei Zhang\n\\at PhD candidate at the Institute of Software, Chinese Academy of Sciences (ISCAS), Beijing, P.R.CHINA, \\email{zh3feng@gmail.com}, has written chapters of Naive Bayes and SVM.\n\\and\nFei Pan\n\\at Master at Beijing University of Technology, Beijing, P.R.CHINA, \\email{example@gmail.com}, has written chapters of KMeans, AdaBoost.\n\\and\nYong Li\n\\at PhD candidate at the Institute of Automation of the Chinese Academy of Sciences (CASIA), Beijing, P.R.CHINA, \\email{liyong3forever@gmail.com}, has written chapters of Logistic Regression.\n\\and\nJiankou Li\n\\at PhD candidate at the Institute of Software, Chinese Academy of Sciences (ISCAS), Beijing, P.R.CHINA, \\email{lijiankoucoco@163.com}, has written chapters of BayesNet.\n\\end{thecontriblist}"
  },
  {
    "path": "chapterABM.tex",
    "content": "\\chapter{Adaptive basis function models}\n\n\n\\section{AdaBoost}\n\n\n\\subsection{Representation}\n\\begin{equation}\ny=\\text{sign}(f(\\vec{x}))=\\text{sign}\\left(\\sum\\limits_{i=1}^m \\alpha_mG_m(\\vec{x})\\right)\n\\end{equation}\nwhere $G_m(\\vec{x})$ are sub classifiers.\n\n\n\\subsection{Evaluation}\n\\begin{equation} \\nonumber\nL(y,f(\\vec{x}))=\\exp[-yf(\\vec{x})] \\text{  i.e., exponential loss function}\n\\end{equation}\n\n\\begin{equation}\n(\\alpha_m,G_m(x))= \\arg\\min_{\\alpha,G} \\sum_{i=1}^N \\exp{[-y_i(f_{m-1}(\\vec{x}_i)+\\alpha G(\\vec{x}_i))]}\n\\end{equation}\n\nDefine $\\bar{w}_{mi}=\\exp{[-y_i(f_{m-1}(\\vec{x}_i)]}$, which is constant w.r.t. $\\alpha, G$\n\\begin{equation}\n(\\alpha_m,G_m(x))= \\arg\\min_{\\alpha,G} \\sum_{i=1}^N {\\bar{w}}_{mi} \\exp{(-y_i \\alpha G(x_i))}\n\\end{equation}\n\n\n\\subsection{Optimization}\n\n\n\\subsubsection{Input}\n\\begin{eqnarray*}\n& \\mathcal{D}=\\{(\\vec{x}_1,y_1),(\\vec{x}_2,y2),\\dots,(\\vec{x}_N,y_N)\\} \\\\\n& \\quad \\text{where } \\vec{x}_i \\in \\mathbb{R}^D,\\ y_i \\in \\{-1,+1\\} \\\\\n& \\text{ Weak classifiers } \\{G_1,G_2,\\dots,G_m\\}\n\\end{eqnarray*}\n\n\n\\subsubsection{Output}\nFinal classifier: $G(x)$\n\n\n\\subsubsection{Algorithm}\n\\begin{enumerate}\n\\item Initialize the weights' distribution of training data(when $m=1$)\n\\begin{equation}\\nonumber\n\\mathcal{D}_0=(w_{11},w_{12},\\cdots,w_{1n})=(\\frac{1}{N},\\frac{1}{N},\\cdots,\\frac{1}{N})\n\\end{equation}\n\\item Iterate over $m=1,2,\\dotsc,M$\n\\subitem (a) Use training data with current weights' distribution $\\mathcal{D}_m$ to get a classifier $G_m(\\vec{x})$\n\\subitem (b) Compute the error rate of $G_m(\\vec{x})$ over the training data \\\\\n\\begin{equation}\ne_m=P(G_m(\\vec{x}_i)\\neq y_i)=\\sum_{i=1}^N {w_{mi}\\mathbb{I}(G_m(\\vec{x}_i) \\neq y_i)}\n\\end{equation}\n\n\\subitem (c) Compute the coefficient of classifier $G_m(x)$\n\\begin{equation}\n\\alpha_m = \\frac{1}{2}\\log{\\frac{1-e_m}{e_m}}\n\\end{equation}\n\\subitem (d) Update the weights' distribution of training data\n\\begin{equation}\nw_{m+1,i}=\\frac{w_{mi}}{Z_m}\\exp(-\\alpha_m y_i G_m(\\vec{x}_i))\n\\end{equation}\nwhere $Z_m$ is the normalizing constant\n\\begin{equation}\nZ_m=\\sum_{i=1}^N w_{mi}\\exp(-\\alpha_m y_i G_m(\\vec{x}_i))\n\\end{equation}\n\n\\item Ensemble $M$ weak classifiers\n\\begin{equation}\nG(x)=\\text{sign}f(\\vec{x})=\\text{sign}\\left[\\sum_{m=1}^M \\alpha_m G_m(\\vec{x})\\right]\n\\end{equation}\n\\end{enumerate} \n\n\\subsection{The upper bound of the training error of AdaBoost}\n\\begin{theorem}\nThe upper bound of the training error of AdaBoost is \n\\begin{equation}\n\\frac{1}{N} \\sum_{i=1}^N \\mathbb{I}(G(\\vec{x}_i)\\neq y_i) \\leq \\frac{1}{N} \\sum_{i=1}^N \\exp(-y_i f(\\vec{x}_i))=\\prod_{m=1}^M Z_m\n\\end{equation}\n\nNote: the following equation would help proof this theorem\n\\begin{equation}\nw_{mi}\\exp(-\\alpha_m y_i G_m(\\vec{x}_i))=Z_m w_{m+1,i}\n\\end{equation}\n\\end{theorem}\n"
  },
  {
    "path": "chapterBayesianStatistics.tex",
    "content": "\\chapter{Bayesian statistics}\n\n\n\\section{Introduction}\nUsing the posterior distribution to summarize everything we know about a set of unknown variables is at the core of Bayesian statistics. In this chapter, we discuss this approach to statistics in more detail.\n\n\n\\section{Summarizing posterior distributions}\nThe posterior $p(\\vec{\\theta}|\\mathcal{D})$ summarizes everything we know about the unknown quantities $\\vec{\\theta}$. In this section, we discuss some simple quantities that can be derived from a probability distribution, such as a posterior. These summary statistics are often easier to understand and visualize than the full joint.\n\n\n\\subsection{MAP estimation}\nWe can easily compute a \\textbf{point estimate} of an unknown quantity by computing the posterior mean, median or mode. In Section \\ref{sec:Bayesian-decision-theory}, we discuss how to use decision theory to choose between these methods. Typically the posterior mean or median is the most appropriate choice for a realvalued quantity, and the vector of posterior marginals is the best choice for a discrete quantity. However, the posterior mode, aka the MAP estimate, is the most popular choice because it reduces to an optimization problem, for which efficient algorithms often exist. Futhermore, MAP estimation can be interpreted in non-Bayesian terms, by thinking of the log prior as a regularizer (see Section TODO for more details).\n\nAlthough this approach is computationally appealing, it is important to point out that there are various drawbacks to MAP estimation, which we briefly discuss below. This will provide motivation for the more thoroughly Bayesian approach which we will study later in this chapter(and elsewhere in this book).\n\n\n\\subsubsection{No measure of uncertainty}\nThe most obvious drawback of MAP estimation, and indeed of any other \\emph{point estimate} such as the posterior mean or median, is that it does not provide any measure of uncertainty. In many applications, it is important to know how much one can trust a given estimate. We can derive such confidence measures from the posterior, as we discuss in Section \\ref{sec:Credible-intervals}.\n\n\\subsubsection{Plugging in the MAP estimate can result in overfitting}\nIf we don’t model the uncertainty in our parameters, then our predictive distribution will be overconfident. Overconfidence in predictions is particularly problematic in situations where we may be risk averse; see Section \\ref{sec:Bayesian-decision-theory} for details.\n\n\\subsubsection{The mode is an untypical point}\nChoosing the mode as a summary of a posterior distribution is often a very poor choice, since the mode is usually quite untypical of the distribution, unlike the mean or median. The basic problem is that the mode is a point of measure zero, whereas the mean and median take the volume of the space into account. See Figure \\ref{fig:untypical-point}.\n\n\\begin{figure}[hbtp]\n\\centering\n\\subfloat[]{\\includegraphics[scale=.50]{untypical-point-a.png}} \\\\\n\\subfloat[]{\\includegraphics[scale=.50]{untypical-point-b.png}}\n\\caption{(a) A bimodal distribution in which the mode is very untypical of the distribution. The thin blue vertical line is the mean, which is arguably a better summary of the distribution, since it is near the majority of the probability mass. (b) A skewed distribution in which the mode is quite different from the mean.}\n\\label{fig:untypical-point} \n\\end{figure}\n\nHow should we summarize a posterior if the mode is not a good choice? The answer is to use decision theory, which we discuss in Section \\ref{sec:Bayesian-decision-theory}. The basic idea is to specify a loss function, where $L(\\theta,\\hat{\\theta})$ is the loss you incur if the truth is $\\theta$ and your estimate is $\\hat{\\theta}$. If we use 0-1 loss $L(\\theta,\\hat{\\theta})=\\mathbb{I}(\\theta \\neq \\hat{\\theta})$(see section \\ref{sec:Loss-function-and-risk-function}), then the optimal estimate is the posterior mode. 0-1 loss means you only get “points” if you make no errors, otherwise you get nothing: there is no “partial credit” under this loss function! For continuous-valued quantities, we often prefer to use squared error loss, $L(\\theta,\\hat{\\theta})=(\\theta-\\hat{\\theta})^2$ ; the corresponding optimal estimator is then the posterior mean, as we show in Section \\ref{sec:Bayesian-decision-theory}. Or we can use a more robust loss function, $L(\\theta,\\hat{\\theta})=|\\theta-\\hat{\\theta}|$, which gives rise to the posterior median.\n\n\\subsubsection{MAP estimation is not invariant to reparameterization *}\nA more subtle problem with MAP estimation is that the result we get depends on how we parameterize the probability distribution. Changing from one representation to another equivalent representation changes the result, which is not very desirable, since the units of measurement are arbitrary (e.g., when measuring distance, we can use centimetres or inches).\n\nTo understand the problem, suppose we compute the posterior forx. If we define y=f(x), the distribution for yis given by Equation \\ref{eqn:General-transformations}. The $\\frac{\\mathrm{d}x}{\\mathrm{d}y}$ term is called the Jacobian, and it measures the change in size of a unit volume passed\nthrough $f$. Let $\\hat{x}=\\arg\\max_x p_x(x)$ be the MAP estimate for $x$. In general it is not the case that $\\hat{x}=\\arg\\max_x p_x(x)$ is given by $f(\\hat{x})$. For example, let $X \\sim \\mathcal{N}(6,1)$ and $y=f(x)$, where $f(x)=1/(1+\\exp(-x+5))$. \n\n\\begin{figure}[hbtp]\n\\centering\n    \\includegraphics[scale=.70]{mode-reparameterization.png}\n\\caption{Example of the transformation of a density under a nonlinear transform. Note how the mode of the transformed distribution is not the transform of the original mode. Based on Exercise 1.4 of (Bishop 2006b).}\n\\label{fig:mode-reparameterization} \n\\end{figure}\n\nWe can derive the distribution of $y$ using Monte Carlo simulation (see Section \\ref{sec:Monte-Carlo-approximation}). The result is shown in Figure \\ref{sec:mode-reparameterization}. We see that the original Gaussian has become “squashed” by the sigmoid nonlinearity. In particular, we see that the mode of the transformed distribution is not equal to the transform of the original mode.\n\nThe MLE does not suffer from this since the likelihood is a function, not a probability density. Bayesian inference does not suffer from this problem either, since the change of measure is taken into account when integrating over the parameter space.\n\n\n\\subsection{Credible intervals}\n\\label{sec:Credible-intervals}\nIn addition to point estimates, we often want a measure of confidence. A standard measure of confidence in some (scalar) quantity $\\theta$ is the “width” of its posterior distribution. This can be measured using a $100(1−\\alpha)\\%$ credible interval, which is a (contiguous) region $C=(\\ell,u)$(standing for lower and upper) which contains $1−\\alpha$ of the posterior probability mass, i.e.,\n\\begin{equation}\nC_{\\alpha}(\\mathcal{D}) \\quad \\text{where } P(\\ell \\leq \\theta \\leq u)=1-\\alpha\n\\end{equation}\n\nThere may be many such intervals, so we choose one such that there is $(1−\\alpha)/2$ mass in each tail; this is called a \\textbf{central interval}.\n\nIf the posterior has a known functional form, we can compute the posterior central interval using $\\ell=F^{-1}(\\alpha/2)$ and $u=F^{-1}(1-\\alpha/2)$, where $F$ is the cdf of the posterior. \n\nIf we don’t know the functional form, but we can draw samples from the posterior, then we can use a Monte Carlo approximation to the posterior quantiles: we simply sort the $\\mathcal{S}$ samples, and find the one that occurs at location $\\alpha/\\mathcal{S}$ along the sorted list. As $\\mathcal{S} \\rightarrow \\infty$, this converges to the true quantile. \n\nPeople often confuse Bayesian credible intervals with frequentist confidence intervals. However, they are not the same thing, as we discuss in Section TODO. In general, credible intervals are usually what people want to compute, but confidence intervals are usually what they actually compute, because most people are taught frequentist statistics but not Bayesian statistics. Fortunately, the mechanics of computing a credible interval is just as easy as computing a confidence interval. \n\n\n\\subsection{Inference for a difference in proportions}\nSometimes we have multiple parameters, and we are interested in computing the posterior distribution of some function of these parameters. For example, suppose you are about to buy something from Amazon.com, and there are two sellers offering it for the same price. Seller 1 has 90 positive reviews and 10 negative reviews. Seller 2 has 2 positive reviews and 0 negative reviews. Who should you buy from?\\footnote{This example is from \\url{http://www.johndcook.com/blog/2011/09/27/bayesian-amazon/}}.\n\nOn the face of it, you should pick seller 2, but we cannot be very confident that seller 2 is better since it has had so few reviews. In this section, we sketch a Bayesian analysis of this problem. Similar methodology can be used to compare rates or proportions across groups for a variety of other settings.\n\nLet $\\theta_1$ and $\\theta_2$ be the unknown reliabilities of the two sellers. Since we don’t know much about them, we’ll endow them both with uniform priors, $\\theta_i \\sim \\text{Beta}(1,1)$. The posteriors are $p(\\theta_1|\\mathcal{D}_1)=\\text{Beta}(91,11)$ and $p(\\theta_2|\\mathcal{D}_2)=\\text{Beta}(3,1)$.\n\nWe want to compute $p(\\theta_1 >\\theta_2|\\mathcal{D})$. For convenience, let us define $\\delta=\\theta_1-\\theta_2$ as the difference in the rates. (Alternatively we might want to work in terms of the log-odds ratio.) We can compute the desired quantity using numerical integration\n\\begin{equation}\n\\begin{split}\np(\\delta>0|\\mathcal{D}) & = \\int_0^1\\int_0^1 \\mathbb{I}(\\theta_1>\\theta_2)\\text{Beta}(\\theta_1|91,11) \\\\\n                        & \\quad \\text{Beta}(\\theta_2|3,1)\\mathrm{d}\\theta_1\\mathrm{d}\\theta_2\n\\end{split}\n\\end{equation}\n\nWe find $p(\\delta>0|\\mathcal{D})=0.710$, which means you are better off buying from seller 1! \n\n\n\\section{Bayesian model selection}\n\\label{sec:Bayesian-model-selection}\n\nIn general, when faced with a set of models (i.e., families of parametric distributions) of different complexity, how should we choose the best one? This is called the \\textbf{model selection} problem.\n\nOne approach is to use cross-validation to estimate the generalization error of all the candidate models, and then to pick the model that seems the best. However, this requires fitting each model $K$ times, where $K$ is the number of CV folds. A more efficient approach is to compute the posterior over models,\n\\begin{equation}\np(m|\\mathcal{D})=\\dfrac{p(\\mathcal{D}|m)p(m)}{\\sum_{m'}p(\\mathcal{D}|m')p(m')}\n\\end{equation}\n\nFrom this, we can easily compute the MAP model, $\\hat{m}=\\arg\\max_m{p(m|\\mathcal{D})}$. This is called \\textbf{Bayesian model selection}.\n\nIf we use a uniform prior over models, this amounts to picking the model which maximizes\n\\begin{equation}\\label{eqn:marginal-likelihood}\np(\\mathcal{D}|m)=\\int{p(\\mathcal{D}|\\vec{\\theta})p(\\vec{\\theta}|m)}\\mathrm{d}\\vec{\\theta}\n\\end{equation}\n\nThis quantity is called the \\textbf{marginal likelihood}, the \\textbf{integrated likelihood}, or the \\textbf{evidence} for model $m$. The details on how to perform this integral will be discussed in Section \\ref{sec:Computing-the-marginal-likelihood}. But first we give an intuitive interpretation of what this quantity means.\n\n\n\\subsection{Bayesian Occam's razor}\nOne might think that using $p(\\mathcal{D}|m)$ to select models would always favour the model with the most parameters. This is true if we use $p(\\mathcal{D}|\\hat{\\vec{\\theta}}_m)$ to select models, where $\\hat{\\vec{\\theta}}_m)$ is the MLE or MAP estimate of the parameters for model $m$, because models with more parameters will fit the data better, and hence achieve higher likelihood. However, if we integrate out the parameters, rather than maximizing them, we are automatically protected from overfitting: models with more parameters do not necessarily have higher \\emph{marginal likelihood}. This is called the \\textbf{Bayesian Occam’s razor} effect (MacKay 1995b; Murray and Ghahramani 2005), named after the principle known as \\textbf{Occam’s razor}, which says one should pick the simplest model that adequately explains the data.\n\nOne way to understand the Bayesian Occam’s razor is to notice that the marginal likelihood can be rewritten as follows, based on the chain rule of probability (Equation \\ref{eqn:product-rule}):\n\\begin{equation}\\begin{split}\np(D) & =p((\\vec{x}_1,y_1))p((\\vec{x}_2,y_2)|(\\vec{x}_1,y_1)) \\\\\n     & \\quad p((\\vec{x}_3,y_3)|(\\vec{x}_1,y_1):(\\vec{x}_2,y_2))\\cdots \\\\\n\t & \\quad p((\\vec{x}_N,y_N)|(\\vec{x}_1,y_1):(\\vec{x}_{N-1},y_{N-1}))\n\\end{split}\\end{equation}\n\nThis is similar to a leave-one-out cross-validation estimate (Section \\ref{sec:Cross-validation}) of the likelihood, since we predict each future point given all the previous ones. (Of course, the order of the data does not matter in the above expression.) If a model is too complex, it will overfit the “early” examples and will then predict the remaining ones poorly.\n\nAnother way to understand the Bayesian Occam’s razor effect is to note that probabilities must sum to one. Hence $\\sum_{p(\\mathcal{D}')} p(m|\\mathcal{D}')=1$, where the sum is over all possible data sets. Complex models, which can predict many things, must spread their probability mass thinly, and hence will not obtain as large a probability for any given data set as simpler models. This is sometimes called the \\textbf{conservation of probability mass} principle, and is illustrated in Figure \\ref{fig:Bayesian-Occams-razor}.\n\n\\begin{figure}[hbtp]\n\\centering\n    \\includegraphics[scale=.80]{Bayesian-Occams-razor.png}\n\\caption{A schematic illustration of the Bayesian Occam’s razor. The broad (green) curve corresponds to a complex model, the narrow (blue) curve to a simple model, and the middle (red) curve is just right. Based on Figure 3.13 of (Bishop 2006a). }\n\\label{fig:Bayesian-Occams-razor} \n\\end{figure}\n\nWhen using the Bayesian approach, we are not restricted to evaluating the evidence at a finite grid of values. Instead, we can use numerical optimization to find $\\lambda^*=\\arg\\max_{\\lambda}p(\\mathcal{D}|\\lambda)$. This technique is called \\textbf{empirical Bayes} or \\textbf{type II maximum likelihood} (see Section \\ref{sec:Empirical-Bayes} for details). An example is shown in Figure TODO(b): we see that the curve has a similar shape to the CV estimate, but it can be computed more efficiently.\n\n\n\\subsection{Computing the marginal likelihood (evidence)}\n\\label{sec:Computing-the-marginal-likelihood}\nWhen discussing parameter inference for a fixed model, we often wrote\n\\begin{equation}\np(\\vec{\\theta}|\\mathcal{D},m) \\propto p(\\vec{\\theta}|m)p(\\mathcal{D}|\\vec{\\theta},m)\n\\end{equation}\nthus ignoring the normalization constant $p(\\mathcal{D}|m)$. This is valid since $p(\\mathcal{D}|m)$is constant wrt $\\vec{\\theta}$. However, when comparing models, we need to know how to compute the marginal likelihood, $p(\\mathcal{D}|m)$. In general, this can be quite hard, since we have to integrate over all possible parameter values, but when we have a conjugate prior, it is easy to compute, as we now show.\n\nLet $p(\\vec{\\theta})=q(\\vec{\\theta})/Z_0$ be our prior, where $q(\\vec{\\theta})$ is an unnormalized distribution, and $Z_0$ is the normalization constant of the prior. Let $p(\\mathcal{D}|\\vec{\\theta})=q(\\mathcal{D}|\\vec{\\theta})/Z_{\\ell}$ be the likelihood, where $Z_{\\ell}$ contains any constant factors in the likelihood. Finally let $p(\\vec{\\theta}|\\mathcal{D})=q(\\vec{\\theta}|\\mathcal{D})/Z_N$ be our posterior , where $q(\\vec{\\theta}|\\mathcal{D})=q(\\mathcal{D}|\\vec{\\theta})q(\\vec{\\theta})$ is the unnormalized posterior, and $Z_N$ is the normalization constant of the posterior. We have\n\\begin{align}\np(\\vec{\\theta}|\\mathcal{D})& =\\dfrac{p(\\mathcal{D}|\\vec{\\theta})p(\\vec{\\theta})}{p(\\mathcal{D})} \\\\\n\\dfrac{q(\\vec{\\theta}|\\mathcal{D})}{Z_N}& =\\dfrac{q(\\mathcal{D}|\\vec{\\theta})q(\\vec{\\theta})}{Z_{\\ell}Z_0p(\\mathcal{D})} \\\\\np(\\mathcal{D})& = \\dfrac{Z_N}{Z_0Z_{\\ell}}\n\\end{align}\n\nSo assuming the relevant normalization constants are tractable, we have an easy way to compute the marginal likelihood. We give some examples below.\n\n\\subsubsection{Beta-binomial model}\nLet us apply the above result to the Beta-binomial model. Since we know $p(\\vec{\\theta}|\\mathcal{D})=\\mathrm{Beta}(\\vec{\\theta}|a',b')$, where $a'=a+N_1$, $b'=b+N_0$, we know the normalization constant of the posterior is $B(a',b')$. Hence\n\\begin{align}\np(\\theta|\\mathcal{D})& =\\dfrac{p(\\mathcal{D}|\\theta)p(\\theta)}{p(\\mathcal{D})} \\\\\n    & =\\dfrac{1}{p(\\mathcal{D})}\\left[\\dfrac{1}{B(a,b)}\\theta^{a-1}(1-\\theta)^{b-1}\\right] \\nonumber \\\\\n\t& \\quad \\left[\\dbinom{N}{N_1}\\theta^{N_1}(1-\\theta)^{N_0}\\right] \\\\\n\t& =\\dbinom{N}{N_1}\\dfrac{1}{p(\\mathcal{D})}\\dfrac{1}{B(a,b)}\\left[\\theta^{a+N_1-1}(1-\\theta)^{b+N_0-1}\\right]\n\\end{align}\n\nSo\n\\begin{align}\n\\dfrac{1}{B(a+N_1,b+N_0)} & = \\dbinom{N}{N_1}\\dfrac{1}{p(\\mathcal{D})}\\dfrac{1}{B(a,b)} \\\\\np(\\mathcal{D}) & = \\dbinom{N}{N_1}\\dfrac{B(a+N_1,b+N_0)}{B(a,b)}\n\\end{align}\n\nThe marginal likelihood for the Beta-Bernoulli model is the same as above, except it is missingthe $\\binom{N}{N_1}$ term.\n\n\\subsubsection{Dirichlet-multinoulli model}\nBy the same reasoning as the Beta-Bernoulli case, one can show that the marginal likelihood for the Dirichlet-multinoulli model is given by\n\\begin{align}\np(\\mathcal{D}) & =\\dfrac{B(\\vec{N}+\\vec{\\alpha})}{B(\\vec{\\alpha})} \\\\\n   & = \\dfrac{\\Gamma(\\sum_k \\alpha_k)}{\\Gamma(N+\\sum_k \\alpha_k)}\\prod\\limits_k \\dfrac{\\Gamma(N_k+\\alpha_k)}{\\Gamma(\\alpha_k)}\n\\end{align}\n\n\\subsubsection{Gaussian-Gaussian-Wishart model}\nConsider the case of an MVN with a conjugate NIW prior. Let $Z_0$ be the normalizer for the prior, $Z_N$ be normalizer for the posterior, and let $Z_{\\ell}(2\\pi)^{ND/2}=$ be the normalizer for the likelihood. Then it is easy to see that\n\\begin{align}\np(\\mathcal{D})& =\\dfrac{Z_N}{Z_0Z_{\\ell}} \\\\\n   & = \\dfrac{1}{(2\\pi)^{ND/2}}\\dfrac{\\left(\\frac{2\\pi}{\\kappa_N}\\right)^{D/2}|\\vec{S}_N|^{-\\nu_N/2}2^{(\\nu_0+N)D/2}\\Gamma_D(\\nu_N/2)}{\\left(\\frac{2\\pi}{\\kappa_0}\\right)^{D/2}|\\vec{S}_0|^{-\\nu_0/2}2^{\\nu_0D/2}\\Gamma_D(\\nu_0/2)} \\\\\n   & = \\dfrac{1}{\\pi^{ND/2}}\\left(\\dfrac{\\kappa_0}{\\kappa_N}\\right)^{D/2}\\dfrac{|\\vec{S}_0|^{\\nu_0/2}}{|\\vec{S}_N|^{\\nu_N/2}}\\dfrac{\\Gamma_D(\\nu_N/2)}{\\Gamma_D(\\nu_0/2)}\n\\end{align}\n\n\\subsubsection{BIC approximation to log marginal likelihood}\nIn general, computing the integral in Equation \\ref{eqn:marginal-likelihood} can be quite difficult. One simple but popular approximation is known as the \\textbf{Bayesian information criterion} or \\textbf{BIC}, which has the following form (Schwarz 1978):\n\\begin{equation}\n\\mathrm{BIC} \\triangleq \\log p(\\mathcal{D}|\\hat{\\vec{\\theta}})-\\dfrac{\\mathrm{dof}(\\hat{\\vec{\\theta}})}{2}\\log{N}\n\\end{equation}\nwhere $\\mathrm{dof}(\\hat{\\vec{\\theta}})$ is the number of \\textbf{degrees of freedom} in the model, and $\\hat{\\vec{\\theta}}$ is the MLE for the model. We see that this has the form of a \\textbf{penalized log likelihood}, where the penalty term depends on the model’s complexity. See Section TODO for the derivation of the BIC score.\n\nAs an example, consider linear regression. As we show in Section TODO, the MLE is given by $\\hat{\\vec{w}}=(\\vec{X}^T\\vec{X})^{-1}\\vec{X}^T\\vec{y}$ and $\\sigma^2=\\frac{1}{N}\\sum_{i=1}^N (y_i-\\hat{\\vec{w}}^T\\vec{x}_i)$. The corresponding log likelihood is given by\n\\begin{equation}\n\\log p(\\mathcal{D}|\\hat{\\vec{\\theta}}) = -\\dfrac{N}{2}\\log(2\\pi\\hat{\\sigma}^2)-\\dfrac{N}{2}\n\\end{equation}\n\nHence the BIC score is as follows (dropping constant terms)\n\\begin{equation}\n\\mathrm{BIC}=-\\dfrac{N}{2}\\log(\\hat{\\sigma}^2)-\\dfrac{D}{2}\\log{N}\n\\end{equation}\nwhere $D$ is the number of variables in the model. In the statistics literature, it is common to use an alternative definition of BIC, which we call the BIC \\emph{cost}(since we want to minimize it):\n\\begin{equation}\n\\mathrm{BIC\\text{-}cost} \\triangleq -2\\log p(\\mathcal{D}|\\hat{\\vec{\\theta}})-\\mathrm{dof}(\\hat{\\vec{\\theta}})\\log{N} \\approx -2\\log{p(\\mathcal{D})}\n\\end{equation}\n\nIn the context of linear regression, this becomes\n\\begin{equation}\n\\mathrm{BIC\\text{-}cost} = N\\log(\\hat{\\sigma}^2)+D\\log{N}\n\\end{equation}\n\nThe BIC method is very closely related to the \\textbf{minimum description length} or \\textbf{MDL} principle, which characterizes the score for a model in terms of how well it fits the data, minus how complex the model is to define. See (Hansen and Yu 2001) for details.\n\nThere is a very similar expression to BIC/ MDL called the \\textbf{Akaike information criterion} or \\textbf{AIC}, defined as\n\\begin{equation}\n\\mathrm{AIC}(m,\\mathcal{D}) = \\log{p(\\mathcal{D}|\\hat{\\vec{\\theta}}_{MLE})}-\\mathrm{dof}(m)\n\\end{equation}\n\nThis is derived from a frequentist framework, and cannot be interpreted as an approximation to the marginal likelihood. Nevertheless, the form of this expression is very similar to BIC. We see that the penalty for AIC is less than for BIC. This causes AIC to pick more complex models. However, this can result in better predictive accuracy. See e.g., (Clarke et al. 2009, sec 10.2) for further discussion on such information criteria.\n\n\\subsubsection{Effect of the prior}\nSometimes it is not clear how to set the prior. When we are performing posterior inference, the details of the prior may not matter too much, since the likelihood often overwhelms the prior anyway. But when computing the marginal likelihood, the prior plays a much more important role, since we are averaging the likelihood over all possible parameter settings, as weighted by the prior.\n\nIf the prior is unknown, the correct Bayesian procedure is to put a prior on the prior. If the prior is unknown, the correct Bayesian procedure is to put a prior on the prior. \n\n\n\\subsection{Bayes factors}\nSuppose our prior on models is uniform, $p(m) \\propto 1$. Then model selection is equivalent to picking the model with the highest marginal likelihood. Now suppose we just have two models we are considering, call them the \\textbf{null hypothesis}, $M_0$, and the \\textbf{alternative hypothesis}, $M_1$. Define the \\textbf{Bayes factor} as the ratio of marginal likelihoods:\n\\begin{equation}\n\\mathrm{BF}_{1,0} \\triangleq \\dfrac{p(\\mathcal{D}|M_1)}{p(\\mathcal{D}|M_0)}=\\dfrac{p(M_1|\\mathcal{D})}{p(M_2|\\mathcal{D})}/\\dfrac{p(M_1)}{p(M_0)}\n\\end{equation}\n\n\n\\section{Priors}\nThe most controversial aspect of Bayesian statistics is its reliance on priors. Bayesians argue this is unavoidable, since nobody is a \\textbf{tabula rasa} or \\textbf{blank slate}: all inference must be done conditional on certain assumptions about the world. Nevertheless, one might be interested in minimizing the impact of one’s prior assumptions. We briefly discuss some ways to do this below.\n\n\n\\subsection{Uninformative priors}\nIf we don’t have strong beliefs about what $\\theta$ should be, it is common to use an \\textbf{uninformative} or \\textbf{non-informative} prior, and to “let the data speak for itself”.\n\n\n\\subsection{Robust priors}\nIn many cases, we are not very confident in our prior, so we want to make sure it does not have an undue influence on the result. This can be done by using \\textbf{robust priors}(Insua and Ruggeri 2000), which typically have heavy tails, which avoids forcing things to be too close to the prior mean.\n\n\n\\subsection{Mixtures of conjugate priors}\nRobust priors are useful, but can be computationally expensive to use. Conjugate priors simplify the computation, but are often not robust, and not flexible enough to encode our prior knowledge. However, it turns out that a \\textbf{mixture of conjugate priors} is also conjugate, and can approximate any kind of prior (Dallal and Hall 1983; Diaconis and Ylvisaker 1985). Thus such priors provide a good compromise between computational convenience and flexibility.\n\n\n\\section{Hierarchical Bayes}\nA key requirement for computing the posterior $p(\\vec{\\theta}|\\mathcal{D})$ is the specification of a prior $p(\\vec{\\theta}|\\vec{\\eta})$, where $\\vec{\\eta}$ are the hyper-parameters. What if we don’t know how to set $\\vec{\\eta}$? In some cases, we can use uninformative priors, we we discussed above. A more Bayesian approach is to put a prior on our priors! In terms of graphical models (Chapter TODO), we can represent the situation as follows:\n\\begin{equation}\n\\vec{\\eta} \\rightarrow \\vec{\\theta} \\rightarrow \\mathcal{D}\n\\end{equation}\n\nThis is an example of a \\textbf{hierarchical Bayesian model}, also called a \\textbf{multi-level} model, since there are multiple levels of unknown quantities. \n\n\n\\section{Empirical Bayes}\n\\label{sec:Empirical-Bayes}\n\n\\begin{table}\n\\centering\n\\begin{tabular}{ll}\n\\hline\\noalign{\\smallskip}\n\\textbf{Method} & \\textbf{Definition} \\\\\n\\noalign{\\smallskip}\\svhline\\noalign{\\smallskip}\nMaximum likelihood & $\\hat{\\vec{\\theta}}=\\arg\\max_{\\vec{\\theta}} p(\\mathcal{D}|\\vec{\\theta})$ \\\\\nMAP estimation & $\\hat{\\vec{\\theta}}=\\arg\\max_{\\vec{\\theta}} p(\\mathcal{D}|\\vec{\\theta})p(\\vec{\\theta}|\\vec{\\eta})$ \\\\\n\\multirow{2}{*}{ML-II (\\textbf{Empirical Bayes})} & $\\hat{\\vec{\\eta}}=\\arg\\max_{\\vec{\\eta}} \\int p(\\mathcal{D}|\\vec{\\theta})p(\\vec{\\theta}|\\vec{\\eta})\\mathrm{d}\\vec{\\theta}$ \\\\\n                                                  & $\\quad =\\arg\\max_{\\vec{\\eta}}p(\\mathcal{D}|\\vec{\\eta})$ \\\\\n\\multirow{2}{*}{MAP-II} & $\\hat{\\vec{\\eta}}=\\arg\\max_{\\vec{\\eta}} \\int p(\\mathcal{D}|\\vec{\\theta})p(\\vec{\\theta}|\\vec{\\eta})p(\\vec{\\eta})\\mathrm{d}\\vec{\\theta}$ \\\\\n                        & $\\quad =\\arg\\max_{\\vec{\\eta}}p(\\mathcal{D}|\\vec{\\eta})p(\\vec{\\eta})$ \\\\\nFull Bayes & $p(\\vec{\\theta},\\vec{\\eta}|\\mathcal{D}) \\propto p(\\mathcal{D}|\\vec{\\theta})p(\\vec{\\theta}|\\vec{\\eta})$ \\\\\n\\noalign{\\smallskip}\\hline\n\\end{tabular}\n\\end{table}\n\n\n\\section{Bayesian decision theory}\n\\label{sec:Bayesian-decision-theory}\nWe have seen how probability theory can be used to represent and updates our beliefs about the state of the world. However, ultimately our goal is to convert our beliefs into actions. In this section, we discuss the optimal way to do this.\n\nOur goal is to devise a \\textbf{decision procedure} or \\textbf{policy}, $f(\\vec{x}) : \\mathcal{X} \\rightarrow \\mathcal{Y}$, which minimizes the \\textbf{expected loss} $R_{\\mathrm{exp}}(f)$(see Equation \\ref{eqn:expected-loss}).\n\nIn the Bayesian approach to decision theory, the optimal output, having observed $\\vec{x}$, is defined as the output $a$ that minimizes the \\textbf{posterior expected loss}:\n\\begin{equation}\n\\rho(f)=\\mathbb{E}_{p(y|\\vec{x})}[L(y,f(\\vec{x}))]=\\begin{cases}\n\\sum\\limits_y L[y,f(\\vec{x})]p(y|\\vec{x}) \\\\\n\\int\\limits_y L[y,f(\\vec{x})]p(y|\\vec{x})\\mathrm{d}y\n\\end{cases}\n\\end{equation}\n\nHence the \\textbf{Bayes estimator}, also called the \\textbf{Bayes decision rule}, is given by\n\\begin{equation}\n\\delta(\\vec{x})=\\arg\\min\\limits_{f \\in \\mathcal{H}} \\rho(f)\n\\end{equation}\n\n\n\\subsection{Bayes estimators for common loss functions}\n\n\n\\subsubsection{MAP estimate minimizes 0-1 loss}\nWhen $L(y,f(x))$ is \\textbf{0-1 loss}(Section \\ref{sec:Loss-function-and-risk-function}), we can proof that MAP estimate minimizes 0-1 loss, \n\\begin{align*}\n\\arg\\min\\limits_{f \\in \\mathcal{H}} \\rho(f)& =\\arg\\min\\limits_{f \\in \\mathcal{H}} \\sum\\limits_{i=1}^K{L[C_k,f(\\vec{x})]p(C_k|\\vec{x})} \\\\\n         & =\\arg\\min\\limits_{f \\in \\mathcal{H}} \\sum\\limits_{i=1}^K{\\mathbb{I}(f(\\vec{x}) \\neq C_k)p(C_k|\\vec{x})} \\\\\n\t\t & =\\arg\\min\\limits_{f \\in \\mathcal{H}} \\sum\\limits_{i=1}^K{p(f(\\vec{x}) \\neq C_k|\\vec{x})} \\\\\n\t\t & =\\arg\\min\\limits_{f \\in \\mathcal{H}} \\left[1-{p(f(\\vec{x}) = C_k|\\vec{x})}\\right] \\\\\n\t\t & =\\arg\\max\\limits_{f \\in \\mathcal{H}} p(f(\\vec{x}) = C_k|\\vec{x})\n\\end{align*}\n\n\n\\subsubsection{Posterior mean minimizes\t$\\ell_2$(quadratic) loss}\nFor continuous parameters, a more appropriate loss function is \\textbf{squared error}, \\textbf{$\\ell_2$ loss}, or \\textbf{quadratic loss}, defined as $L(y,f(\\vec{x}))=\\left[y-f(\\vec{x})\\right]^2$.\n\nThe posterior expected loss is given by\n\\begin{equation}\\begin{split}\n\\rho(f) & =\\int\\limits_y L[y,f(\\vec{x})]p(y|\\vec{x})\\mathrm{d}y \\\\\n        & =\\int\\limits_y \\left[y-f(\\vec{x})\\right]^2p(y|\\vec{x})\\mathrm{d}y \\\\\n        & =\\int\\limits_y \\left[y^2-2yf(\\vec{x})+f(\\vec{x})^2\\right]p(y|\\vec{x})\\mathrm{d}y\n\\end{split}\\end{equation}\n\nHence the optimal estimate is the posterior mean:\n\\begin{align}\n& \\dfrac{\\partial \\rho}{\\partial f} =\\int\\limits_y [-2y+2f(\\vec{x})]p(y|\\vec{x})\\mathrm{d}y=0 \\Rightarrow \\nonumber \\\\\n& \\int\\limits_y f(\\vec{x})p(y|\\vec{x})\\mathrm{d}y = \\int\\limits_y yp(y|\\vec{x})\\mathrm{d}y \\nonumber \\\\\n& f(\\vec{x}) \\int\\limits_y p(y|\\vec{x})\\mathrm{d}y = \\mathbb{E}_{p(y|\\vec{x})}[y] \\nonumber \\\\\n& f(\\vec{x}) = \\mathbb{E}_{p(y|\\vec{x})}[y]\n\\end{align}\n\nThis is often called the \\textbf{minimum mean squared error} estimate or \\textbf{MMSE} estimate.\n\n\n\\subsubsection{Posterior median minimizes $\\ell_1$(absolute) loss}\nThe $\\ell_2$ loss penalizes deviations from the truth quadratically, and thus is sensitive to outliers. A more robust alternative is the absolute or $\\ell_1$ loss. The optimal estimate is the posterior median, i.e., a value $a$ such that $P(y<a|\\vec{x})=P(y \\geq a|\\vec{x})=0.5$.\n\n\\begin{proof}\n\\begin{align*}\n\\rho(f)& =\\int\\limits_y L[y,f(\\vec{x})]p(y|\\vec{x})\\mathrm{d}y=\\int\\limits_y |y-f(\\vec{x})|p(y|\\vec{x})\\mathrm{d}y \\\\\n       & =\\int\\limits_y [f(\\vec{x})-y]p(y<f(\\vec{x})|\\vec{x})+ \\\\\n\t   & \\quad [y-f(\\vec{x})]p(y \\geq f(\\vec{x})|\\vec{x})\\mathrm{d}y \\\\\n& \\dfrac{\\partial \\rho}{\\partial f}=\\int\\limits_y \\left[p(y<f(\\vec{x})|\\vec{x})-p(y \\geq f(\\vec{x})|\\vec{x})\\right]\\mathrm{d}y=0 \\Rightarrow \\\\\n& p(y<f(\\vec{x})|\\vec{x})=p(y \\geq f(\\vec{x})|\\vec{x})=0.5 \\\\\n& \\therefore f(\\vec{x})=\\text{median}\n\\end{align*}\n\\end{proof}\n\n\n\\subsubsection{Reject option}\nIn classification problems where $p(y|\\vec{x})$ is very uncertain, we may prefer to choose a reject action, in which we refuse to classify the example as any of the specified classes, and instead say “don’t know”. Such ambiguous cases can be handled by e.g., a human expert. This is useful in \\textbf{risk averse} domains such as medicine and finance.\n\nWe can formalize the reject option as follows. Let choosing $f(\\vec{x})=c_{K+1}$ correspond to picking the reject action, and choosing $f(\\vec{x}) \\in \\{C_1,...,C_k\\}$ correspond to picking one of the classes. Suppose we define the loss function as\n\\begin{equation}\nL(f(\\vec{x}), y)=\\begin{cases} \n0 & \\text{if } f(\\vec{x})=y \\text{ and } f(\\vec{x}),y \\in \\{C_1,...,C_k\\} \\\\\n\\lambda_s & \\text{if } f(\\vec{x}) \\neq y \\text{ and } f(\\vec{x}),y \\in \\{C_1,...,C_k\\} \\\\\n\\lambda_r & \\text{if } f(\\vec{x})=C_{K+1}\n\\end{cases}\n\\end{equation}\nwhere $\\lambda_s$ is the cost of a substitution error, and $\\lambda_r$ is the cost of the reject action. \n\n\n\\subsubsection{Supervised learning}\nWe can define the loss incurred by $f(\\vec{x})$ (i.e., using this predictor) when the unknown state of nature is $\\vec{\\theta}$(the parameters of the data generating mechanism) as follows:\n\\begin{equation}\nL(\\vec{\\theta},f) \\triangleq \\mathbb{E}_{p(\\vec{x},y|\\vec{\\theta})}[\\ell(y-f(\\vec{x}))]\n\\end{equation}\n\nThis is known as the \\textbf{generalization error}. Our goal is to minimize the posterior expected loss, given by\n\\begin{equation}\n\\rho(f|\\mathcal{D}) = \\int{p(\\vec{\\theta}|\\mathcal{D})L(\\vec{\\theta},f)}\\mathrm{d}\\vec{\\theta}\n\\end{equation}\n\nThis should be contrasted with the frequentist risk which is defined in Equation TODO.\n\n\n\\subsection{The false positive vs false negative tradeoff}\nIn this section, we focus on binary decision problems, such as hypothesis testing, two-class classification, object/ event detection, etc. There are two types of error we can make: a \\textbf{false positive}(aka \\textbf{false alarm}), or a \\textbf{false negative}(aka \\textbf{missed detection}). The 0-1 loss treats these two kinds of errors equivalently. However, we can consider the following more general loss matrix:\n\nTODO\n"
  },
  {
    "path": "chapterClustering.tex",
    "content": "\\chapter{Clustering}\n\n\\url{https://www.analytixlabs.co.in/blog/types-of-clustering-algorithms/}\n"
  },
  {
    "path": "chapterDGM.tex",
    "content": "\\chapter{Directed graphical models (Bayes nets)}\n\\label{chap:DGM}\n\n\\section{Introduction}\n\n\n\\subsection{Chain rule}\n\\begin{equation}\np(x_{1:V}) = p(x_1)p(x_2|x_1)p(x_3|x_{1:2})\\cdots p(x_N|x_{1:V-1})\n\\end{equation}\n\n\\subsection{Conditional independence}\n$X$ and $Y$ are \\textbf{conditionally independent} given $Z$, denoted $X \\perp Y|Z$, iff the conditional joint can be written as a product of conditional marginals, i.e.\n\\begin{equation}\nX \\perp Y|Z \\Longleftrightarrow p(X,Y|Z)=p(X|Z)p(Y|Z)\n\\end{equation}\n\nfirst order \\textbf{Markov assumption}: the future is independent of the past given the present, \n\\begin{equation}\nx_{t+1} \\perp x_{1:t-1}|x_t\n\\end{equation}\n\nfirst-order \\textbf{Markov chain}\n\\begin{equation}\np(x_{1:V}) = p(x_1)\\prod\\limits_{t=2}^V p(x_t|x_{t-1})\n\\end{equation}\n\n\n\\subsection{Graphical models}\nA \\textbf{graphical model}(GM) is a way to represent a joint distribution by making CI assumptions. In particular, the nodes in the graph represent random variables, and the (lack of) edges represent CI assumptions.\n\nThere are several kinds of graphical model, depending on whether the graph is directed, undirected, or some combination of directed and undirected. In this chapter, we just study directed graphs. We consider undirected graphs in Chapter 19.\n\n\n\\subsection{Directed graphical model}\nA \\textbf{directed graphical model}or \\textbf{DGM} is a GM whose graph is a DAG. These are more commonly known as \\textbf{Bayesian networks}. However, there is nothing inherently “Bayesian” about Bayesian networks: they are just a way of defining probability distributions. These models are also called \\textbf{belief networks}. The term “belief” here refers to subjective probability. Once again, there is nothing inherently subjective about the kinds of probability distributions represented by DGMs.\n\n\\textbf{Ordered Markov property}\n\\begin{equation}\nx_s \\perp x_{\\mathrm{pred}(s)\\ \\mathrm{pa}(s)} \\perp x_{\\mathrm{pa}(s)}\n\\end{equation}\nwhere pa$(s)$ are the parents of nodes, and pred$(s)$ are the predecessors of nodes in the DAG.\n\n\\textbf{\\textbf{Markov chain}} on a DGM\n\\begin{equation}\np(x_{1:V}|G)=\\prod\\limits_{t=1}^V p(x_t|x_{\\mathrm{pa}(t)})\n\\end{equation}\n\n\n\\begin{figure}[hbtp]\n\\centering\n    \\includegraphics[scale=.50]{graphical-models.png}\n\\caption{(a) A simple DAG on 5 nodes, numbered in topological order. Node 1 is the root, nodes 4 and 5 are the leaves. (b) A simple undirected graph, with the following maximal cliques: {1,2,3}, {2,3,4}, {3,5}.}\n\\label{fig:graphical-models} \n\\end{figure}\n\n\n\\section{Examples}\n\n\n\\subsection{Naive Bayes classifiers}\n\\begin{figure}[hbtp]\n\\centering\n    \\includegraphics[scale=.60]{naive-bayes-as-DGM.png}\n\\caption{(a) A naive Bayes classifier represented as a DGM. We assume there are $D=4$ features, for simplicity. Shaded nodes are observed, unshaded nodes are hidden. (b) Tree-augmented naive Bayes classifier for $D=4$ features. In general, the tree topology can change depending on the value of $y$.}\n\\label{fig:naive-bayes-as-DGM} \n\\end{figure}\n\n\n\\subsection{Markov and hidden Markov models}\n\\begin{figure}[hbtp]\n\\centering\n    \\includegraphics[scale=.50]{second-order-Markov-chain.png}\n\\caption{A first and second order Markov chain.}\n\\label{fig:second-order-Markov-chain} \n\\end{figure}\n\n\\begin{figure}[hbtp]\n\\centering\n    \\includegraphics[scale=.60]{first-order-HMM.png}\n\\caption{A first-order HMM.}\n\\label{fig:first-order-HMM} \n\\end{figure}\n\n\n\n\\section{Inference}\nSuppose we have a set of correlated random variables with joint distribution $p(\\vec{x}_{1:V}|\\vec{\\theta})$. Let us partition this vector into the \\textbf{visible variables} $\\vec{x}_v$, which are observed, and the \\textbf{hidden variables}, $\\vec{x}_h$, which are unobserved. Inference refers to computing the posterior distribution of the unknowns given the knowns:\n\\begin{equation}\np(\\vec{x}_h|\\vec{x}_v,\\theta) = \\frac{p(\\vec{x}_h, \\vec{x}_v|\\vec{\\theta})}{p(\\vec{x}_v|\\vec{\\theta})}=\\frac{p(\\vec{x}_h, \\vec{x}_v|\\vec{\\theta})}{\\sum_{\\vec{x}_h'}p(\\vec{x}_h', \\vec{x}_v|\\vec{\\theta})}\n\\end{equation}\n\nSometimes only some of the hidden variables are of interest to us. So let us partition the hidden variables into \\textbf{query variables}, $\\vec{x}_q$, whose value we wish to know, and the remaining \\textbf{nuisance variables}, $\\vec{x}_n$, which we are not interested in. We can compute what we are interested in by \\textbf{marginalizing out} the nuisance variables:\n\\begin{equation}\np(\\vec{x}_q|\\vec{x}_v,\\vec{\\theta}) = \\sum_{\\vec{x}_n}p(\\vec{x}_q, \\vec{x}_n|\\vec{x}_v, \\vec{\\theta})\n\\end{equation}\n\n\n\\section{Learning}\nMAP estimate:\n\\begin{equation}\n\\hat{\\vec{\\theta}} =\\arg\\max_{\\vec{\\theta}}\\sum\\limits_{i=1}^N \\log p(\\vec{x}_{i,v}|\\vec{\\theta})+\\log p(\\vec{\\theta})\n\\end{equation}\n\n\n\\subsection{Learning from complete data}\nIf all the variables are fully observed in each case, so there is no missing data and there are no hidden variables, we say the data is \\textbf{complete}. For a DGM with complete data, the likelihood is given by\n\\begin{equation}\\begin{split}\np(\\mathcal{D}|\\vec{\\theta}) & = \\prod_{i=1}^N p(\\vec{x}_i|\\vec{\\theta}) \\\\\n& = \\prod_{i=1}^N\\prod_{t=1}^V p(\\vec{x}_{it}|\\vec{x}_{i, \\mathrm{pa}(t)}, \\vec{\\theta}_t) \\\\\n& = \\prod_{t=1}^V p(\\mathcal{D}_t|\\vec{\\theta}_t)\n\\end{split}\\end{equation}\nwhere $\\mathcal{D}_t$ is the data associated with node $t$ and its parents, i.e., the $t$'th family.\n\nNow suppose that the prior factorizes as well:\n\\begin{equation}\np(\\vec{\\theta})=\\prod\\limits_{t=1}^V p(\\vec{\\theta}_t)\n\\end{equation}\n\nThen clearly the posterior also factorizes:\n\\begin{equation}\np(\\vec{\\theta}|\\mathcal{D}) \\propto p(\\mathcal{D}|\\vec{\\theta})p(\\vec{\\theta}) = \\prod\\limits_{t=1}^V p(\\mathcal{D}_t|\\vec{\\theta}_t)p(\\vec{\\theta}_t)\n\\end{equation}\n\n\n\\subsection{Learning with missing and/or latent variables}\nIf we have missing data and/or hidden variables, the likelihood no longer factorizes, and indeed it is no longer convex, as we explain in detail in Section TODO. This means we will usually can only compute a locally optimal ML or MAP estimate. Bayesian inference of the parameters is even harder. We discuss suitable approximate inference techniques in later chapters.\n\n\n\\section{Conditional independence properties of DGMs}\n\n\n\\subsection{d-separation and the Bayes Ball algorithm (global Markov properties)}\n\\begin{enumerate}\n\\item P contains a chain\n\\begin{equation}\\begin{split}\np(x,z|y) & = \\frac{p(x,y,z)}{p(y)}\n= \\frac{p(x)p(y|x)p(z|y)}{p(y)} \\\\\n & = \\frac{p(x,y)p(z|y)}{p(y)} = p(x|y)p(z|y)\n\\end{split}\\end{equation}\n\n\\item P contains a fork\n\\begin{equation}\np(x,z|y) = \\frac{p(x,y,z)}{p(y)}\n= \\frac{p(y)p(x|y)p(z|y)}{p(y)}\n= p(x|y)p(z|y)\n\\end{equation}\n\\item P contains v-structure\n\\begin{equation}\np(x,z|y) = \\frac{p(x,y,z)}{p(y)}\n= \\frac{p(x)p(z)p(y|x,z)}{p(y)}\n\\neq p(x|y)p(z|y)\n\\end{equation}\n\\end{enumerate}\n\n\n\n\\subsection{Other Markov properties of DGMs}\n\n\n\\subsection{Markov blanket and full conditionals}\n\n\\begin{equation}\nmb(t) = ch(t)\\cup pa(t)\\cup copa(t)\n\\end{equation}\n\n\n\\subsection{Multinoulli Learning}\nMultinoulli Distribution：\n\\begin{equation}\\label{eqn:discrite}\nCat(x|\\mu) = \\prod_{k=1}^K\\mu_k^{x_k}\n\\end{equation}\nthen from \\ref{bayes_net} and \\ref{eqn:discrite}:\n\\begin{equation}\np(x|G,\\theta) = \\prod_{v=1}^V\\prod_{c=1}^{C_v}\\prod_{k=1}^K\n\\theta_{vck}^{y_{vck}}\n\\end{equation}\nLikelihood\n\\begin{equation}\np(D|G,\\theta) = \\prod_{n=1}^N p(x_n|G,\\theta)\n=\\prod_{n=1}^N\\prod_{v=1}^V\\prod_{c=1}^{C_{nv}}\\prod_{k=1}^K\n\\theta_{vck}^{y_{nvck}}\n\\end{equation}\nwhere $y_{nv} = f(pa(x_{nv}))$, f(x) is a map from x to a vector, there is only one element in the vector is 1.\n\n\n\\section{Influence (decision) diagrams *}\n\n"
  },
  {
    "path": "chapterDeepLearning.tex",
    "content": "\\chapter{Deep learning}\n\n"
  },
  {
    "path": "chapterEM.tex",
    "content": "\\chapter{Mixture models and the EM algorithm}\n\\label{chap:EM-algorithm}\n\n\n\\section{Latent variable models}\nIn Chapter \\ref{chap:DGM} we showed how graphical models can be used to define high-dimensional joint probability distributions. The basic idea is to model dependence between two variables by adding an edge between them in the graph. (Technically the graph represents conditional\nindependence, but you get the point.)\n\nAn alternative approach is to assume that the observed variables are correlated because they arise from a hidden common “cause”. Model with hidden variables are also known as \\textbf{latent variable models} or \\textbf{LVM}s. As we will see in this chapter, such models are harder to fit than models with no latent variables. However, they can have significant advantages, for two main reasons.\n\\begin{itemize}\n\\item{First, LVMs often have fewer parameters than models that directly represent correlation in the visible space.}\n\\item{Second, the hidden variables in an LVM can serve as a \\textbf{bottleneck}, which computes a compressed representation of the data. This forms the basis of unsupervised learning, as we will see. Figure \\ref{fig:latent-variable-model} illustrates some generic LVM structures that can be used for this purpose.}\n\\end{itemize}\n\n\\begin{figure}[hbtp]\n\\centering\n    \\includegraphics[scale=.60]{latent-variable-model.png}\n\\caption{A latent variable model represented as a DGM. (a) Many-to-many. (b) One-to-many. (c) Many-to-one. (d) One-to-one.}\n\\label{fig:latent-variable-model} \n\\end{figure}\n\n\n\\section{Mixture models}\nThe simplest form of LVM is when $z_i \\in \\{1,\\cdots,K\\}$, representing a discrete latent state. We will use a discrete prior for this, $p(zi)=\\mathrm{Cat}(\\pi)$. For the likelihood, we use $p(\\vec{x}_i|z_i =k)=p_k(\\vec{x}_i)$, where $p_k$ is the $k$'th \\textbf{base distribution} for the observations; this can be of any type. The overall model is known as a \\textbf{mixture model}, since we are mixing together the $K$ base distributions as follows:\n\\begin{equation}\np(\\vec{x}_i|\\vec{\\theta})=\\sum\\limits_{k=1}^K \\pi_kp_k(\\vec{x}_i|\\vec{\\theta})\n\\end{equation}\n\nDepending on the form of the likelihood $p(\\vec{x}_i|\\vec{z}_i)$ and the prior $p(\\vec{z}_i)$, we can generate a variety of different models, as summarized in Table \\ref{tab:popular-directed-latent-variable-models}.\n\n\\begin{table}\n\\centering\n\\begin{tabular}{llll}\n\\hline\\noalign{\\smallskip}\n$p(\\vec{x}_i|\\vec{z}_i)$ & $p(\\vec{z}_i)$ & \\textbf{Name} & \\textbf{Section} \\\\\n\\noalign{\\smallskip}\\svhline\\noalign{\\smallskip}\nMVN & Discrete & Mixture of Gaussians & 11.2.1 \\\\\nProd. Discrete & Discrete & Mixture of multinomials & 11.2.2 \\\\\n\\multirow{2}{*}{Prod. Gaussian} & \\multirow{2}{*}{Prod. Gaussian} & Factor analysis/ & \\multirow{2}{*}{12.1.5} \\\\\n                                &                                 & probabilistic PCA&  \\\\\n\\multirow{2}{*}{Prod. Gaussian} & \\multirow{2}{*}{Prod. Laplace} & Probabilistic ICA/& \\multirow{2}{*}{12.6} \\\\\n                                &                                & sparse coding     &  \\\\\nProd. Discrete & Prod. Gaussian & Multinomial PCA & 27.2.3 \\\\\n\\multirow{2}{*}{Prod. Discrete} & \\multirow{2}{*}{Dirichlet} & Latent Dirichlet & \\multirow{2}{*}{27.3}\\\\\n                                &                            & allocation       &  \\\\\nProd. Noisy-OR & Prod. Bernoulli & BN20/ QMR & 10.2.3 \\\\\nProd. Bernoulli & Prod. Bernoulli & Sigmoid belief net & 27.7 \\\\\n\\noalign{\\smallskip}\\hline\n\\end{tabular}\n\\caption{Summary of some popular directed latent variable models. Here “Prod” means product, so “Prod. Discrete” in the likelihood means a factored distribution of the form $\\prod_j \\mathrm{Cat}(x_{ij}|\\vec{z}_i)$, and “Prod. Gaussian” means a factored distribution of the form $\\prod_j \\mathcal{N}(x_{ij}|\\vec{z}_i)$.}\n\\label{tab:popular-directed-latent-variable-models}\n\\end{table}\n\n\n\\subsection{Mixtures of Gaussians}\n\\begin{equation}\np_k(\\vec{x}_i|\\vec{\\theta})=\\mathcal{N}(\\vec{x}_i|\\vec{\\mu}_k,\\Sigma_k)\n\\end{equation}\n\n\n\\subsection{Mixtures of multinoullis}\n\\begin{equation}\np_k(\\vec{x}_i|\\vec{\\theta})=\\prod\\limits_{j=1}^D \\mathrm{Ber}(x_{ij}|\\mu_{jk})=\\prod\\limits_{j=1}^D \\mu_{jk}^{x_{ij}}(1-\\mu_{jk})^{1-x_{ij}}\n\\end{equation}\nwhere $\\mu_{jk}$ is the probability that bit $j$ turns on in cluster $k$.\n\nThe latent variables do not have to any meaning, we might simply introduce latent variables in order to make the model more powerful. For example, one can show that the mean and covariance of the mixture distribution are given by\n\\begin{align}\n\\mathbb{E}[\\vec{x}] & = \\sum\\limits_{k=1}^K \\pi_k\\vec{\\mu}_k \\\\\n\\mathrm{Cov}[\\vec{x}] & = \\sum\\limits_{k=1}^K \\pi_k(\\Sigma_k+\\vec{\\mu}_k\\vec{\\mu}_k^T)-\\mathbb{E}[\\vec{x}]\\mathbb{E}[\\vec{x}]^T\n\\end{align}\nwhere $\\Sigma_k=\\mathrm{diag}(\\mu_{jk}(1-\\mu_{jk}))$. So although the component distributions are factorized, the joint distribution is not. Thus the mixture distribution can capture correlations between variables, unlike a single product-of-Bernoullis model.\n\n\n\n\n\\subsection{Using mixture models for clustering}\nThere are two main applications of mixture models, black-box density model(see Section 14.7.3 TODO) and clustering(see Chapter 25 TODO).\n\n\\textbf{Soft clustering}\n\\begin{equation}\\begin{split}\nr_{ik} & \\triangleq p(z_i=k|\\vec{x}_i,\\vec{\\theta})=\\dfrac{p(z_i=k,\\vec{x}_i|\\vec{\\theta})}{p(\\vec{x}_i|\\vec{\\theta})} \\\\\n       & =\\dfrac{p(z_i=k|\\vec{\\theta})p(\\vec{x}_i|z_i=k,\\vec{\\theta})}{\\sum_{k'=1}^K p(z_i=k'|\\vec{\\theta})p(\\vec{x}_i|z_i=k',\\vec{\\theta})}\n\\end{split}\\end{equation}\nwhere $r_{ik}$ is known as the \\textbf{responsibility} of cluster $k$ for point $i$.\n\n\\textbf{Hard clustering}\n\\begin{equation}\nz_i^* \\triangleq \\arg\\max_k r_{ik}=\\arg\\max_k p(z_i=k|\\vec{x}_i,\\vec{\\theta})\n\\end{equation}\n\nThe difference between generative classifiers and mixture models only arises at training time: in the mixture case, we never observe $z_i$, whereas with a generative classifier, we do observe $y_i$(which plays the role of $z_i$).\n\n\n\\subsection{Mixtures of experts}\nSection 14.7.3 TODO described how to use mixture models in the context of generative classifiers. We can also use them to create discriminative models for classification and regression. For example, consider the data in Figure \\ref{fig:mixture-of-experts}(a). It seems like a good model would be three different linear regression functions, each applying to a different part of the input space. We can model this by allowing the mixing weights and the mixture densities to be input-dependent:\n\\begin{align}\np(y_i|\\vec{x}_i,z_i=k,\\vec{\\theta}) & =\\mathcal{N}(y_i|\\vec{w}_k^T\\vec{x},\\sigma_k^2) \\\\\np(z_i | \\vec{x}_i,\\vec{\\theta}) & = \\mathrm{Cat}(z_i|\\mathcal{S}(\\vec{V}^T\\vec{x}_i))\n\\end{align}\n\nSee Figure \\ref{fig:mixture-of-experts2}(a) for the DGM.\n\n\\begin{figure}[hbtp]\n\\centering\n\\subfloat[]{\\includegraphics[scale=.60]{mixture-of-experts-a.png}} \\\\\n\\subfloat[]{\\includegraphics[scale=.60]{mixture-of-experts-b.png}} \\\\\n\\subfloat[]{\\includegraphics[scale=.60]{mixture-of-experts-c.png}}\n\\caption{(a) Some data fit with three separate regression lines. (b) Gating functions for three different “experts”. (c) The conditionally weighted average of the three expert predictions.}\n\\label{fig:mixture-of-experts} \n\\end{figure}\n\n\\begin{figure}[hbtp]\n\\centering\n    \\includegraphics[scale=.50]{mixture-of-experts2.png}\n\\caption{(a) A mixture of experts. (b) A hierarchical mixture of experts.}\n\\label{fig:mixture-of-experts2} \n\\end{figure}\n\nThis model is called a \\textbf{mixture of experts} or MoE (Jordan and Jacobs 1994). The idea is that each submodel is considered to be an “expert” in a certain region of input space. The function $p(z_i | \\vec{x}_i,\\vec{\\theta})$ is called a \\textbf{gating function}, and decides which expert to use, depending on the input values. For example, Figure \\ref{fig:mixture-of-experts}(b) shows how the three experts have “carved up” the 1d input space, Figure \\ref{fig:mixture-of-experts}(a) shows the predictions of each expert individually (in this case, the experts are just linear regression models), and Figure \\ref{fig:mixture-of-experts}(c) shows the overall prediction of the model, obtained using\n\\begin{equation}\np(y_i|\\vec{x}_i,\\vec{\\theta})=\\sum\\limits_{k=1}^K p(z_i=k | \\vec{x}_i,\\vec{\\theta})p(y_i|\\vec{x}_i,z_i=k,\\vec{\\theta})\n\\end{equation}\n\nWe discuss how to fit this model in Section TODO 11.4.3.\n\n\n\\section{Parameter estimation for mixture models}\n\n\n\\subsection{Unidentifiability}\n\n\n\\subsection{Computing a MAP estimate is non-convex}\n\n\n\\section{The EM algorithm}\n\n\n\\subsection{Introduction}\nFor many models in machine learning and statistics, computing the ML or MAP parameter estimate is easy provided we observe all the values of all the relevant random variables, i.e., if we have complete data. However, if we have missing data and/or latent variables, then computing the ML/MAP estimate becomes hard.\n\nOne approach is to use a generic gradient-based optimizer to find a local minimum of the NLL$(\\vec{\\theta})$. However, we often have to enforce constraints, such as the fact that covariance matrices must be positive definite, mixing weights must sum to one, etc., which can be tricky. In such cases, it is often much simpler (but not always faster) to use an algorithm called \\textbf{expectation maximization},or \\textbf{EM} for short (Dempster et al. 1977; Meng and van Dyk 1997; McLachlan and Krishnan 1997). This is is an efficient iterative algorithm to compute the ML or MAP estimate in the presence of missing or hidden data, often with closed-form updates at each step. Furthermore, the algorithm automatically enforce the required constraints.\n\nSee Table \\ref{tab:summary-of-the-applications-of-EM} for a summary of the applications of EM in this book.\n\n\\begin{table}\n\\caption{Some models discussed in this book for which EM can be easily applied to find the ML/ MAP parameter estimate.}\n\\label{tab:summary-of-the-applications-of-EM}\n\\centering\n\\begin{tabular}{ll}\n\\hline\\noalign{\\smallskip}\n\\textbf{Model} & \\textbf{Section} \\\\\n\\noalign{\\smallskip}\\svhline\\noalign{\\smallskip}\nMix. Gaussians & 11.4.2 \\\\\nMix. experts & 11.4.3 \\\\\nFactor analysis & 12.1.5 \\\\\nStudent T & 11.4.5 \\\\\nProbit regression & 11.4.6 \\\\\nDGM with hidden variables & 11.4.4 \\\\\nMVN with missing data & 11.6.1 \\\\\nHMMs & 17.5.2 \\\\\nShrinkage estimates of Gaussian means & Exercise 11.13 \\\\\n\\noalign{\\smallskip}\\hline\n\\end{tabular}\n\\end{table}\n\n\n\\subsection{Basic idea}\nEM exploits the fact that if the data were fully observed, then the ML/ MAP estimate would be easy to compute. In particular, each iteration of the EM algorithm consists of two processes: The E-step, and the M-step. \n\\begin{itemize}\n\\item{In the \\textbf{E-step}, the missing data are inferred given the observed data and current estimate of the model parameters. This is achieved using the conditional expectation, explaining the choice of terminology.}\n\\item{In the \\textbf{M-step}, the likelihood function is maximized under the assumption that the missing data are known. The missing data inferred from the E-step are used in lieu of the actual missing data.}\n\\end{itemize}\n\nLet $\\vec{x}_i$ be the visible or observed variables in case $i$, and let $\\vec{z}_i$ be the hidden or missing variables. The goal is to maximize the log likelihood of the observed data:\n\\begin{equation}\n\\ell(\\vec{\\theta})=\\log p(\\mathcal{D}|\\vec{\\theta})=\\sum\\limits_{i=1}^N \\log p(\\vec{x}_i|\\vec{\\theta})=\\sum\\limits_{i=1}^N \\log{\\sum\\limits_{\\vec{z}_i} p(\\vec{x}_i,\\vec{z}_i|\\vec{\\theta})}\n\\end{equation}\n\nUnfortunately this is hard to optimize, since the log cannot be pushed inside the sum.\n\nEM gets around this problem as follows. Define the \\textbf{complete data log likelihood} to be\n\\begin{equation}\n\\ell_c(\\vec{\\theta})=\\sum\\limits_{i=1}^N \\log p(\\vec{x}_i,\\vec{z}_i|\\vec{\\theta})\n\\end{equation}\n\nThis cannot be computed, since $\\vec{z}_i$ is unknown. So let us define the \\textbf{expected complete data log likelihood} as follows:\n\\begin{equation}\\label{eqn:auxiliary-function}\nQ(\\vec{\\theta},\\vec{\\theta}^{t-1}) \\triangleq \\mathbb{E}_{\\vec{z}|\\mathcal{D},\\theta^{t-1}}\\left[\\ell_c(\\vec{\\theta})\\right]=\\mathbb{E}\\left[\\ell_c(\\vec{\\theta})| \\mathcal{D},\\theta^{t-1}\\right]\n\\end{equation}\nwhere $t$ is the current iteration number. $Q$ is called the \\textbf{auxiliary function}(see Section \\ref{sec:Derivation-of-the-Q-function} for derivation). The expectation is taken wrt the old parameters, $\\vec{\\theta}^{t-1}$, and the observed data $\\mathcal{D}$. The goal of the E-step is to compute $Q(\\vec{\\theta},\\vec{\\theta}^{t-1})$, or rather, the parameters inside of it which the MLE(or MAP) depends on; these are known as the \\textbf{expected sufficient statistics} or \\textbf{ESS}. In the M-step, we optimize the $Q$ function wrt $\\vec{\\theta}$:\n\\begin{equation}\n\\vec{\\theta}^t=\\arg\\max_{\\vec{\\theta}} Q(\\vec{\\theta},\\vec{\\theta}^{t-1})\n\\end{equation}\n\nTo perform MAP estimation, we modify the M-step as follows:\n\\begin{equation}\n\\vec{\\theta}^t=\\arg\\max_{\\vec{\\theta}} Q(\\vec{\\theta},\\vec{\\theta}^{t-1})+\\log p(\\vec{\\theta})\n\\end{equation}\nThe E step remains unchanged.\n\nIn summary, the EM algorithm's pseudo code is as follows\n\n\\begin{algorithm}[htbp]\n    \\SetKwInOut{Input}{input}\\SetKwInOut{Output}{output}\n    \\Input{observed data $\\mathcal{D}=\\{\\vec{x}_1,\\vec{x}_2,\\cdots, \\vec{x}_N$\\},joint distribution $P(\\vec{x},\\vec{z}|\\vec{\\theta})$}\n\t\\Output{model's parameters $\\vec{\\theta}$}\n\n\t// 1. identify hidden variables $\\vec{z}$, write out the log likelihood function $\\ell(\\vec{x},\\vec{z}|\\vec{\\theta})$ \\\\\n\t$\\vec{\\theta}^{(0)}$ = ... // initialize \\\\\n\t\n\t\\While{(!convergency)} {\n\t    // 2. E-step: plug in $P(\\vec{x},\\vec{z}|\\vec{\\theta})$, derive the formula of $Q(\\vec{\\theta}, \\vec{\\theta}^{t-1})$ \\\\\n\t    $Q(\\vec{\\theta}, \\vec{\\theta}^{t-1})=\\mathbb{E}\\left[\\ell_c(\\vec{\\theta})| \\mathcal{D},\\theta^{t-1}\\right]$ \\\\\n\t    // 3. M-step: find \\vec{\\theta} that maximizes the value of $Q(\\vec{\\theta}, \\vec{\\theta}^{t-1})$ \\\\\n\t\t$\\vec{\\theta}^t=\\arg\\max\\limits_{\\vec{\\theta}} Q(\\vec{\\theta}, \\vec{\\theta}^{t-1})$ \\\\\n\t}\n\t\n\\caption{EM algorithm}\n\\end{algorithm}\n\nBelow we explain how to perform the E and M steps for several simple models, that should make things clearer.\n\n\n\\subsection{EM for GMMs}\n\n\\subsubsection{Auxiliary function}\n\\begin{align}\nQ(\\vec{\\theta}, \\vec{\\theta}^{t-1}) & =\\mathbb{E}_{z|\\mathcal{D},\\theta^{t-1}}\\left[\\ell_c(\\vec{\\theta})\\right] \\nonumber \\\\\n    & = \\mathbb{E}_{z|\\mathcal{D},\\theta^{t-1}}\\left[\\sum\\limits_{i=1}^N \\log p(\\vec{x}_i,z_i|\\vec{\\theta})\\right] \\nonumber \\\\\n\t& = \\sum\\limits_{i=1}^N \\mathbb{E}_{z|\\mathcal{D},\\theta^{t-1}}\\left\\{\\log\\left[\\prod\\limits_{k=1}^K \\left(\\pi_kp(\\vec{x}_i|\\vec{\\theta}_k)\\right)^{\\mathbb{I}(z_i=k)}\\right]\\right\\} \\nonumber \\\\\n\t& = \\sum\\limits_{i=1}^N{\\sum\\limits_{k=1}^K{\\mathbb{E}[\\mathbb{I}(z_i=k)]\\log\\left[\\pi_kp(\\vec{x}_i|\\vec{\\theta}_k)\\right]}} \\nonumber \\\\\n\t& = \\sum\\limits_{i=1}^N{\\sum\\limits_{k=1}^K{p(z_i=k|\\vec{x}_i,\\vec{\\theta}^{t-1})\\log\\left[\\pi_kp(\\vec{x}_i|\\vec{\\theta}_k)\\right]}} \\nonumber \\\\\n\t& = \\sum\\limits_{i=1}^N{\\sum\\limits_{k=1}^K{r_{ik}\\log \\pi_k}}+\\sum\\limits_{i=1}^N{\\sum\\limits_{k=1}^K{r_{ik}\\log p(\\vec{x}_i|\\vec{\\theta}_k)}} \\label{eqn:Q-miture-model}\n\\end{align}\nwhere $r_{ik} \\triangleq \\mathbb{E}[\\mathbb{I}(z_i=k)]=p(z_i=k|\\vec{x}_i,\\vec{\\theta}^{t-1})$ is the \\textbf{responsibility} that cluster $k$ takes for data point $i$. This is computed in the E-step, described below.\n\n\n\\subsubsection{E-step}\nThe E-step has the following simple form, which is the same for any mixture model:\n\\begin{equation}\\begin{split}\nr_{ik} & =p(z_i=k|\\vec{x}_i,\\vec{\\theta}^{t-1})=\\frac{p(z_i=k,\\vec{x}_i|\\vec{\\theta}^{t-1})}{p(\\vec{x}_i|\\vec{\\theta}^{t-1})} \\\\\n  & =\\frac{\\pi_kp(\\vec{x}_i|\\vec{\\theta}_k^{t-1})}{\\sum_{k'=1}^K \\pi_{k'}p(\\vec{x}_i|\\vec{\\theta}_k^{t-1})}\n\\end{split}\\end{equation}\n\n\\subsubsection{M-step}\nIn the M-step, we optimize $Q$ wrt $\\vec{\\pi}$ and $\\vec{\\theta}_k$.\n\nFor $\\vec{\\pi}$, grouping together only the terms that depend on $\\pi_k$, we find that we need to maximize $\\sum\\limits_{i=1}^N{\\sum\\limits_{k=1}^K{r_{ik}\\log \\pi_k}}$. However, there is an additional constraint $\\sum\\limits_{k=1}^K{\\pi_k}=1$, since they represent the probabilities $\\vec{\\pi}_k=P(z_i=k)$. To deal with the constraint we construct the Lagrangian\n\\begin{equation}\n\\mathcal{L}(\\vec{\\pi})=\\sum\\limits_{i=1}^N{\\sum\\limits_{k=1}^K{r_{ik}\\log \\pi_k}}+\\beta\\left(\\sum\\limits_{k=1}^K{\\pi_k}-1\\right) \\nonumber\n\\end{equation}\nwhere $\\beta$ is the Lagrange multiplier. Taking derivatives, we find\n\\begin{equation}\n\\hat{\\vec{\\pi}}_k=\\frac{\\sum\\limits_{i=1}^N \\hat{r}_{ik}}{N}\n\\end{equation}\nThis is the same for any mixture model, whereas $\\vec{\\theta}_k$ depends on the form of $p(\\vec{x}|\\vec{\\theta}_k)$.\n\nFor $\\vec{\\theta}_k$, plug in the pdf to Equation \\ref{eqn:Q-miture-model}\n\\begin{equation*}\\begin{split}\nQ(\\vec{\\theta}, \\vec{\\theta}^{t-1}) & =\\sum\\limits_{i=1}^N{\\sum\\limits_{k=1}^K{r_{ik}\\log \\pi_k}}-\\frac{1}{2}\\sum\\limits_{i=1}^N  \\sum\\limits_{k=1}^K  r_{ik}\\left[\\log |\\vec{\\Sigma}_k| + \\right. \\\\\n & \\quad \\left. (\\vec{x}_i-\\vec{\\mu}_k)^T\\vec{\\Sigma}_k^{-1}(\\vec{x}_i-\\vec{\\mu}_k)\\right]\n\\end{split}\\end{equation*}\n\nTake partial derivatives of $Q$ wrt $\\vec{\\mu}_k$, $\\vec{\\Sigma}_k$ and let them equal to 0, we can get\n\\begin{align}\n\\frac{\\partial Q}{\\partial \\vec{\\mu}_k} & = -\\frac{1}{2}\\sum\\limits_{i=1}^N{r_{ik}\\left[(\\vec{\\Sigma}_k^{-1}+\\vec{\\Sigma}_k^{-T})(\\vec{x}_i-\\vec{\\mu}_k)\\right]} \\nonumber \\\\\n    &  =-\\sum\\limits_{i=1}^N{r_{ik}\\left[\\vec{\\Sigma}_k^{-1}(\\vec{x}_i-\\vec{\\mu}_k)\\right]}=0 \\Rightarrow \\nonumber \\\\\n\\hat{\\vec{\\mu}}_k & = \\frac{\\sum_{i=1}^N \\hat{r}_{ik}\\vec{x}_i}{\\sum_{i=1}^N \\hat{r}_{ik}}\n\\end{align}\n\n\\begin{align}\n\\frac{\\partial Q}{\\partial \\vec{\\Sigma}_k} & = -\\frac{1}{2}\\sum\\limits_{i=1}^N{r_{ik}\\left[\\frac{1}{\\vec{\\Sigma}_k}-\\frac{1}{\\vec{\\Sigma}_k^2}(\\vec{x}_i-\\vec{\\mu}_k)(\\vec{x}_i-\\vec{\\mu}_k)^T\\right]}=0 \\Rightarrow \\nonumber \\\\\n\\hat{\\vec{\\Sigma}}_k & = \\frac{\\sum_{i=1}^N \\hat{r}_{ik}(\\vec{x}_i-\\vec{\\mu}_k)(\\vec{x}_i-\\vec{\\mu}_k)^T}{\\sum_{i=1}^N \\hat{r}_{ik}} \\\\\n & =\\frac{\\sum_{i=1}^N \\hat{r}_{ik}\\vec{x}_i\\vec{x}_i^T}{\\sum_{i=1}^N \\hat{r}_{ik}}-\\vec{\\mu}_k\\vec{\\mu}_k^T\n\\end{align}\n\n\n\\subsubsection{Algorithm pseudo code}\n\n\\begin{algorithm}[htbp]\n    \\SetAlgoNoLine\n    \\SetKwInOut{Input}{input}\\SetKwInOut{Output}{output}\n    \\Input{observed data $\\mathcal{D}=\\{\\vec{x}_1,\\vec{x}_2,\\cdots, \\vec{x}_N$\\},GMM}\n\t\\Output{GMM's parameters $\\vec{\\pi},\\vec{\\mu},\\vec{\\Sigma}$}\n\n\t// 1. initialize \\\\\n\t$\\vec{\\pi}^{(0)}$ = ... \\\\\n\t$\\vec{\\mu}^{(0)}$ = ...  \\\\\n\t$\\vec{\\Sigma}^{(0)}$ = ...  \\\\\n\tt = 0 \\\\\n\t\\While{(!convergency)} {\n\t    // 2. E-step \\\\\n\t    $\\hat{r}_{ik}=\\frac{\\pi_kp(\\vec{x}_i|\\vec{\\theta}_k^{t-1})}{\\sum_{k'=1}^K \\pi_{k'}p(\\vec{x}_i|\\vec{\\mu}_k^{t-1},\\vec{\\Sigma}_k^{t-1})}$ \\\\\n\t    // 3. M-step \\\\\n        $\\hat{\\vec{\\pi}}_k=\\frac{\\sum_{i=1}^N \\hat{r}_{ik}}{N}$ \\\\\n\t\t$\\hat{\\vec{\\mu}}_k  = \\frac{\\sum_{i=1}^N \\hat{r}_{ik}\\vec{x}_i}{\\sum_{i=1}^N \\hat{r}_{ik}}$ \\\\\n\t\t$\\hat{\\vec{\\Sigma}}_k =\\frac{\\sum_{i=1}^N \\hat{r}_{ik}\\vec{x}_i\\vec{x}_i^T}{\\sum_{i=1}^N \\hat{r}_{ik}}-\\vec{\\mu}_k\\vec{\\mu}_k^T$ \\\\\n        ++t \\\\\n\t}\n\t\n\\caption{EM algorithm for GMM}\n\\end{algorithm}\n\n\n\\subsubsection{MAP estimation}\nAs usual, the MLE may overfit. The overfitting problem is particularly severe in the case of GMMs. An easy solution to this is to perform MAP estimation. The new auxiliary function is the expected complete data log-likelihood plus the log prior:\n\\begin{equation}\\begin{split}\nQ(\\vec{\\theta}, \\vec{\\theta}^{t-1}) & = \\sum\\limits_{i=1}^N{\\sum\\limits_{k=1}^K{r_{ik}\\log \\pi_k}}+\\sum\\limits_{i=1}^N{\\sum\\limits_{k=1}^K{r_{ik}\\log p(\\vec{x}_i|\\vec{\\theta}_k)}} \\\\\n & +\\log p(\\vec{\\pi})+\\sum\\limits_{k=1}^K{\\log p(\\vec{\\theta}_k)}\n\\end{split}\\end{equation}\n\nIt is natural to use conjugate priors. \n\\begin{align*}\np(\\vec{\\pi}) & = \\mathrm{Dir}(\\vec{\\pi}|\\vec{\\alpha}) \\\\\np(\\vec{\\mu}_k,\\vec{\\Sigma}_k) & = \\mathrm{NIW}(\\vec{\\mu}_k,\\vec{\\Sigma}_k|\\vec{m}_0,\\kappa_0,\\nu_0,\\vec{S}_0)\n\\end{align*}\n\nFrom Equation \\ref{eqn:Dir-MAP} and Section \\ref{sec:Posterior-distribution-of-mu-and-Sigma}, the MAP estimate is given by\n\\begin{align}\n\\hat{\\pi}_k & = \\frac{\\sum_{i=1}^N r_{ik}+\\alpha_k-1}{N+\\sum_{k=1}^K \\alpha_k-K} \\\\\n\\hat{\\vec{\\mu}}_k & = \\frac{\\sum_{i=1}^N r_{ik}\\vec{x}_i + \\kappa_0\\vec{m}_0}{\\sum_{i=1}^N r_{ik} + \\kappa_0} \\\\\n\\hat{\\vec{\\Sigma}}_k & = \\frac{\\vec{S}_0+\\vec{S}_k+\\frac{\\kappa_0r_k}{\\kappa_0+r_k}(\\bar{\\vec{x}}_k-\\vec{m}_0)(\\bar{\\vec{x}}_k-\\vec{m}_0)^T}{\\nu_0+r_k+D+2} \\\\\n\\text{where } & r_k \\triangleq \\sum_{i=1}^N r_{ik}, \\bar{\\vec{x}}_k \\triangleq \\frac{\\sum_{i=1}^N r_{ik}\\vec{x}_i}{r_k}, \\nonumber \\\\\n  & \\vec{S}_k \\triangleq \\sum_{i=1}^N r_{ik} (\\vec{x}_i-\\bar{\\vec{x}}_k)(\\vec{x}_i-\\bar{\\vec{x}}_k)^T \\nonumber\n\\end{align}\n\n\n\\subsection{EM for K-means}\n\\label{sec:K-means}\n\n\\subsubsection{Representation}\n\\begin{equation}\ny_j=k \\text{ if } \\|\\vec{x}_j-\\vec{\\mu}_k\\|_2^2 \\text{ is minimal}\n\\end{equation}\nwhere $\\vec{\\mu}_k$ \\ is\\ the centroid of cluster k.\n\n\n\\subsubsection{Evaluation}\n\\begin{equation}\n\\arg\\min\\limits_{\\vec{\\mu}} \\sum_{j=1}^N {\\sum_{k=1}^K}\\gamma_{jk}{\\|\\vec{x}_j-\\vec{\\mu}_k\\|_2^2}\n\\end{equation}\n\nThe hidden variable is $\\gamma_{jk}$, which's meanining is:\n\\begin{equation} \\nonumber\n\\gamma_{jk}=\\begin{cases}\n1, & \\text{if } \\|\\vec{x}_j-\\vec{\\mu}_k\\|_2 \\text{ is minimal for } \\vec{\\mu}_k \\\\\n0, & \\text{otherwise}\n\\end{cases}\n\\end{equation}\n\n\n\\subsubsection{Optimization}\nE-Step:\n\\begin{equation}\n\\gamma_{jk}^{(i+1)}=\\begin{cases} \n1, & \\text{if } \\|\\vec{x}_j-\\vec{\\mu}_k^{(i)}\\|_2 \\text{ is minimal for } \\vec{\\mu}_k^{(i)} \\\\ \n0, & \\text{otherwise}\n\\end{cases}\n\\end{equation}\n\nM-Step:\n\\begin{equation}\n\\vec{\\mu}_{k}^{(i+1)}= \\frac{\\sum_{j=1}^N{\\gamma_{jk}^{(i+1)}\\vec{x}_j}}{\\sum \\gamma_{jk}^{(i+1)}}\n\\end{equation}\n\n\n\\subsubsection{Tricks}\n\n\\textbf{Choosing $k$}\n\nTODO\n\n\\textbf{Choosing the initial centroids(seeds)}\n\n\\begin{enumerate}\n\\item  \\textbf{K-means++}.\n\nThe intuition that spreading out the k initial cluster centers is a good thing is behind this approach: the first cluster center is chosen uniformly at random from the data points that are being clustered, after which each subsequent cluster center is chosen from the remaining data points with probability proportional to its squared distance from the point's closest existing cluster center\\footnote{\\url{http://en.wikipedia.org/wiki/K-means++}}.\n\nThe exact algorithm is as follows:\n\\begin{enumerate}\n\\item Choose one center uniformly at random from among the data points.\n\\item For each data point \\vec{x}, compute $D(\\vec{x})$, the distance between \\vec{x} and the nearest center that has already been chosen.\n\\item Choose one new data point at random as a new center, using a weighted probability distribution where a point \\vec{x} is chosen with probability proportional to $D(\\vec{x})^2$.\n\\item Repeat Steps 2 and 3 until $k$ centers have been chosen.\n\\item Now that the initial centers have been chosen, proceed using standard k-means clustering.\n\\end{enumerate}\n\\item TODO\n\\end{enumerate}\n\n\n\\subsection{EM for mixture of experts}\n\n\n\\subsection{EM for DGMs with hidden variables}\n\n\n\\subsection{EM for the Student distribution *}\n\n\n\\subsection{EM for probit regression *}\n\n\n\\subsection{Derivation of the $Q$ function}\n\\label{sec:Derivation-of-the-Q-function}\n\n\\begin{theorem}\n(\\textbf{Jensen's inequality}) Let $f$ be a convex function(see Section \\ref{sec:Convexity}) defined on a convex set $\\mathcal{S}$ . If $\\vec{x}_1, \\vec{x}_2, \\cdots , \\vec{x}_n \\in \\mathcal{S}$ and $\\lambda_1, \\lambda_2, \\cdots , \\lambda_n \\geq 0$ with $\\sum\\limits_{i=1}^n \\lambda_i=1$,\n\\begin{equation}\nf\\left(\\sum\\limits_{i=1}^n \\lambda_i\\vec{x}_i\\right) \\leq \\sum\\limits_{i=1}^n {\\lambda_i f(\\vec{x}_i)}\n\\end{equation}\n\\end{theorem}\n\n\\begin{proposition}\n\\begin{equation}\n\\log\\left(\\sum\\limits_{i=1}^n \\lambda_i\\vec{x}_i\\right) \\geq \\sum\\limits_{i=1}^n {\\lambda_i \\log(\\vec{x}_i)}\n\\end{equation}\n\\end{proposition}\n\nNow let's proof why the $Q$ function should look like Equation \\ref{eqn:auxiliary-function}:\n\\begin{align}\n\\ell(\\vec{\\theta}) &= \\log{P(\\mathcal{D}|\\vec{\\theta})}  \\nonumber \\\\\n                &= \\log{{\\sum\\limits_{\\vec{z}} P(\\mathcal{D},\\vec{z}|\\vec{\\theta})}} \\nonumber \\\\\n\t\t\t\t&= \\log{{\\sum\\limits_{\\vec{z}} P(\\mathcal{D}|\\vec{z},\\vec{\\theta})P(\\vec{z}|\\vec{\\theta})}} \\nonumber \\\\\n\\ell(\\vec{\\theta})-\\ell(\\vec{\\theta}^{t-1}) &= \\log\\left[\\sum\\limits_{\\vec{z}} P(\\mathcal{D}|\\vec{z},\\vec{\\theta})P(\\vec{z}|\\vec{\\theta})\\right] - \\log{P(\\mathcal{D}|\\vec{\\theta}^{t-1})} \\nonumber \\\\\n                &= \\log\\left[\\sum\\limits_{\\vec{z}} P(\\mathcal{D}|\\vec{z},\\vec{\\theta})P(\\vec{z}|\\vec{\\theta})\\dfrac{P(\\vec{z}|\\mathcal{D},\\theta^{t-1})}{P(\\vec{z}|\\mathcal{D},\\theta^{t-1})}\\right] \\nonumber \\\\\n\t\t\t\t& \\quad -\\log{P(\\mathcal{D}|\\vec{\\theta}^{t-1})} \\nonumber \\\\\n\t\t\t\t&= \\log\\left[\\sum\\limits_{\\vec{z}} P(\\vec{z}|\\mathcal{D},\\theta^{t-1})\\dfrac{P(\\mathcal{D}|\\vec{z},\\vec{\\theta})P(\\vec{z}|\\vec{\\theta})}{P(\\vec{z}|\\mathcal{D},\\theta^{t-1})}\\right] \\nonumber \\\\\n\t\t\t\t& \\quad - \\log{P(\\mathcal{D}|\\vec{\\theta}^{t-1})} \\nonumber \\\\\n\t\t\t\t&\\geq \\sum\\limits_{\\vec{z}} P(\\vec{z}|\\mathcal{D},\\theta^{t-1})\\log\\left[\\dfrac{P(\\mathcal{D}|\\vec{z},\\vec{\\theta})P(\\vec{z}|\\vec{\\theta})}{P(\\vec{z}|\\mathcal{D},\\theta^{t-1})}\\right] \\nonumber \\\\\n\t\t\t\t& \\quad - \\log{P(\\mathcal{D}|\\vec{\\theta}^{t-1})} \\nonumber \\\\\n\t\t\t\t&= \\sum\\limits_{\\vec{z}} \\left\\{P(\\vec{z}|\\mathcal{D},\\theta^{t-1}) \\right. \\nonumber \\\\\n\t\t\t\t& \\quad \\left. \\log\\left[\\dfrac{P(\\mathcal{D}|\\vec{z},\\vec{\\theta})P(\\vec{z}|\\vec{\\theta})}{P(\\vec{z}|\\mathcal{D},\\theta^{t-1})P(\\mathcal{D}|\\vec{\\theta}^{t-1})}\\right]\\right\\} \\nonumber\n\\end{align}\n\\begin{align}\nB(\\vec{\\theta},\\vec{\\theta}^{t-1}) & \\triangleq \\ell(\\vec{\\theta}^{t-1})+ \\nonumber \\\\\n & \\sum\\limits_{\\vec{z}} P(\\vec{z}|\\mathcal{D},\\theta^{t-1})\\log\\left[\\dfrac{P(\\mathcal{D}|\\vec{z},\\vec{\\theta})P(\\vec{z}|\\vec{\\theta})}{P(\\vec{z}|\\mathcal{D},\\theta^{t-1})P(\\mathcal{D}|\\vec{\\theta}^{t-1})}\\right] \\nonumber \\\\\n\\Rightarrow & \\nonumber\n\\end{align}\n\n\\begin{align}\n\\vec{\\theta}^t &= \\arg\\max\\limits_{\\vec{\\theta}} B(\\vec{\\theta},\\vec{\\theta}^{t-1})  \\nonumber \\\\\n                &= \\arg\\max\\limits_{\\vec{\\theta}}\\left\\{ \\ell(\\vec{\\theta}^{t-1})+\\right. \\nonumber \\\\\n\t\t\t\t & \\quad \\left. \\sum\\limits_{\\vec{z}} P(\\vec{z}|\\mathcal{D},\\theta^{t-1})\\log\\left[\\dfrac{P(\\mathcal{D}|\\vec{z},\\vec{\\theta})P(\\vec{z}|\\vec{\\theta})}{P(\\vec{z}|\\mathcal{D},\\theta^{t-1})P(\\mathcal{D}|\\vec{\\theta}^{t-1})}\\right]\\right\\} \\nonumber \\\\\n\t\t\t\t& \\text{Now drop terms which are constant w.r.t. } \\vec{\\theta} \\nonumber \\\\\n\t\t\t\t&= \\arg\\max\\limits_{\\vec{\\theta}}{\\left\\{\\sum\\limits_{\\vec{z}} P(\\vec{z}|\\mathcal{D},\\theta^{t-1})\\log\\left[P(\\mathcal{D}|\\vec{z},\\vec{\\theta})P(\\vec{z}|\\vec{\\theta})\\right]\\right\\}} \\nonumber \\\\\n\t\t\t\t&= \\arg\\max\\limits_{\\vec{\\theta}}{\\left\\{\\sum\\limits_{\\vec{z}} P(\\vec{z}|\\mathcal{D},\\theta^{t-1})\\log\\left[P(\\mathcal{D},\\vec{z}|\\vec{\\theta})\\right]\\right\\}} \\nonumber \\\\\n\t\t\t\t&= \\arg\\max\\limits_{\\vec{\\theta}}{\\left\\{\\mathbb{E}_{\\vec{z}|\\mathcal{D},\\theta^{t-1}}\\log\\left[P(\\mathcal{D},\\vec{z}|\\vec{\\theta})\\right]\\right\\}} \\\\\n\t\t\t\t&\\triangleq \\arg\\max\\limits_{\\vec{\\theta}}{Q(\\vec{\\theta}, \\vec{\\theta}^{t-1})}\n\\end{align}\n\n\n\\subsection{Convergence of the EM Algorithm *}\n\n\\subsubsection{Expected complete data log likelihood is a lower bound}\n\nNote that $\\ell(\\vec{\\theta}) \\geq B(\\vec{\\theta},\\vec{\\theta}^{t-1})$, and $\\ell(\\vec{\\theta}^{t-1}) \\geq B(\\vec{\\theta}^{t-1},\\vec{\\theta}^{t-1})$, which means $B(\\vec{\\theta},\\vec{\\theta}^{t-1})$ is an lower bound of $\\ell(\\vec{\\theta})$. If we maximize $B(\\vec{\\theta},\\vec{\\theta}^{t-1})$, then $\\ell(\\vec{\\theta})$ gets maximized, see Figure \\ref{fig:EM-algorithm}.\n\n\\begin{figure}[hbtp]\n\\centering\n    \\includegraphics[scale=.50]{EM-algorithm.png}\n\\caption{Graphical interpretation of a single iteration of the EM algorithm: The function $B(\\vec{\\theta},\\vec{\\theta}^{t-1})$ is bounded above by the log likelihood function $\\ell(\\vec{\\theta})$. The functions are equal at $\\vec{\\theta} = \\vec{\\theta}^{t-1}$. The EM algorithm chooses $\\vec{\\theta}^{t-1}$ as the value of $\\vec{\\theta}$ for which $B(\\vec{\\theta},\\vec{\\theta}^{t-1})$ is a maximum. Since $\\ell(\\vec{\\theta}) \\geq B(\\vec{\\theta},\\vec{\\theta}^{t-1})$ increasing $B(\\vec{\\theta},\\vec{\\theta}^{t-1})$ ensures that the value of the log likelihood function $\\ell(\\vec{\\theta})$ is increased at each step.}\n\\label{fig:EM-algorithm} \n\\end{figure}\n\nSince the expected complete data log likelihood $Q$ is derived from $B(\\vec{\\theta},\\vec{\\theta}^{t-1})$ by dropping terms which are constant w.r.t. $\\vec{\\theta}$, so it is also a lower bound to a lower bound of $\\ell(\\vec{\\theta})$.\n\n\n\\subsubsection{EM monotonically increases the observed data log likelihood}\n\n\n\\subsection{Generalization of EM Algorithm *}\nEM algorithm can be interpreted as F function's maximization-maximization algorithm, based on this interpretation there are many variations and generalization, e.g., generalized EM Algorithm(GEM).\n\n\n\\subsubsection{F function's maximization-maximization algorithm}\n\\begin{definition}\nGiven the probability distribution of the hidden variable $Z$ is $\\tilde{P}(Z)$, define \\textbf{F function} as the following:\n\\begin{equation}\nF(\\tilde{P},\\vec{\\theta})=\\mathbb{E}_{\\tilde{P}}\\left[\\log{P(X,Z|\\theta)}\\right]+H(\\tilde{P})\n\\end{equation}\nWhere $H(\\tilde{P})=-\\mathbb{E}_{\\tilde{P}}\\log\\tilde{P}(Z)$, which is $\\tilde{P}(Z)$'s entropy. Usually we assume that $P(X,Z|\\theta)$ is continuous w.r.t. $\\vec{\\theta}$, therefore $F(\\tilde{P},\\vec{\\theta})$ is continuous w.r.t. $\\tilde{P}$ and $\\vec{\\theta}$.\n\\end{definition}\n\n\\begin{lemma}\n\\label{lemma:F-function}\nFor a fixed $\\vec{\\theta}$, there is only one distribution $\\tilde{P}_{\\theta}$ which maximizes $F(\\tilde{P},\\vec{\\theta})$\n\\begin{equation}\n\\tilde{P}_{\\theta}(Z)=P(Z|X, \\vec{\\theta})\n\\end{equation}\nand $\\tilde{P}_{\\theta}$ is continuous w.r.t. $\\vec{\\theta}$.\n\\end{lemma}\n\n\\begin{proof}\nGiven a fixed $\\vec{\\theta}$, we can get $\\tilde{P}_{\\theta}$ which maximizes $F(\\tilde{P},\\vec{\\theta})$. we construct the Lagrangian\n\\begin{equation}\\begin{split}\n\\mathcal{L}(\\tilde{P}, \\vec{\\theta}) & =\\mathbb{E}_{\\tilde{P}}\\left[\\log{P(X,Z|\\theta)}\\right]-\\mathbb{E}_{\\tilde{P}}\\log\\tilde{P}_{\\theta}(Z) \\\\\n                                     & \\quad +\\lambda\\left[1-\\sum\\limits_Z{\\tilde{P}(Z)}\\right]\n\\end{split}\\end{equation}\n\nTake partial derivative with respect to $\\tilde{P}_{\\theta}(Z)$ then we get\n\\begin{equation}\n\\dfrac{\\partial \\mathcal{L}}{\\partial{\\tilde{P}_{\\theta}(Z)}}=\\log{P(X,Z|\\theta)}-\\log\\tilde{P}_{\\theta}(Z)-1-\\lambda  \\nonumber\n\\end{equation}\n\nLet it equal to 0, we can get\n\\begin{equation}\n\\lambda=\\log{P(X,Z|\\theta)}-\\log\\tilde{P}_{\\theta}(Z)-1 \\nonumber\n\\end{equation}\n\nThen we can derive that $\\tilde{P}_{\\theta}(Z)$ is proportional to $P(X,Z|\\theta)$\n\\begin{eqnarray}\n\\dfrac{P(X,Z|\\theta)}{\\tilde{P}_{\\theta}(Z)} &=& e^{1+\\lambda} \\nonumber \\\\\n\\Rightarrow \\tilde{P}_{\\theta}(Z) &=& \\dfrac{P(X,Z|\\vec{\\theta})}{e^{1+\\lambda}} \\nonumber \\\\\n\\sum\\limits_Z{\\tilde{P}_{\\theta}(Z)}=1 & \\Rightarrow & \\sum\\limits_Z{\\dfrac{P(X,Z|\\vec{\\theta})}{e^{1+\\lambda}}}=1 \\Rightarrow P(X|\\vec{\\theta})=e^{1+\\lambda} \\nonumber \\\\\n\\tilde{P}_{\\theta}(Z) &=& \\dfrac{P(X,Z|\\vec{\\theta})}{e^{1+\\lambda}} = \\dfrac{P(X,Z|\\vec{\\theta})}{P(X|\\vec{\\theta})}=P(Z|X, \\vec{\\theta}) \\nonumber\n\\end{eqnarray}\n\\end{proof}\n\n\\begin{lemma}\nIf $\\tilde{P}_{\\theta}(Z)=P(Z|X, \\vec{\\theta})$, then\n\\begin{equation}\nF(\\tilde{P},\\vec{\\theta})=\\log P(X|\\vec{\\theta})\n\\end{equation}\n\\end{lemma}\n\n\\begin{theorem}\nOne iteration of EM algorithm can be implemented as F function's maximization-maximization.\n\nAssume $\\vec{\\theta}^{t-1}$ is the estimation of $\\vec{\\theta}$ in the $(t-1)$-th iteration, $\\tilde{P}^{t-1}$ is the estimation of $\\tilde{P}$ in the $(t-1)$-th iteration. Then in the $t$-th iteration two steps are:\n\\begin{enumerate}\n\\item for fixed $\\vec{\\theta}^{t-1}$, find $\\tilde{P}^t$ that maximizes $F(\\tilde{P},\\vec{\\theta}^{t-1})$;\n\\item for fixed $\\tilde{P}^t$, find $\\vec{\\theta}^t$ that maximizes $F(\\tilde{P}^t,\\vec{\\theta})$.\n\\end{enumerate}\n\\end{theorem}\n\n\\begin{proof}\n(1) According to Lemma \\ref{lemma:F-function}, we can get\n\\begin{equation}\n\\tilde{P}^t(Z)=P(Z|X, \\vec{\\theta}^{t-1}) \\nonumber\n\\end{equation}\n\n(2) According above, we can get\n\\begin{eqnarray}\nF(\\tilde{P}^t,\\vec{\\theta}) &=& \\mathbb{E}_{\\tilde{P}^t}\\left[\\log{P(X,Z|\\theta)}\\right]+H(\\tilde{P}^t) \\nonumber \\\\\n    &=& \\sum\\limits_Z{P(Z|X,\\vec{\\theta}^{t-1})\\log{P(X,Z|\\theta)}}+H(\\tilde{P}^t) \\nonumber \\\\\n\t&=& Q(\\vec{\\theta}, \\vec{\\theta}^{t-1})+H(\\tilde{P}^t)\\nonumber\n\\end{eqnarray}\n\nThen\n\\begin{equation}\n\\vec{\\theta}^t=\\arg\\max\\limits_{\\theta}F(\\tilde{P}^t,\\vec{\\theta})=\\arg\\max\\limits_{\\theta}Q(\\vec{\\theta}, \\vec{\\theta}^{t-1}) \\nonumber\n\\end{equation}\n\\end{proof}\n\n\n\\subsubsection{The Generalized EM Algorithm(GEM)}\nIn the formulation of the EM algorithm described above, $\\vec{\\theta}^t$ was chosen as the value of $\\vec{\\theta}$ for which $Q(\\vec{\\theta}, \\vec{\\theta}^{t-1})$ was maximized. While this ensures the greatest increase in $\\ell(\\vec{\\theta})$, it is however possible to relax the requirement of maximization to one of simply increasing $Q(\\vec{\\theta}, \\vec{\\theta}^{t-1})$ so that $Q(\\vec{\\theta}^t, \\vec{\\theta}^{t-1}) \\geq Q(\\vec{\\theta}^{t-1}, \\vec{\\theta}^{t-1})$. This approach, to simply increase and not necessarily maximize $Q(\\vec{\\theta}^t, \\vec{\\theta}^{t-1})$ is known as the Generalized Expectation Maximization (GEM) algorithm and is often useful in cases where the maximization is difficult. The convergence of the GEM algorithm is similar to the EM algorithm.\n\n\n\\subsection{Online EM}\n\n\n\\subsection{Other EM variants *}\n\n\n\\section{Model selection for latent variable models}\n\\label{sec:Model-selection-for-LVM}\nWhen using LVMs, we must specify the number of latent variables, which controls the model complexity. In particular, in the case of mixture models, we must specify $K$, the number of clusters. Choosing these parameters is an example of model selection. We discuss some approaches below.\n\n\n\\subsection{Model selection for probabilistic models}\nThe optimal Bayesian approach, discussed in Section \\ref{sec:Bayesian-model-selection}, is to pick the model with the largest marginal likelihood, $K^*=\\arg\\max_k p(\\mathcal{D}|k)$.\n\nThere are two problems with this. First, evaluating the marginal likelihood for LVMs is quite difficult. In practice, simple approximations, such as BIC, can be used (see e.g., (Fraley and Raftery 2002)). Alternatively, we can use the cross-validated likelihood as a performance measure, although this can be slow, since it requires fitting each model $F$ times, where Fis the number of CV folds.\n\nThe second issue is the need to search over a potentially large number of models. The usual approach is to perform exhaustive search over all candidate values ofK. However, sometimes we can set the model to its maximal size, and then rely on the power of the Bayesian Occam’s razor to “kill off” unwanted components. An example of this will be shown in Section TODO 21.6.1.6, when we discuss variational Bayes.\n\nAn alternative approach is to perform stochastic sampling in the space of models. Traditional approaches, such as (Green 1998, 2003; Lunn et al. 2009), are based on reversible jump MCMC, and use birth moves to propose new centers, and death moves to kill off old centers. However, this can be slow and difficult to implement. A simpler approach is to use a Dirichlet process mixture model, which can be fit using Gibbs sampling, but still allows for an unbounded number of mixture components; see Section TODO 25.2 for details.\n\nPerhaps surprisingly, these sampling-based methods can be faster than the simple approach of evaluating the quality of eachKseparately. The reason is that fitting the model for each $K$ is often slow. By contrast, the sampling methods can often quickly determine that a certain value of $K$ is poor, and thus they need not waste time in that part of the posterior.\n\n\n\\subsection{Model selection for non-probabilistic methods}\nWhat if we are not using a probabilistic model? For example, how do we choose $K$ for the K-means algorithm? Since this does not correspond to a probability model, there is no likelihood, so none of the methods described above can be used.\n\nAn obvious proxy for the likelihood is the \\textbf{reconstruction error}. Define the squared reconstruction error of a data set $\\mathcal{D}$, using model complexity $K$, as follows:\n\\begin{equation}\nE(\\mathcal{D}, K) \\triangleq \\frac{1}{|\\mathcal{D}|}\\sum\\limits_{i=1}^N \\lVert\\vec{x}_i-\\hat{\\vec{x}}_i\\rVert^2\n\\end{equation}\n\nIn the case of K-means, the reconstruction is given by $\\hat{\\vec{x}}_i=\\vec{\\mu}_{z_i}$, where $z_i=\\arg\\min_k \\lVert\\vec{x}_i-\\hat{\\vec{\\mu}}_k\\rVert^2$, as explained in Section 11.4.2.6 TODO.\n\nIn supervised learning, we can always use cross validation to select between non-probabilistic models of different complexity, but this is not the case with unsupervised learning. The most common approach is to plot the reconstruction error on the training set versus $K$, and to try to identify a \\textbf{knee} or \\textbf{kink} in the curve. \n\n\n\\section{Fitting models with missing data}\nSuppose we want to fit a joint density model by maximum likelihood, but we have “holes” in our data matrix, due to missing data (usually represented by NaNs). More formally, let $O_{ij} =1$ if component $j$ of data case $i$ is observed, and let $O_{ij} =0$ otherwise. Let $\\vec{X}_v=\\{x_{ij}: \\vec{O}_{ij} =1\\}$ be the visible data, and $X_h=\\{x_{ij}: \\vec{O}_{ij} =0\\}$ be the missing or hidden data. Our goal is to compute\n\\begin{equation}\n\\hat{\\vec{\\theta}}=\\arg\\max_{\\vec{\\theta}} p(\\vec{X}_v|\\vec{\\theta}, \\vec{O})\n\\end{equation}\n\nUnder the missing at random assumption (see Section \\ref{sec:Dealing-with-missing-data}), we have\n\nTODO\n\n\\subsection{EM for the MLE of an MVN with missing data}\nTODO\n"
  },
  {
    "path": "chapterExactInferenceForGraphicalModels.tex",
    "content": "\\chapter{Exact inference for graphical models}\n\n"
  },
  {
    "path": "chapterFrequentistStatistics.tex",
    "content": "\\chapter{Frequentist statistics}\n\nAttempts have been made to devise approaches to statistical inference that avoid treating parameters like random variables, and which thus avoid the use of priors and Bayes rule. Such approaches are known as \\textbf{frequentist statistics}, \\textbf{classical statistics} or \\textbf{orthodox statistics}. Instead of being based on the posterior distribution, they are based on the concept of a sampling distribution.\n\n\n\\section{Sampling distribution of an estimator}\nIn frequentist statistics, a parameter estimate $\\hat{\\vec{\\theta}}$ is computed by applying an \\textbf{estimator} $\\delta$ to some data $\\mathcal{D}$, so $\\hat{\\vec{\\theta}}=\\delta(\\mathcal{D})$. The parameter is viewed as fixed and the data as random, which is the exact opposite of the Bayesian approach. The uncertainty in the parameter estimate can be measured by computing the \\textbf{sampling distribution} of the estimator. To understand this\n\n\n\\subsection{Bootstrap}\nWe might think of the bootstrap distribution as a “poor man’s” Bayes posterior, see (Hastie et al. 2001, p235) for details.\n\n\n\\subsection{Large sample theory for the MLE *}\n\n\n\n\\section{Frequentist decision theory}\nIn frequentist or classical decision theory, there is a loss function and a likelihood, but there is no prior and hence no posterior or posterior expected loss. Thus there is no automatic way of deriving an optimal estimator, unlike the Bayesian case. Instead, in the frequentist approach, we are free to choose any estimator or decision procedure $f: \\mathcal{X} \\rightarrow \\mathcal{Y}$ we want.\n\nHaving chosen an estimator, we define its expected loss or \\textbf{risk} as follows:\n\\begin{equation}\\begin{split}\nR_{\\mathrm{exp}}(\\theta,f) & \\triangleq \\mathbb{E}_{p(\\tilde{\\mathcal{D}}|\\theta^*)}[L(\\theta^*, f(\\tilde{\\mathcal{D}}))] \\\\\n    & =\\int L(\\theta^*, f(\\tilde{\\mathcal{D}}))p(\\tilde{\\mathcal{D}}|\\theta^*)\\mathrm{d}\\tilde{\\mathcal{D}}\n\\end{split}\\end{equation}\nwhere˜$\\tilde{\\mathcal{D}}$ is data sampled from “nature’s distribution”, which is represented by parameter $\\theta^*$. In other words, the expectation is wrt the sampling distribution of the estimator. Compare this to the Bayesian posterior expected loss:\n\\begin{equation}\n\\rho(f|\\mathcal{D},)\n\\end{equation}\n\n\n\\section{Desirable properties of estimators}\n\n\n\\section{Empirical risk minimization}\n\n\n\\subsection{Regularized risk minimization}\n\n\n\\subsection{Structural risk minimization}\n\n\n\\subsection{Estimating the risk using cross validation}\n\n\n\\subsection{Upper bounding the risk using statistical learning theory *}\n\n\n\\subsection{Surrogate loss functions}\n\\label{sec:Surrogate-loss-functions}\n\n\\textbf{log-loss}\n\\begin{equation}\\label{eqn:log-loss}\nL_{\\mathrm{nll}}(y,\\eta)=-\\log p(y|\\vec{x},\\vec{w})=\\log(1+e^{-y\\eta})\n\\end{equation}\n\n\n\\section{Pathologies of frequentist statistics *}\n\n"
  },
  {
    "path": "chapterGLM.tex",
    "content": "\\chapter{Generalized linear models and the exponential family}\n\\label{chap:GLM}\n\n\n\\section{The exponential family}\n\\label{sec:exponential-family}\n\nBefore defining the exponential family, we mention several reasons why it is important:\n\\begin{itemize}\n\\item{It can be shown that, under certain regularity conditions, the exponential family is the only family of distributions with finite-sized sufficient statistics, meaning that we can compress the data into a fixed-sized summary without loss of information. This is particularly useful for online learning, as we will see later.}\n\\item{The exponential family is the only family of distributions for which conjugate priors exist, which simplifies the computation of the posterior (see Section \\ref{sec:Bayes-for-the-exponential-family}).}\n\\item{The exponential family can be shown to be the family of distributions that makes the least set of assumptions subject to some user-chosen constraints (see Section \\ref{sec:Maximum-entropy-derivation-of-the-exponential-family}).}\n\\item{The exponential family is at the core of generalized linear models, as discussed in Section \\ref{sec:GLMs}.}\n\\item{The exponential family is at the core of variational inference, as discussed in Section TODO.}\n\\end{itemize}\n\n\n\\subsection{Definition}\nA pdf or pmf $p(\\vec{x}|\\vec{\\theta})$,for $\\vec{x} \\in \\mathbb{R}^m$ and $\\vec{\\theta} \\in \\mathbb{R}^D$, is said to be in the \\textbf{exponential family} if it is of the form\n\\begin{align}\np(\\vec{x}|\\vec{\\theta}) & =\\dfrac{1}{Z(\\vec{\\theta})}h(\\vec{x})\\exp[\\vec{\\theta}^T\\phi(\\vec{x})] \\\\\n    & = h(\\vec{x})\\exp[\\vec{\\theta}^T\\phi(\\vec{x})-A(\\vec{\\theta})] \\label{eqn:exponential-family}\n\\end{align}\nwhere\n\\begin{align}\nZ(\\vec{\\theta}) & =\\int h(\\vec{x})\\exp[\\vec{\\theta}^T\\phi(\\vec{x})]\\mathrm{d}\\vec{x} \\\\\nA(\\vec{\\theta}) & =\\log Z(\\vec{\\theta})\n\\end{align}\n\nHere $\\vec{\\theta}$ are called the \\textbf{natural parameters} or \\textbf{canonical parameters}, $\\phi(\\vec{x}) \\in \\mathbb{R}^D$ is called a vector of \\textbf{sufficient statistics}, $Z(\\vec{\\theta})$ is called the \\textbf{partition function}, $A(\\vec{\\theta})$ is called the \\textbf{log partition function} or \\textbf{cumulant function}, and $h(\\vec{x})$ is the a scaling constant, often 1. If $\\phi(\\vec{x})=\\vec{x}$, we say it is a \\textbf{natural exponential family}.\n\nEquation \\ref{eqn:exponential-family} can be generalized by writing\n\\begin{equation}\np(\\vec{x}|\\vec{\\theta}) = h(\\vec{x})\\exp[\\eta(\\vec{\\theta})^T\\phi(\\vec{x})-A(\\eta(\\vec{\\theta}))]\n\\end{equation}\nwhere $\\eta$ is a function that maps the parameters $\\vec{\\theta}$ to the canonical parameters $\\vec{\\eta}=\\eta(\\vec{\\theta})$.If $\\mathrm{dim}(\\vec{\\theta})<\\mathrm{dim}(\\eta(\\vec{\\theta}))$, it is called a \\textbf{curved exponential family}, which means we have more sufficient statistics than parameters. If $\\eta(\\vec{\\theta})=\\vec{\\theta}$, the model is said to be in \\textbf{canonical form}. We will assume models are in canonical form unless we state otherwise.\n\n\n\\subsection{Examples}\n\n\n\\subsubsection{Bernoulli}\nThe Bernoulli for $x \\in \\{0,1\\}$ can be written in exponential family form as follows:\n\\begin{equation}\\begin{split}\n\\mathrm{Ber}(x|\\mu)& =\\mu^x(1-\\mu)^{1-x} \\\\\n   & =\\exp[x\\log\\mu+(1-x)\\log(1-\\mu)]\n\\end{split}\\end{equation}\nwhere $\\phi(x)=(\\mathbb{I}(x=0),\\mathbb{I}(x=1))$ and $\\vec{\\theta}=(\\log\\mu,\\log(1-\\mu))$. \n\nHowever, this representation is \\textbf{over-complete} since $\\vec{1}^T\\phi(x)=\\mathbb{I}(x=0)+\\mathbb{I}(x=1)=1$. Consequently $\\vec{\\theta}$ is not uniquely identifiable. It is common to require that the representation be \\textbf{minimal}, which means there is a unique $\\theta$ associated with the distribution. In this case, we can just define\n\\begin{align}\n\\mathrm{Ber}(x|\\mu) & =(1-\\mu)\\exp\\left(x\\log\\dfrac{\\mu}{1-\\mu}\\right) \\\\\n\\text{where } \\phi(x) & =x, \\theta=\\log\\dfrac{\\mu}{1-\\mu}, Z=\\dfrac{1}{1-\\mu}  \\nonumber\n\\end{align}\n\nWe can recover the mean parameter $\\mu$ from the canonical parameter using\n\\begin{equation}\n\\mu=\\mathrm{sigm}(\\theta)=\\dfrac{1}{1+e^{-\\theta}}\n\\end{equation}\n\n\n\\subsubsection{Multinoulli}\nWe can represent the multinoulli as a minimal exponential family as follows:\n\\begin{equation*}\\begin{split}\n& \\mathrm{Cat}(\\vec{x}|\\vec{\\mu}) = \\prod\\limits_{k=1}^K = \\exp\\left(\\sum\\limits_{k=1}^K x_k\\log\\mu_k\\right) \\\\\n    & = \\exp\\left[\\sum\\limits_{k=1}^{K-1} x_k\\log\\mu_k+  (1-\\sum\\limits_{k=1}^{K-1} x_k)\\log(1-\\sum\\limits_{k=1}^{K-1} \\mu_k)\\right] \\\\\n\t& = \\exp\\left[\\sum\\limits_{k=1}^{K-1} x_k\\log\\dfrac{\\mu_k}{1-\\sum_{k=1}^{K-1} \\mu_k} + \\log(1-\\sum\\limits_{k=1}^{K-1} \\mu_k) \\right] \\\\\n\t& = \\exp\\left[\\sum\\limits_{k=1}^{K-1} x_k\\log\\dfrac{\\mu_k}{\\mu_K}+\\log\\mu_K\\right] \\text{, where } \\mu_K \\triangleq 1-\\sum\\limits_{k=1}^{K-1} \\mu_k\n\\end{split}\\end{equation*}\n\nWe can write this in exponential family form as follows:\n\\begin{align}\n\\mathrm{Cat}(\\vec{x}|\\vec{\\mu}) & = \\exp[\\vec{\\theta}^T\\phi(\\vec{x})-A(\\vec{\\theta})] \\\\\n\\vec{\\theta} & \\triangleq (\\log\\dfrac{\\mu_1}{\\mu_K},\\cdots,\\log\\dfrac{\\mu_{K-1}}{\\mu_K}) \\\\\n\\phi(\\vec{x}) & \\triangleq (x_1,\\cdots,x_{K-1})\n\\end{align}\n\nWe can recover the mean parameters from the canonical parameters using\n\\begin{align}\n\\mu_k & = \\dfrac{e^{\\theta_k}}{1+\\sum_{j=1}^{K-1} e^{\\theta_j}} \\\\\n\\mu_K & = 1- \\dfrac{\\sum_{j=1}^{K-1} e^{\\theta_j}}{1+\\sum_{j=1}^{K-1} e^{\\theta_j}}=\\dfrac{1}{1+\\sum_{j=1}^{K-1} e^{\\theta_j}}\n\\end{align}\nand hence\n\\begin{equation}\nA(\\vec{\\theta]} = -\\log\\mu_K=\\log(1+\\sum\\limits_{j=1}^{K-1} e^{\\theta_j})\n\\end{equation}\n\n\n\\subsubsection{Univariate Gaussian}\nThe univariate Gaussian can be written in exponential family form as follows:\n\\begin{align}\n\\mathcal{N}(x|\\mu,\\sigma^2) & =\\dfrac{1}{\\sqrt{2\\pi}\\sigma}\\exp\\left[-\\dfrac{1}{2\\sigma^2}(x-\\mu)^2\\right] \\nonumber \\\\\n    & = \\dfrac{1}{\\sqrt{2\\pi}\\sigma}\\exp\\left[-\\dfrac{1}{2\\sigma^2}x^2+\\dfrac{\\mu}{\\sigma^2}x-\\dfrac{1}{2\\sigma^2}\\mu^2\\right] \\nonumber \\\\\n\t& = \\dfrac{1}{Z(\\vec{\\theta})}\\exp[\\vec{\\theta}^T\\phi(x)]\n\\end{align}\nwhere\n\\begin{align}\n\\vec{\\theta} & = (\\dfrac{\\mu}{\\sigma^2}, -\\dfrac{1}{2\\sigma^2}) \\\\\n\\phi(x) & =(x,x^2) \\\\\nZ(\\vec{\\theta}) & =\\sqrt{2\\pi}\\sigma\\exp(\\dfrac{\\mu^2}{2\\sigma^2})\n\\end{align}\n\n\n\\subsubsection{Non-examples}\nNot all distributions of interest belong to the exponential family. For example, the uniform distribution,$X \\sim U(a,b)$, does not, since the support of the distribution depends on the parameters. Also, the Student T distribution (Section TODO) does not belong, since it does not have the required form.\n\n\n\\subsection{Log partition function}\nAn important property of the exponential family is that derivatives of the log partition function can be used to generate \\textbf{cumulants} of the sufficient statistics.\\footnote{The first and second cumulants of a distribution are its mean $\\mathbb{E}[X]$ and variance $\\mathrm{var}[X]$, whereas the first and second moments are its mean $\\mathbb{E}[X]$ and $\\mathbb{E}[X^2]$.} For this reason, $A(\\vec{\\theta})$ is sometimes called a \\textbf{cumulant function}. We will prove this for a 1-parameter distribution; this can be generalized to a $K$-parameter distribution in a straightforward way. For the first derivative we have\n\nFor the second derivative we have\n\\begin{align}\n\\dfrac{\\mathrm{d} A}{\\mathrm{d} \\theta} & = \\dfrac{\\mathrm{d}}{\\mathrm{d} \\theta}\\left\\{\\log\\int\\exp\\left[\\theta\\phi(x)\\right]h(x)\\mathrm{d}x\\right\\} \\nonumber \\\\\n    & = \\dfrac{\\frac{\\mathrm{d}}{\\mathrm{d} \\theta}\\int\\exp\\left[\\theta\\phi(x)\\right]h(x)\\mathrm{d}x}{\\int\\exp\\left[\\theta\\phi(x)\\right]h(x)\\mathrm{d}x} \\nonumber \\\\\n\t& = \\dfrac{\\int\\phi(x)exp\\left[\\theta\\phi(x)\\right]h(x)\\mathrm{d}x}{\\exp(A(\\theta))} \\nonumber \\\\\n\t& = \\int \\phi(x)\\exp\\left[\\theta\\phi(x)-A(\\theta)\\right]h(x)\\mathrm{d}x \\nonumber \\\\\n\t& = \\int \\phi(x)p(x)\\mathrm{d}x=\\mathbb{E}[\\phi(x)]\n\\end{align}\n\nFor the second derivative we have\n\\begin{align}\n\\dfrac{\\mathrm{d}^2 A}{\\mathrm{d} \\theta^2} & = \\int \\phi(x)\\exp\\left[\\theta\\phi(x)-A(\\theta)\\right]h(x)\\left[\\phi(x)-A'(\\theta)\\right]\\mathrm{d}x \\nonumber \\\\\n    & = \\int \\phi(x)p(x)\\left[\\phi(x)-A'(\\theta)\\right]\\mathrm{d}x \\nonumber \\\\\n\t& = \\int \\phi^2(x)p(x)\\mathrm{d}x-A'(\\theta)\\int \\phi(x)p(x)\\mathrm{d}x \\nonumber \\\\\n\t& = \\mathbb{E}[\\phi^2(x)]-\\mathbb{E}[\\phi(x)]^2=\\mathrm{var}[\\phi(x)]\n\\end{align}\n\nIn the multivariate case, we have that\n\\begin{equation}\n\\dfrac{\\partial^2 A}{\\partial \\theta_i \\partial \\theta_j}=\\mathbb{E}[\\phi_i(x)\\phi_j(x)]-\\mathbb{E}[\\phi_i(x)]\\mathbb{E}[\\phi_j(x)]\n\\end{equation}\nand hence\n\\begin{equation}\n\\nabla^2A(\\vec{\\theta}) = \\mathrm{cov}[\\phi(\\vec{x})]\n\\end{equation}\n\nSince the covariance is positive definite, we see that $A(\\vec{\\theta})$ is a convex function (see Section \\ref{sec:Convexity}).\n\n\n\\subsection{MLE for the exponential family}\nThe likelihood of an exponential family model has the form\n\\begin{equation}\np(\\mathcal{D}|\\vec{\\theta})=\\left[\\prod\\limits_{i=1}^N h(\\vec{x}_i)\\right]g(\\vec{\\theta})^N\\exp\\left[\\vec{\\theta}^T\\left(\\sum\\limits_{i=1}^N \\phi(\\vec{x}_i)\\right)\\right]\n\\end{equation}\n\nWe see that the sufficient statistics are $N$ and\n\\begin{equation}\n\\phi(\\mathcal{D})=\\sum\\limits_{i=1}^N \\phi(\\vec{x}_i)=(\\sum\\limits_{i=1}^N \\phi_1(\\vec{x}_i),\\cdots,\\sum\\limits_{i=1}^N \\phi_K(\\vec{x}_i))\n\\end{equation}\n\nThe \\textbf{Pitman-Koopman-Darmois theorem} states that, under certain regularity conditions, the exponential family is the only family of distributions with finite sufficient statistics. (Here, finite means of a size independent of the size of the data set.)\n\nOne of the conditions required in this theorem is that the support of the distribution not be dependent on the parameter.\n\n\n\\subsection{Bayes for the exponential family}\n\\label{sec:Bayes-for-the-exponential-family}\nTODO\n\n\n\\subsubsection{Likelihood}\n\n\n\n\\subsection{Maximum entropy derivation of the exponential family *}\n\\label{sec:Maximum-entropy-derivation-of-the-exponential-family}\n\n\n\n\\section{Generalized linear models (GLMs)}\n\\label{sec:GLMs}\nLinear and logistic regression are examples of \\textbf{generalized linear models}, or \\textbf{GLM}s (McCullagh and Nelder 1989). These are models in which the output density is in the exponential family (Section \\ref{sec:exponential-family}), and in which the mean parameters are a linear combination of the inputs, passed through a possibly nonlinear function, such as the logistic function. We describe GLMs in more detail below. We focus on scalar outputs for notational simplicity. (This excludes multinomial logistic regression, but this is just to simplify the presentation.)\n\n\n\\subsection{Basics}\n\n\n\n\\section{Probit regression}\n\n\n\n\\section{Multi-task learning}\n\n\n\n"
  },
  {
    "path": "chapterGP.tex",
    "content": "\\chapter{Gaussian processes}\n\n\n\\section{Introduction}\nIn supervised learning, we observe some inputs $\\vec{x}_i$ and some outputs $y_i$. We assume that $y_i =f(\\vec{x}_i)$, for some unknown function $f$, possibly corrupted by noise. The optimal approach is to infer a \\emph{distribution over functions} given the data, $p(f|\\mathcal{D})$, and then to use this to make predictions given new inputs, i.e., to compute\n\\begin{equation}\np(y|\\vec{x},\\mathcal{D})=\\int p(y|f,\\vec{x})p(f|\\mathcal{D})\\mathrm{d}f\n\\end{equation}\n\nUp until now, we have focussed on parametric representations for the function $f$, so that instead of inferring $p(f|\\mathcal{D})$, we infer $p(\\vec{\\theta}|\\mathcal{D})$. In this chapter, we discuss a way to perform Bayesian inference over functions themselves.\n\nOur approach will be based on \\textbf{Gaussian processes} or \\textbf{GP}s. A GP defines a prior over functions, which can be converted into a posterior over functions once we have seen some data. \n\nIt turns out that, in the regression setting, all these computations can be done in closed form, in $O(N^3)$ time. (We discuss faster approximations in Section \\ref{sec:Approximation-methods-for-large-datasets}.) In the classification setting, we must use approximations, such as the Gaussian approximation, since the posterior is no longer exactly Gaussian.\n\nGPs can be thought of as a Bayesian alternative to the kernel methods we discussed in Chapter \\ref{chap:Kernels}, including L1VM, RVM and SVM.\n\n\n\\section{GPs for regression}\nLet the prior on the regression function be a GP, denoted by\n\\begin{equation}\nf(\\vec{x}) \\sim GP(m(\\vec{x}),\\kappa(\\vec{x},\\vec{x}'))\n\\end{equation}\nwhere $m(\\vec{x}$ is the mean function and $\\kappa(\\vec{x},\\vec{x}')$ is the kernel or covariance function, i.e.,\n\\begin{align}\nm(\\vec{x} & = \\mathbb{E}[f(\\vec{x})] \\\\\n\\kappa(\\vec{x},\\vec{x}') & = \\mathbb{E}[(f(\\vec{x})-m(\\vec{x}))(f(\\vec{x})-m(\\vec{x}))^T]\n\\end{align}\nwhere $\\kappa$ is a positive definite kernel.\n\n\n\\section{GPs meet GLMs}\n\n\n\\section{Connection with other methods}\n\n\n\\section{GP latent variable model}\n\n\n\\section{Approximation methods for large datasets}\n\\label{sec:Approximation-methods-for-large-datasets}\n\n\n"
  },
  {
    "path": "chapterGenerativeModels.tex",
    "content": "\\chapter{Generative models for discrete data}\n\n\\section{Generative classifier}\n\\begin{equation}\\label{eqn:Generative-classifier}\np(y=c|\\vec{x},\\vec{\\theta})=\\dfrac{p(y=c|\\vec{\\theta})p(\\vec{x}|y=c,\\vec{\\theta})}{\\sum_{c'}{p(y=c'|\\vec{\\theta})p(\\vec{x}|y=c',\\vec{\\theta})}}\n\\end{equation}\n\nThis is called a \\textbf{generative classifier}, since it specifies how to generate the data using the \\textbf{class conditional density} $p(\\vec{x}|y=c)$ and the class prior $p(y=c)$. An alternative approach is to directly fit the class posterior, $p(y=c|\\vec{x})$ ;this is known as a \\textbf{discriminative classifier}. \n\n\n\\section{Bayesian concept learning}\nPsychological research has shown that people can learn concepts from positive examples alone (Xu and Tenenbaum 2007).\n\nWe can think of learning the meaning of a word as equivalent to \\textbf{concept learning}, which in turn is equivalent to binary classification. To see this, define $f(\\vec{x})=1$ if x is an example of the concept $C$, and $f(\\vec{x})=0$ otherwise. Then the goal is to learn the indicator function $f$, which just defines which elements are in the set $C$.\n\n\n\\subsection{Likelihood}\n\\begin{equation}\np(\\mathcal{D}|h) \\triangleq \\left(\\dfrac{1}{\\text{size}(h)}\\right)^N=\\left(\\dfrac{1}{|h|}\\right)^N\n\\end{equation}\n\nThis crucial equation embodies what Tenenbaum calls the \\textbf{size principle}, which means the model favours the simplest (smallest) hypothesis consistent with the data. This is more commonly known as \\textbf{Occam’s razor}\\footnote{\\url{http://en.wikipedia.org/wiki/Occam\\%27s_razor}}.\n\n\n\\subsection{Prior}\nThe prior is decided by human, not machines, so it is subjective. The subjectivity of the prior is controversial. For example, that a child and a math professor will reach different answers. In fact, they presumably not only have different priors, but also different hypothesis spaces. However, we can finesse that by defining the hypothesis space of the child and the math professor to be the same, and then setting the child’s prior weight to be zero on certain “advanced” concepts. Thus there is no sharp distinction between the prior and the hypothesis space.\n\nHowever, the prior is the mechanism by which background knowledge can be brought to bear on a problem. Without this, rapid learning (i.e., from small samples sizes) is impossible.\n\n\n\\subsection{Posterior}\nThe posterior is simply the likelihood times the prior, normalized.\n\\begin{equation}\np(h|\\mathcal{D}) \\triangleq \\dfrac{p(\\mathcal{D}|h)p(h)}{\\sum_{h' \\in \\mathcal{H}}p(\\mathcal{D}|h')p(h')}=\\dfrac{\\mathbb{I}(\\mathcal{D} \\in h)p(h)}{\\sum_{h' \\in \\mathcal{H}}\\mathbb{I}(\\mathcal{D} \\in h')p(h')}\n\\end{equation}\nwhere $\\mathbb{I}(\\mathcal{D} \\in h)p(h)$ is 1 \\textbf{iff}(iff and only if) all the data are in the extension of the hypothesis $h$.\n\nIn general, when we have enough data, the posterior $p(h|\\mathcal{D})$ becomes peaked on a single concept, namely the MAP estimate, i.e.,\n\\begin{equation}\np(h|\\mathcal{D}) \\rightarrow \\hat{h}^{MAP}\n\\end{equation}\nwhere $\\hat{h}^{MAP}$ is the posterior mode,\n\\begin{equation}\\begin{split}\n\\hat{h}^{MAP} & \\triangleq \\arg\\max\\limits_h p(h|\\mathcal{D})=\\arg\\max\\limits_h p(\\mathcal{D}|h)p(h) \\\\\n    & =\\arg\\max\\limits_h [\\log p(\\mathcal{D}|h) + \\log p(h)]\n\\end{split}\\end{equation}\n\nSince the likelihood term depends exponentially on $N$, and the prior stays constant, as we get more and more data, the MAP estimate converges towards the \\textbf{maximum likelihood estimate} or \\textbf{MLE}:\n\\begin{equation}\n\\hat{h}^{MLE} \\triangleq \\arg\\max\\limits_h p(\\mathcal{D}|h)=\\arg\\max\\limits_h \\log p(\\mathcal{D}|h)\n\\end{equation}\n\nIn other words, if we have enough data, we see that the \\textbf{data overwhelms the prior}.\n\n\n\\subsection{Posterior predictive distribution}\nThe concept of \\textbf{posterior predictive distribution}\\footnote{\\url{http://en.wikipedia.org/wiki/Posterior_predictive_distribution}} is normally used in a Bayesian context, where it makes use of the entire posterior distribution of the parameters given the observed data to yield a probability distribution over an interval rather than simply a point estimate. \n\\begin{equation}\np(\\tilde{\\vec{x}}|\\mathcal{D}) \\triangleq \\mathbb{E}_{h|\\mathcal{D}}[p(\\tilde{\\vec{x}}|h)] = \\begin{cases}\n\\sum_h p(\\tilde{\\vec{x}}|h)p(h|\\mathcal{D}) \\\\\n\\int p(\\tilde{\\vec{x}}|h)p(h|\\mathcal{D})\\mathrm{d}h\n\\end{cases}\n\\end{equation}\n\nThis is just a weighted average of the predictions of each individual hypothesis and is called \\textbf{Bayes model averaging}(Hoeting et al. 1999). \n\n\n\\section{The beta-binomial model}\n\n\n\\subsection{Likelihood}\nGiven $X \\sim \\text{Bin}(\\theta)$, the likelihood of $\\mathcal{D}$ is given by\n\\begin{equation}\np(\\mathcal{D}|\\theta)= \\text{Bin}(N_1|N,\\theta)\n\\end{equation}\n\n\n\\subsection{Prior}\n\\begin{equation}\n\\text{Beta}(\\theta|a,b) \\propto \\theta^{a-1}(1-\\theta)^{b-1}\n\\end{equation}\n\nThe parameters of the prior are called \\textbf{hyper-parameters}.\n\n\n\\subsection{Posterior}\n\\begin{equation}\\begin{split}\\label{eqn:beta-binomial-posterior}\np(\\theta|\\mathcal{D}) & \\propto \\text{Bin}(N_1|N_1+N_0,\\theta)\\text{Beta}(\\theta|a,b) \\\\\n    & =\\text{Beta}(\\theta|N_1+a,N_0b)\n\\end{split}\\end{equation}\n\nNote that updating the posterior sequentially is equivalent to updating in a single batch. To see this, suppose we have two data sets $\\mathcal{D}_a$ and $\\mathcal{D}_b$ with sufficient statistics $N_1^a,N_0^a$ and $N_1^b,N_0^b$. Let $N_1=N_1^a+N_1^b$ and $N_0=N_0^a+N_0^b$ be the sufficient statistics of the combined datasets. In batch mode we have\n\\begin{align*}\np(\\theta|\\mathcal{D}_a,\\mathcal{D}_b)& = p(\\theta,\\mathcal{D}_b|\\mathcal{D}_a)p(\\mathcal{D}_a) \\\\\n               &\\propto p(\\theta,\\mathcal{D}_b|\\mathcal{D}_a) \\\\\n               & = p(\\mathcal{D}_b,\\theta|\\mathcal{D}_a) \\\\\n\t\t\t   & = p(\\mathcal{D}_b|\\theta)p(\\theta|\\mathcal{D}_a) \\\\\n\t\t\t   & \\text{Combine Equation \\ref{eqn:beta-binomial-posterior} and \\ref{eqn:binomial-pmf}} \\\\\n\t\t\t   & =\\text{Bin}(N_1^b|\\theta, N_1^b+N_0^b)\\text{Beta}(\\theta|N_1^a+a,N_0^a+b) \\\\\n\t\t\t   & =\\text{Beta}(\\theta|N_1^a+N_1^b+a,N_0^a+N_0^b+b)\n\\end{align*}\n\nThis makes Bayesian inference particularly well-suited to \\textbf{online learning}, as we will see later.\n\n\\subsubsection{Posterior mean and mode}\n\\label{sec:beta-binomial-Posterior-mean-and-mode}\nFrom Table \\ref{tab:beta-distribution}, the posterior mean is given by\n\\begin{equation}\n\\bar{\\theta}=\\dfrac{a+N_1}{a+b+N}\n\\end{equation}\n\nThe mode is given by\n\\begin{equation}\n\\hat{\\theta}_{MAP}=\\dfrac{a+N_1-1}{a+b+N-2}\n\\end{equation}\n\nIf we use a uniform prior, then the MAP estimate reduces to the MLE,\n\\begin{equation}\n\\hat{\\theta}_{MLE}=\\dfrac{N_1}{N}\n\\end{equation}\n\nWe will now show that the posterior mean is convex combination of the prior mean and the MLE, which captures the notion that the posterior is a compromise between what we previously believed and what the data is telling us.\n\n\\subsubsection{Posterior variance}\nThe mean and mode are point estimates, but it is useful to know how much we can trust them. The variance of the posterior is one way to measure this. The variance of the Beta posterior is given by\n\\begin{equation}\n\\text{var}(\\theta|\\mathcal{D})=\\dfrac{(a+N_1)(b+N_0)}{(a+N_1+b+N_0)^2(a+N_1+b+N_0+1)}\n\\end{equation}\n\nWe can simplify this formidable expression in the case that $N \\gg a, b$, to get\n\\begin{equation}\n\\text{var}(\\theta|\\mathcal{D}) \\approx \\dfrac{N_1N_0}{NNN}=\\dfrac{\\hat{\\theta}_{MLE}(1-\\hat{\\theta}_{MLE})}{N}\n\\end{equation}\n\n\n\\subsection{Posterior predictive distribution}\nSo far, we have been focusing on inference of the unknown parameter(s). Let us now turn our attention to prediction of future observable data.\n\nConsider predicting the probability of heads in a single future trial under a Beta$(a, b)$posterior. We have\n\\begin{align}\np(\\tilde{x}|\\mathcal{D})& =\\int_0^1 p(\\tilde{x}|\\theta)p(\\theta|\\mathcal{D})\\mathrm{d}\\theta \\nonumber \\\\\n                        & =\\int_0^1 \\theta\\text{Beta}(\\theta|a,b)\\mathrm{d}\\theta \\nonumber \\\\\n\t\t\t\t\t\t& =\\mathbb{E}[\\theta|\\mathcal{D}]=\\dfrac{a}{a+b}\n\\end{align}\n\n\\subsubsection{Overfitting and the black swan paradox}\nLet us now derive a simple Bayesian solution to the problem. We will use a uniform prior, so $a=b=1$. In this case, plugging in the posterior mean gives \\textbf{Laplace’s rule of succession}\n\\begin{equation}\np(\\tilde{x}|\\mathcal{D})=\\dfrac{N_1+1}{N_0+N_1+1}\n\\end{equation}\n\nThis justifies the common practice of adding 1 to the empirical counts, normalizing and then plugging them in, a technique known as \\textbf{add-one smoothing}. (Note that plugging in the MAP parameters would not have this smoothing effect, since the mode becomes the MLE if $a=b=1$, see Section \\ref{sec:beta-binomial-Posterior-mean-and-mode}.)\n\n\\subsubsection{Predicting the outcome of multiple future trials}\nSuppose now we were interested in predicting the number of heads, $\\tilde{x}$, in $M$ future trials. This is given by\n\\begin{align}\np(\\tilde{x}|\\mathcal{D})& =\\int_0^1 \\text{Bin}(\\tilde{x}|M,\\theta)\\text{Beta}(\\theta|a,b)\\mathrm{d}\\theta \\\\\n                        & =\\dbinom{M}{\\tilde{x}}\\dfrac{1}{B(a,b)}\\int_0^1 \\theta^{\\tilde{x}}(1-\\theta)^{M-\\tilde{x}}\\theta^{a-1}(1-\\theta)^{b-1}\\mathrm{d}\\theta\n\\end{align}\n\nWe recognize the integral as the normalization constant for a Beta$(a+\\tilde{x}, M−\\tilde{x}+b)$ distribution. Hence\n\\begin{equation}\n\\int_0^1 \\theta^{\\tilde{x}}(1-\\theta)^{M-\\tilde{x}}\\theta^{a-1}(1-\\theta)^{b-1}\\mathrm{d}\\theta=B(\\tilde{x}+a,M-\\tilde{x}+b)\n\\end{equation}\n\nThus we find that the posterior predictive is given by the following, known as the (compound) \\textbf{beta-binomial distribution}:\n\\begin{equation}\nBb(x|a,b,M) \\triangleq \\dbinom{M}{x}\\dfrac{B(x+a,M-x+b)}{B(a,b)}\n\\end{equation}\n\nThis distribution has the following mean and variance\n\\begin{equation}\n\\text{mean}=M\\dfrac{a}{a+b} \\text{ , var}=\\dfrac{Mab}{(a+b)^2}\\dfrac{a+b+M}{a+b+1}\n\\end{equation}\n\nThis process is illustrated in Figure \\ref{fig:beta-binomial-distribution}. We start with a Beta$(2,2)$ prior, and plot the posterior predictive density after seeing $N_1 =3$ heads and $N_0 =17$ tails. Figure \\ref{fig:beta-binomial-distribution}(b) plots a plug-in approximation using a MAP estimate. We see that the Bayesian prediction has longer tails, spreading its probability mass more widely, and is therefore less prone to overfitting and blackswan type paradoxes.\n\n\\begin{figure}[hbtp]\n\\centering\n\\subfloat[]{\\includegraphics[scale=.60]{beta-binomial-distribution-a.png}} \\\\\n\\subfloat[]{\\includegraphics[scale=.60]{beta-binomial-distribution-b.png}}\n\\caption{(a) Posterior predictive distributions after seeing $N_1=3,N_0=17$. (b) MAP estimation.}\n\\label{fig:beta-binomial-distribution} \n\\end{figure}\n\n\n\\section{The Dirichlet-multinomial model}\nIn the previous section, we discussed how to infer the probability that a coin comes up heads. In this section, we generalize these results to infer the probability that a dice with $K$ sides comes up as face $k$. \n\n\n\\subsection{Likelihood}\nSuppose we observe $N$ dice rolls, $\\mathcal{D}=\\{x_1,x_2,\\cdots,x_N\\}$, where $x_i \\in \\{1,2,\\cdots,K\\}$. The likelihood has the form\n\\begin{equation}\np(\\mathcal{D}|\\vec{\\theta}) = \\dbinom{N}{N_1 \\cdots N_k} \\prod\\limits_{k=1}^K\\theta_k^{N_k} \\quad \\text{where } N_k=\\sum\\limits_{i=1}^N \\mathbb{I}(y_i=k)\n\\end{equation}\nalmost the same as Equation \\ref{eqn:multinomial-pmf}.\n\n\n\\subsection{Prior}\n\\begin{equation}\n\\text{Dir}(\\vec{\\theta}|\\vec{\\alpha}) = \\dfrac{1}{B(\\vec{\\alpha})}\\prod\\limits_{k=1}^K \\theta_k^{\\alpha_k-1}\\mathbb{I}(\\vec{\\theta} \\in S_K)\n\\end{equation}\n\n\n\\subsection{Posterior}\n\\begin{align}\np(\\vec{\\theta}|\\mathcal{D})& \\propto p(\\mathcal{D}|\\vec{\\theta})p(\\vec{\\theta}) \\\\\n     & \\propto \\prod\\limits_{k=1}^K\\theta_k^{N_k}\\theta_k^{\\alpha_k-1} = \\prod\\limits_{k=1}^K\\theta_k^{N_k+\\alpha_k-1}\\\\\n\t & =\\text{Dir}(\\vec{\\theta}|\\alpha_1+N_1,\\cdots,\\alpha_K+N_K)\n\\end{align}\n\nFrom Equation \\ref{eqn:Dirichlet-properties}, the MAP estimate is given by\n\\begin{equation}\\label{eqn:Dir-MAP}\n\\hat{\\theta}_k=\\dfrac{N_k+\\alpha_k-1}{N+\\alpha_0-K}\n\\end{equation}\n\nIf we use a uniform prior, $\\alpha_k=1$, we recover the MLE:\n\\begin{equation}\\label{eqn:Dirichlet-multinomial-posterior-MLE}\n\\hat{\\theta}_k=\\dfrac{N_k}{N}\n\\end{equation}\n\n\n\\subsection{Posterior predictive distribution}\nThe posterior predictive distribution for a single multinoulli trial is given by the following expression:\n\\begin{align}\np(X=j|\\mathcal{D})& =\\int p(X=j|\\vec{\\theta})p(\\vec{\\theta}|\\mathcal{D})\\mathrm{d}\\vec{\\theta} \\\\\n    & =\\int p(X=j|\\theta_j)\\left[\\int p(\\vec{\\theta}_{-j}, \\theta_j|\\mathcal{D})\\mathrm{d}\\vec{\\theta}_{-j}\\right]\\mathrm{d}\\theta_j \\\\\n\t& =\\int \\theta_jp(\\theta_j|\\mathcal{D})\\mathrm{d}\\theta_j=\\mathbb{E}[\\theta_j|\\mathcal{D}]=\\dfrac{\\alpha_j+N_j}{\\alpha_0+N}\n\\end{align}\nwhere $\\vec{\\theta}_{-j}$ are all the components of \\vec{\\theta} except $\\theta_j$.\n\nThe above expression avoids the zero-count problem. In fact, this form of Bayesian smoothing is even more important in the multinomial case than the binary case, since the likelihood of data sparsity increases once we start partitioning the data into many categories.\n\n\n\\section{Naive Bayes classifiers}\n\\label{sec:NBC}\nAssume the features are \\textbf{conditionally independent} given the class label, then the class conditional density has the following form\n\\begin{equation}\np(\\vec{x}|y=c,\\vec{\\theta})=\\prod\\limits_{j=1}^D p(x_j|y=c,\\vec{\\theta}_{jc})\n\\end{equation}\n\nThe resulting model is called a \\textbf{naive Bayes classifier}(NBC).\n\nThe form of the class-conditional density depends on the type of each feature. We give some possibilities below:\n\\begin{itemize}\n\\item{In the case of real-valued features, we can use the Gaussian distribution: $p(\\vec{x}|y,\\vec{\\theta})=\\prod_{j=1}^D \\mathcal{N}(x_j|\\mu_{jc},\\sigma_{jc}^2)$, where $\\mu_{jc}$ is the mean of feature $j$ in objects of class $c$, and $\\sigma_{jc}^2$ is its variance.}\n\\item{In the case of binary features, $x_j \\in \\{0,1\\}$, we can use the Bernoulli distribution: $p(\\vec{x}|y,\\vec{\\theta})=\\prod_{j=1}^D \\text{Ber}(x_j|\\mu_{jc})$, where $\\mu_{jc}$ is the probability that feature $j$ occurs in class $c$. This is sometimes called the \\textbf{multivariate Bernoulli naive Bayes} model. We will see an application of this below.}\n\\item{In the case of categorical features, $x_j \\in \\{a_{j1},a_{j2},\\cdots, a_{jS_j}\\}$, we can use the multinoulli distribution: $p(\\vec{x}|y,\\vec{\\theta})=\\prod_{j=1}^D \\text{Cat}(x_j|\\vec{\\mu}_{jc})$, where $\\vec{\\mu}_{jc}$ is a histogram over the $K$ possible values for $x_j$ in class $c$.}\n\\end{itemize}\n\nObviously we can handle other kinds of features, or use different distributional assumptions. Also, it is easy to mix and match features of different types.\n\n\n\\subsection{Optimization}\n\\label{sec:NBC-Optimization}\nWe now discuss how to “train” a naive Bayes classifier. This usually means computing the MLE or the MAP estimate for the parameters. However, we will also discuss how to compute the full posterior, $p(\\vec{\\theta}|\\mathcal{D})$.\n\n\\subsubsection{MLE for NBC}\nThe probability for a single data case is given by\n\\begin{equation}\\begin{split}\np(\\vec{x}_i,y_i|\\vec{\\theta}) & =p(y_i|\\vec{\\pi})\\prod\\limits_j p(x_{ij}|\\vec{\\theta}_j) \\\\\n  & =\\prod\\limits_c \\pi_c^{\\mathbb{I}(y_i=c)} \\prod\\limits_j\\prod\\limits_c p(x_{ij}|\\vec{\\theta}_{jc})^{\\mathbb{I}(y_i=c)}\n\\end{split}\\end{equation}\n\nHence the log-likelihood is given by\n\\begin{equation}\np(\\mathcal{D}|\\vec{\\theta})=\\sum\\limits_{c=1}^C{N_c\\log\\pi_c}+ \\sum\\limits_{j=1}^D{\\sum\\limits_{c=1}^C{\\sum\\limits_{i:y_i=c}{\\log p(x_{ij}|\\vec{\\theta}_{jc})}}}\n\\end{equation}\nwhere $N_c \\triangleq \\sum\\limits_i \\mathbb{I}(y_i=c)$ is the number of feature vectors in class $c$.\n\nWe see that this expression decomposes into a series of terms, one concerning $\\vec{\\pi}$, and $DC$ terms containing the $\\theta_{jc}$’s. Hence we can optimize all these parameters separately.\n\nFrom Equation \\ref{eqn:Dirichlet-multinomial-posterior-MLE}, the MLE for the class prior is given by\n\\begin{equation}\n\\hat{\\pi}_c=\\dfrac{N_c}{N}\n\\end{equation}\n\nThe MLE for $\\theta_{jc}$’s depends on the type of distribution we choose to use for each feature. \n\nIn the case of binary features, $x_j \\in \\{0,1\\}$, $x_j|y=c \\sim \\text{Ber}(\\theta_{jc})$, hence\n\\begin{equation}\n\\hat{\\theta}_{jc}=\\dfrac{N_{jc}}{N_c}\n\\end{equation}\nwhere $N_{jc} \\triangleq \\sum\\limits_{i:y_i=c} \\mathbb{I}(y_i=c)$ is the number that feature $j$ occurs in class $c$.\n\nIn the case of categorical features, $x_j \\in \\{a_{j1},a_{j2},\\cdots, a_{jS_j}\\}$, $x_j|y=c \\sim \\text{Cat}(\\vec{\\theta}_{jc})$, hence\n\\begin{equation}\n\\hat{\\vec{\\theta}}_{jc}=(\\dfrac{N_{j1c}}{N_c},\\dfrac{N_{j2c}}{N_c}, \\cdots, \\dfrac{N_{jS_j}}{N_c})^T\n\\end{equation}\nwhere $N_{jkc} \\triangleq \\sum\\limits_{i=1}^N \\mathbb{I}(x_{ij}=a_{jk}, y_i=c)$ is the number that feature $x_j=a_{jk}$ occurs in class $c$.\n\n\n\\subsubsection{Bayesian naive Bayes}\n\\label{sec:Bayesian-naive-Bayes}\nUse a Dir$(\\vec{\\alpha})$ prior for $\\vec{\\pi}$.\n\nIn the case of binary features, use a Beta$(\\beta0,\\beta1)$ prior for each $\\theta_{jc}$; in the case of categorical features, use a Dir$(\\vec{\\alpha})$ prior for each  $\\vec{\\theta}_{jc}$. Often we just take $\\vec{\\alpha}=\\vec{1}$ and $\\vec{\\beta}=\\vec{1}$, corresponding to \\textbf{add-one} or \\textbf{Laplace smoothing}.\n\n\n\\subsection{Using the model for prediction}\nThe goal is to compute\n\\begin{equation}\\begin{split}\ny=f(\\vec{x}) & =\\arg\\max\\limits_{c}{P(y=c|\\vec{x},\\vec{\\theta})} \\\\\n   & =P(y=c|\\vec{\\theta})\\prod_{j=1}^D P(x_j|y=c,\\vec{\\theta})\n\\end{split}\\end{equation}\n\nWe can the estimate parameters using MLE or MAP, then the posterior predictive density is obtained by simply plugging in the parameters $\\bar{\\vec{\\theta}}$(MLE) or $\\hat{\\vec{\\theta}}$(MAP). \n\nOr we can use BMA, just integrate out the unknown parameters.\n\n\n\\subsection{The log-sum-exp trick}\nwhen using generative classifiers of any kind, computing the posterior over class labels using Equation \\ref{eqn:Generative-classifier} can fail due to \\textbf{numerical underflow}. The problem is that $p(\\vec{x}|y=c)$ is often a very small number, especially if \\vec{x} is a high-dimensional vector. This is because we require that $\\sum_{\\vec{x}}p(\\vec{x}|y)=1$, so the probability of observing any particular high-dimensional vector is small. The obvious solution is to take logs when applying Bayes rule, as follows:\n\\begin{equation}\n\\log p(y=c|\\vec{x},\\vec{\\theta})=b_c-\\log\\left(\\sum\\limits_{c'}e^{b_{c'}}\\right)\n\\end{equation}\nwhere $b_c \\triangleq \\log p(\\vec{x}|y=c,\\vec{\\theta})+\\log p(y=c|\\vec{\\theta})$.\n\nWe can factor out the largest term, and just represent the remaining numbers relative to that. For example,\n\\begin{equation}\\begin{split}\n\\log(e^{-120}+e^{-121}) & =\\log(e^{-120}(1+e^{-1})) \\\\\n   & =\\log(1+e^{-1})-120\n\\end{split}\\end{equation}\n\nIn general, we have\n\\begin{equation}\n\\sum\\limits_{c}e^{b_{c}}=\\log\\left[(\\sum e^{b_c-B})e^B\\right]=\\log\\left(\\sum e^{b_c-B}\\right)+B\n\\end{equation}\nwhere $B \\triangleq \\max\\{b_c\\}$.\n\nThis is called the \\textbf{log-sum-exp} trick, and is widely used. \n\n\n\\subsection{Feature selection using mutual information}\nSince an NBC is fitting a joint distribution over potentially many features, it can suffer from overfitting. In addition, the run-time cost is $O(D)$, which may be too high for some applications. \n\nOne common approach to tackling both of these problems is to perform \\textbf{feature selection}, to remove “irrelevant” features that do not help much with the classification problem. The simplest approach to feature selection is to evaluate the relevance of each feature separately, and then take the top K,whereKis chosen based on some tradeoff between accuracy and complexity. This approach is known as \\textbf{variable ranking}, \\textbf{filtering}, or \\textbf{screening}.\n\nOne way to measure relevance is to use mutual information (Section \\ref{sec:Mutual-information}) between feature $X_j$ and the class label $Y$\n\\begin{equation}\n\\mathbb{I}(X_j,Y)=\\sum\\limits_{x_j}{\\sum\\limits_{y}{p(x_j,y)\\log \\dfrac{p(x_j,y)}{p(x_j)p(y)}}}\n\\end{equation}\n\nIf the features are binary, it is easy to show that the MI can be computed as follows\n\\begin{equation}\n\\mathbb{I}_j = \\sum\\limits_c \\left[\\theta_{jc}\\pi_c\\log{\\dfrac{\\theta_{jc}}{\\theta_j}}+(1-\\theta_{jc})\\pi_c\\log{\\dfrac{1-\\theta_{jc}}{1-\\theta_j}}\\right]\n\\end{equation}\nwhere $\\pi_c=p(y=c)$, $\\theta_{jc}=p(x_j=1|y=c)$, and $\\theta_j=p(x_j=1)=\\sum_{c} \\pi_c\\theta_{jc}$.\n\n\n\\subsection{Classifying documents using bag of words}\n\\textbf{Document classification} is the problem of classifying text documents into different categories.\n\n\n\\subsubsection{Bernoulli product model}\nOne simple approach is to represent each document as a binary vector, which records whether each word is present or not, so $x_{ij} =1$ iff word $j$ occurs in document $i$, otherwise $x_{ij}=0$. We can then use the following class conditional density:\n\\begin{equation}\\begin{split}\np(\\vec{x}_i|y_i=c,\\vec{\\theta}) & =\\prod\\limits_{j=1}^D \\mathrm{Ber}(x_{ij}|\\theta_{jc}) \\\\\n  & =\\prod\\limits_{j=1}^D \\theta_{jc}^{x_{ij}}(1-\\theta_{jc})^{1-x_{ij}}\n\\end{split}\\end{equation}\n\nThis is called the \\textbf{Bernoulli product model}, or the \\textbf{binary independence model}.\n\n\\subsubsection{Multinomial document classifier}\nHowever, ignoring the number of times each word occurs in a document loses some information (McCallum and Nigam 1998). A more accurate representation counts the number of occurrences of each word. Specifically, let $\\vec{x}_i$ be a vector of counts for document $i$, so $x_{ij} \\in \\{0,1,\\cdots,N_i\\}$, where $N_i$ is the number of terms in document $i$(so $\\sum\\limits_{j=1}^D x_{ij}=N_i$). For the class conditional densities, we can use a multinomial distribution:\n\\begin{equation}\\label{eqn:Multinomial-document-classifier}\np(\\vec{x}_i|y_i=c,\\vec{\\theta})=\\text{Mu}(\\vec{x}_i|N_i,\\vec{\\theta}_c)=\\dfrac{N_i!}{\\prod_{j=1}^D x_{ij}!}\\prod\\limits_{j=1}^D \\theta_{jc}^{x_{ij}}\n\\end{equation}\nwhere we have implicitly assumed that the document length $N_i$ is independent of the class. Here $θ_{jc}$ is the probability of generating word $j$ in documents of class $c$; these parameters satisfy the constraint that $\\sum_{j=1}^D \\theta_{jc}=1$ for each class c.\n\nAlthough the multinomial classifier is easy to train and easy to use at test time, it does not work particularly well for document classification. One reason for this is that it does not take into account the \\textbf{burstiness} of word usage. This refers to the phenomenon that most words never appear in any given document, but if they do appear once, they are likely to appear more than once, i.e., words occur in bursts.\n\nThe multinomial model cannot capture the burstiness phenomenon. To see why, note that Equation \\ref{eqn:Multinomial-document-classifier} has the form $\\theta_{jc}^{x_{ij}}$, and since $\\theta_{jc} \\ll 1$ for rare words, it becomes increasingly unlikely to generate many of them. For more frequent words, the decay rate is not as fast. To see why intuitively, note that the most frequent words are function words which are not specific to the class, such as “and”, “the”, and “but”; the chance of the word “and” occuring is pretty much the same no matter how many time it has previously occurred (modulo document length), so the independence assumption is more reasonable for common words. However, since rare words are the ones that matter most for classification purposes, these are the ones we want to model the most carefully.\n\n\\subsubsection{DCM model}\nVarious ad hoc heuristics have been proposed to improve the performance of the multinomial document classifier (Rennie et al. 2003). We now present an alternative class conditional density that performs as well as these ad hoc methods, yet is probabilistically sound (Madsen et al. 2005).\n\nSuppose we simply replace the multinomial class conditional density with the \\textbf{Dirichlet Compound Multinomial} or \\textbf{DCM} density, defined as follows:\n\\begin{equation}\\begin{split}\np(\\vec{x}_i|y_i=c,\\vec{\\alpha}) & =\\int \\text{Mu}(\\vec{x}_i|N_i,\\vec{\\theta}_c)\\text{Dir}(\\vec{\\theta}_c|\\vec{\\alpha}_c) \\\\\n   & =\\dfrac{N_i!}{\\prod_{j=1}^D x_{ij}!}\\prod\\limits_{j=1}^D\\dfrac{B(\\vec{x}_i+\\vec{\\alpha}_c)}{B(\\vec{\\alpha}_c)}\n\\end{split}\\end{equation}\n\n(This equation is derived in Equation TODO.) Surprisingly this simple change is all that is needed to capture the burstiness phenomenon. The intuitive reason for this is as follows: After seeing one occurence of a word, say wordj, the posterior counts on θj gets updated, making another occurence of wordjmore likely. By contrast, ifθj is fixed, then the occurences of each word are independent. The multinomial model corresponds to drawing a ball from an urn with Kcolors of ball, recording its color, and then replacing it. By contrast, the DCM model corresponds to drawing a ball, recording its color, and then replacing it with one additional copy; this is called the \\textbf{Polya urn}.\n\nUsing the DCM as the class conditional density gives much better results than using the multinomial, and has performance comparable to state of the art methods, as described in (Madsen et al. 2005). The only disadvantage is that fitting the DCM model is more complex; see (Minka 2000e; Elkan 2006) for the details.\n"
  },
  {
    "path": "chapterGraphicalModelStructureLearning.tex",
    "content": "\\chapter{Exact inference for graphical models}\n\n\n"
  },
  {
    "path": "chapterHMM.tex",
    "content": "\\chapter{Hidden markov Model}\n\n\n\\section{Introduction}\n\n\n\\section{Markov models}\n\\label{sec:Markov-models}\n\n"
  },
  {
    "path": "chapterIntroduction.tex",
    "content": "\\chapter{Introduction}\n\n\\section{Types of machine learning}\n\\begin{equation}\\nonumber\n\\begin{cases}\n\\text{Supervised learning} \\begin{cases} \\text{Classification} \\\\ \\text{Regression} \\end{cases}\\\\\n\\text{Unsupervised learning} \\begin{cases} \\text{Discovering clusters} \\\\ \\text{Discovering latent factors} \\\\ \\text{Discovering graph structure} \\\\ \\text{Matrix completion} \\end{cases}\\\\\n\\end{cases}\n\\end{equation}\n\n\n\\section{Three elements of a machine learning model}\n\n\\textbf{Model = Representation + Evaluation + Optimization}\\footnote{Domingos, P. A few useful things to know about machine learning. Commun. ACM. 55(10):78–87 (2012).}\n\n\n\\subsection{Representation}\nIn supervised learning, a model must be represented as a conditional probability distribution $P(y|\\vec{x})$(usually we call it classifier) or a decision function $f(x)$. The set of classifiers(or decision functions) is called the hypothesis space of the model. Choosing a representation for a model is tantamount to choosing the hypothesis space that it can possibly learn. \n\n\n\\subsection{Evaluation}\nIn the hypothesis space, an evaluation function (also called objective function or risk function) is needed to distinguish good classifiers(or decision functions) from bad ones.\n\n\n\\subsubsection{Loss function and risk function}\n\\label{sec:Loss-function-and-risk-function}\n\n\\begin{definition}\nIn order to measure how well a function fits the training data, a \\textbf{loss function} $L:Y \\times Y \\rightarrow R \\geq 0$ is defined. For training example $(x_i,y_i)$, the loss of predicting the value $\\widehat{y}$ is $L(y_i,\\widehat{y})$.\n\\end{definition}\n\nThe following is some common loss functions:\n\\begin{enumerate}\n\\item 0-1 loss function \\\\ $L(Y,f(X))=\\mathbb{I}(Y,f(X))=\\begin{cases} 1, & Y=f(X) \\\\ 0, & Y \\neq f(X) \\end{cases}$\n\\item Quadratic loss function $L(Y,f(X))=\\left(Y-f(X)\\right)^2$\n\\item Absolute loss function $L(Y,f(X))=\\abs{Y-f(X)}$\n\\item Logarithmic loss function \\\\ $L(Y,P(Y|X))=-\\log{P(Y|X)}$\n\\end{enumerate}\n\n\\begin{definition}\nThe risk of function $f$ is defined as the expected loss of $f$:\n\\begin{equation}\\label{eqn:expected-loss}\nR_{\\mathrm{exp}}(f)=E\\left[L\\left(Y,f(X)\\right)\\right]=\\int L\\left(y,f(x)\\right)P(x,y)\\mathrm{d}x\\mathrm{d}y\n\\end{equation}\nwhich is also called expected loss or \\textbf{risk function}.\n\\end{definition}\n\n\\begin{definition}\nThe risk function $R_{\\mathrm{exp}}(f)$ can be estimated from the training data as\n\\begin{equation}\nR_{\\mathrm{emp}}(f)=\\dfrac{1}{N}\\sum\\limits_{i=1}^{N} L\\left(y_i,f(x_i)\\right)\n\\end{equation}\nwhich is also called empirical loss or \\textbf{empirical risk}.\n\\end{definition}\n\nYou can define your own loss function, but if you're a novice, you're probably better off using one from the literature. There are conditions that loss functions should meet\\footnote{\\url{http://t.cn/zTrDxLO}}:\n\\begin{enumerate}\n\\item They should approximate the actual loss you're trying to minimize. As was said in the other answer, the standard loss functions for classification is zero-one-loss (misclassification rate) and the ones used for training classifiers are approximations of that loss.\n\\item The loss function should work with your intended optimization algorithm. That's why zero-one-loss is not used directly: it doesn't work with gradient-based optimization methods since it doesn't have a well-defined gradient (or even a subgradient, like the hinge loss for SVMs has).\n\nThe main algorithm that optimizes the zero-one-loss directly is the old perceptron algorithm(chapter \\S \\ref{chap:Perceptron}).\n\\end{enumerate}\n\n\n\\subsubsection{ERM and SRM}\n\\begin{definition}\nERM(Empirical risk minimization)\n\\begin{equation}\n\\min\\limits _{f \\in \\mathcal{F}} R_{\\mathrm{emp}}(f)=\\min\\limits _{f \\in \\mathcal{F}} \\dfrac{1}{N}\\sum\\limits_{i=1}^{N} L\\left(y_i,f(x_i)\\right)\n\\end{equation}\n\\end{definition}\n\n\\begin{definition}\nStructural risk\n\\begin{equation}\nR_{\\mathrm{smp}}(f)=\\dfrac{1}{N}\\sum\\limits_{i=1}^{N} L\\left(y_i,f(x_i)\\right) +\\lambda J(f)\n\\end{equation}\n\\end{definition}\n\n\\begin{definition}\nSRM(Structural risk minimization)\n\\begin{equation}\n\\min\\limits _{f \\in \\mathcal{F}} R_{\\mathrm{srm}}(f)=\\min\\limits _{f \\in \\mathcal{F}} \\dfrac{1}{N}\\sum\\limits_{i=1}^{N} L\\left(y_i,f(x_i)\\right) +\\lambda J(f)\n\\end{equation}\n\\end{definition}\n\n\n\\subsection{Optimization}\nFinally, we need a \\textbf{training algorithm}(also called \\textbf{learning algorithm}) to search among the classifiers in the the hypothesis space for the highest-scoring one. The choice of optimization technique is key to the \\textbf{efficiency} of the model.\n\n\n\\section{Some basic concepts}\n\n\n\\subsection{Parametric vs non-parametric models}\n\n\n\\subsection{A simple non-parametric classifier: K-nearest neighbours}\n\n\\subsubsection{Representation}\n\\begin{equation}\ny=f(\\vec{x})=\\arg\\min_{c}{\\sum\\limits_{\\vec{x}_i \\in N_k(\\vec{x})} \\mathbb{I}(y_i=c)}\n\\end{equation}\nwhere $N_k(\\vec{x})$ is the set of k points that are closest to point $\\vec{x}$.\n\nUsually use \\textbf{k-d tree} to accelerate the process of finding k nearest points.\n\n\\subsubsection{Evaluation}\nNo training is needed.\n\n\\subsubsection{Optimization}\nNo training is needed.\n\n\n\\subsection{Overfitting}\n\n\n\\subsection{Cross validation}\n\\label{sec:Cross-validation}\n\\begin{definition}\n\\textbf{Cross validation}, sometimes called \\emph{rotation estimation}, is a \\emph{model validation} technique for assessing how the results of a statistical analysis will generalize to an independent data set\\footnote{\\url{http://en.wikipedia.org/wiki/Cross-validation_(statistics)}}.\n\\end{definition}\n\nCommon types of cross-validation:\n\\begin{enumerate}\n\\item K-fold cross-validation. In k-fold cross-validation, the original sample is randomly partitioned into k equal size subsamples. Of the k subsamples, a single subsample is retained as the validation data for testing the model, and the remaining k − 1 subsamples are used as training data.\n\\item 2-fold cross-validation. Also, called simple cross-validation or holdout method. This is the simplest variation of k-fold cross-validation, k=2.\n\\item Leave-one-out cross-validation(\\emph{LOOCV}). k=M, the number of original samples.\n\\end{enumerate}\n\n\n\\subsection{Model selection}\nWhen we have a variety of models of different complexity (e.g., linear or logistic regression models with different degree polynomials, or KNN classifiers with different values ofK), how should we pick the right one? A natural approach is to compute the \\textbf{misclassification rate} on the training set for each method.\n\n\n"
  },
  {
    "path": "chapterKernels.tex",
    "content": "\\chapter{Kernels}\n\\label{chap:Kernels}\n\n\\section{Introduction}\nSo far in this book, we have been assuming that each object that we wish to classify or cluster or process in anyway can be represented as a fixed-size feature vector, typically of the form $\\vec{x}_i \\in \\mathbb{R}^D$. However, for certain kinds of objects, it is not clear how to best represent them as fixed-sized feature vectors. For example, how do we represent a text document or protein sequence, which can be of variable length? or a molecular structure, which has complex 3d geometry? or an evolutionary tree, which has variable size and shape?\n\nOne approach to such problems is to define a generative model for the data, and use the inferred latent representation and/or the parameters of the model as features, and then to plug these features in to standard methods. For example, in Chapter 28 TODO, we discuss deep learning, which is essentially an unsupervised way to learn good feature representations.\n\nAnother approach is to assume that we have some way of measuring the similarity between objects, that doesn’t require preprocessing them into feature vector format. For example, when comparing strings, we can compute the edit distance between them. Let $\\kappa(\\vec{x},\\vec{x}') \\geq 0$ be some measure of similarity between objects $\\kappa(\\vec{x},\\vec{x}') \\in \\mathcal{X}$,  we will call $\\kappa$ a \\textbf{kernel function}. Note that the word “kernel” has several meanings; we will discuss a different interpretation in Section 14.7.1 TODO.\n\nIn this chapter, we will discuss several kinds of kernel functions. We then describe some algorithms that can be written purely in terms of kernel function computations. Such methods can be used when we don’t have access to (or choose not to look at) the “inside” of the objects $\\vec{x}$ that we are processing.\n\n\n\\section{Kernel functions}\n\\begin{definition}\nA \\textbf{kernel function}\\footnote{\\url{http://en.wikipedia.org/wiki/Kernel_function}} is a real-valued function of two arguments, $\\kappa(\\vec{x},\\vec{x}') \\in \\mathbb{R}$. Typically the function is symmetric (i.e., $\\kappa(\\vec{x},\\vec{x}')=\\kappa(\\vec{x}',\\vec{x})$, and non-negative (i.e., $\\kappa(\\vec{x},\\vec{x}') \\geq 0$). \n\\end{definition}\n\nWe give several examples below.\n\n\\subsection{RBF kernels}\nThe \\textbf{Gaussian kernel} or \\textbf{squared exponential kernel}(SE kernel) is defined by\n\\begin{equation}\n\\kappa(\\vec{x},\\vec{x}')=\\exp\\left(-\\frac{1}{2}(\\vec{x}-\\vec{x}')^T\\vec{\\Sigma}^{-1}(\\vec{x}-\\vec{x}')\\right)\n\\end{equation}\n\nIf $\\vec{\\Sigma}$ is diagonal, this can be written as\n\\begin{equation}\n\\kappa(\\vec{x},\\vec{x}')=\\exp\\left(-\\frac{1}{2}\\sum\\limits_{j=1}^D \\frac{1}{\\sigma_j^2}(x_j-x_j')^2\\right)\n\\end{equation}\n\nWe can interpret the $\\sigma_j$ as defining the \\textbf{characteristic length scale} of dimension $j$.If $\\sigma_j = \\infty$, the corresponding dimension is ignored; hence this is known as the \\textbf{ARD kernel}. If $\\vec{\\Sigma}$ is spherical, we get the isotropic kernel\n\\begin{equation}\\label{eqn:RBF-kernel}\n\\kappa(\\vec{x},\\vec{x}')=\\exp\\left(-\\frac{\\lVert\\vec{x}-\\vec{x}'\\rVert^2}{2\\sigma^2}\\right)\n\\end{equation}\n\nHere $\\sigma^2$ is known as the \\textbf{bandwidth}. Equation \\ref{eqn:RBF-kernel} is an example of a \\textbf{radial basis function} or \\textbf{RBF} kernel, since it is only a function of $\\lVert\\vec{x}-\\vec{x}'\\rVert^2$.\n\n\n\\subsection{TF-IDF kernels}\n\\begin{equation}\\label{eqn:RBF-kernel}\n\\kappa(\\vec{x},\\vec{x}')=\\frac{\\phi(\\vec{x})^T\\phi(\\vec{x}')}{\\lVert\\phi(vec{x})\\rVert_2\\lVert\\phi(\\vec{x}')\\rVert_2}\n\\end{equation}\nwhere $\\phi(\\vec{x})=\\text{tf-idf}(\\vec{x})$.\n\n\\subsection{Mercer (positive definite) kernels}\n\\label{sec:Mercer-kernels}\nIf the kernel function satisfies the requirement that the \\textbf{Gram matrix}, defined by\n\\begin{equation}\n\\vec{K} \\triangleq \\left(\\begin{array}{ccc}\n\\kappa(\\vec{x}_1,\\vec{x}_2) & \\cdots \\kappa(\\vec{x}_1,\\vec{x}_N) \\\\\n\\vdots & \\vdots & \\vdots \\\\\n\\kappa(\\vec{x}_N,\\vec{x}_1) & \\cdots \\kappa(\\vec{x}_N,\\vec{x}_N) \n\\end{array}\\right)\n\\end{equation}\nbe positive definite for any set of inputs $\\{\\vec{x}_i\\}_{i=1}^N$. We call such a kernel a \\textbf{Mercer kernel},or \\textbf{positive definite kernel}.\n\nIf the Gram matrix is positive definite, we can compute an eigenvector decomposition of it as follows\n\\begin{equation}\n\\vec{K}=\\vec{U}^T\\vec{\\Lambda}\\vec{U}\n\\end{equation}\n\nwhere $\\vec{\\Lambda}$ is a diagonal matrix of eigenvalues $\\lambda_i >0$. Now consider an element of $\\vec{K}$:\n\\begin{equation}\nk_{ij}=(\\vec{\\Lambda}^{\\frac{1}{2}}\\vec{U}_{:,i})^T(\\vec{\\Lambda}^{\\frac{1}{2}}\\vec{U}_{:,j})\n\\end{equation}\n\nLet us define $\\phi(\\vec{x}_i)=\\vec{\\Lambda}^{\\frac{1}{2}}\\vec{U}_{:,i}$, then we can write\n\\begin{equation}\nk_{ij}=\\phi(\\vec{x}_i)^T\\phi(\\vec{x}_j)\n\\end{equation}\n\nThus we see that the entries in the kernel matrix can be computed by performing an inner product of some feature vectors that are implicitly defined by the eigenvectors $\\vec{U}$. In general, if the kernel is Mercer, then there exists a function $\\phi$ mapping $\\vec{x} \\in \\mathcal{X}$ to $\\mathbb{R}^D$ such that\n\\begin{equation}\n\\kappa(\\vec{x},\\vec{x}')=\\phi(\\vec{x})^T\\phi(\\vec{x}')\n\\end{equation}\nwhere $\\phi$ depends on the eigen functions of $\\kappa$(so $D$ is a potentially infinite dimensional space).\n\nFor example, consider the (non-stationary) \\textbf{polynomial kernel} $\\kappa(\\vec{x},\\vec{x}')=(\\gamma \\vec{x}\\vec{x}'+r)^M$, where $r>0$. One can show that the corresponding feature vector $\\phi(\\vec{x})$ will contain all terms up to degree $M$. For example, if $M=2, \\gamma=r=1$ and $\\vec{x}, \\vec{x}' \\in \\mathbb{R}^2$, we have\n\\begin{align*}\n(\\vec{x}\\vec{x}'+1)^2 & =(1+x_1x_1'+x_2+x_2')^2 \\\\\n    & = 1+2x_1x_1'+2x_2x_2'+(x_1x_1')^2+(x_2x_2')^2x_1x_1'x_2x_2' \\\\\n\t& = \\phi(\\vec{x})^T\\phi(\\vec{x}') \\\\\n\\text{where } & \\phi(\\vec{x})=(1,\\sqrt{2}x_1,\\sqrt{2}x_2,x_1^2,x_2^2,\\sqrt{2}x_1x_2)\n\\end{align*}\n\nIn the case of a Gaussian kernel, the feature map lives in an infinite dimensional space. In such a case, it is clearly infeasible to explicitly represent the feature vectors.\n\nIn general, establishing that a kernel is a Mercer kernel is difficult, and requires techniques from functional analysis. However, one can show that it is possible to build up new Mercer kernels from simpler ones using a set of standard rules. For example, if $\\kappa_1$ and $\\kappa_2$ are both Mercer, so is $\\kappa(\\vec{x},\\vec{x}')=\\kappa_1(\\vec{x},\\vec{x}')+\\kappa_2(\\vec{x},\\vec{x}')=$. See e.g., (Schoelkopf and Smola 2002) for details.\n\n\n\\subsection{Linear kernels}\n\\begin{equation}\n\\kappa(\\vec{x},\\vec{x}')=\\vec{x}^T\\vec{x}'\n\\end{equation}\n\n\\subsection{Matern kernels}\nThe \\textbf{Matern kernel}, which is commonly used in Gaussian process regression (see Section 15.2), has the following form\n\\begin{equation}\n\\kappa(r)=\\frac{2^{1-\\nu}}{\\Gamma(\\nu)}\\left(\\frac{\\sqrt{2\\nu}r}{\\ell}\\right)^{\\nu}K_{\\nu}\\frac{\\sqrt{2\\nu}r}{\\ell}\n\\end{equation}\nwhere $r=\\lVert\\vec{x}-\\vec{x}'\\rVert$, $\\nu>0$, $\\ell>0$, and $K_{\\nu}$ is a modified Bessel function. As $\\nu \\rightarrow \\infty$, this approaches the SE kernel. If $\\nu=\\frac{1}{2}$, the kernel simplifies to\n\\begin{equation}\n\\kappa(r)=\\exp(-r/\\ell)\n\\end{equation}\n\nIf $D=1$, and we use this kernel to define a Gaussian process (see Chapter 15 TODO), we get the \\textbf{Ornstein-Uhlenbeck process}, which describes the velocity of a particle undergoing Brownian motion (the corresponding function is continuous but not differentiable, and hence is very “jagged”).\n\n\n\\subsection{String kernels}\n\\label{sec:String-kernels}\nNow let $\\phi_s(\\vec{x})$ denote the number of times that substrings appears in string $\\vec{x}$. We define the kernel between two strings $\\vec{x}$ and $\\vec{x}'$ as\n\\begin{equation}\n\\kappa(\\vec{x},\\vec{x}')=\\sum\\limits_{s \\in \\mathcal{A}^*} w_s\\phi_s(\\vec{x})\\phi_s(\\vec{x}')\n\\end{equation}\nwhere $w_s \\geq 0$ and $\\mathcal{A}^*$ is the set of all strings (of any length) from the alphabet $\\mathcal{A}$(this is known as the Kleene star operator). This is a Mercer kernel, and be computed in $O(|\\vec{x}|+|\\vec{x}'|)$ time (for certain settings of the weights $\\{ws\\}$) using suffix trees (Leslie et al. 2003; Vishwanathan and Smola 2003; Shawe-Taylor and Cristianini 2004).\n\nThere are various cases of interest. If we set $w_s =0$for $|s| >1$ we get a bag-of-characters kernel. This defines $\\phi(\\vec{x})$ to be the number of times each character in $\\mathcal{A}$ occurs in $\\vec{x}$.If we require $s$ to be bordered by white-space, we get a bag-of-words kernel, where $\\phi(\\vec{x})$ counts how many times each possible word occurs. Note that this is a very sparse vector, since most words will not be present. If we only consider strings of a fixed lengthk, we get the \\textbf{k-spectrum} kernel. This has been used to classify proteins into SCOP superfamilies (Leslie et al. 2003).\n\n\n\\subsection{Pyramid match kernels}\n% \\begin{figure}[hbtp]\n% \\centering\n%     \\includegraphics[scale=.70]{pyramid-match-kernel.png}\n% \\caption{Illustration of a pyramid match kernel computed from two images. Used with kind permission of Kristen Grauman.}\n% \\label{fig:pyramid-match-kernel}\n% \\end{figure}\n\n\n\\subsection{Kernels derived from probabilistic generative models}\nSuppose we have a probabilistic generative model of feature vectors, $p(\\vec{x}|\\vec{\\theta})$. Then there are several ways we can use this model to define kernel functions, and thereby make the model suitable for discriminative tasks. We sketch two approaches below.\n\n\n\\subsubsection{Probability product kernels}\n\\begin{equation}\\label{eqn:Probability-product-kernels}\n\\kappa(\\vec{x}_i,\\vec{x}_j)=\\int p(\\vec{x}|\\vec{x}_i)^{\\rho}p(\\vec{x}|\\vec{x}_j)^{\\rho}\\mathrm{d}\\vec{x}\n\\end{equation}\nwhere $\\rho>0$, and $p(\\vec{x}|\\vec{x}_i)$ is often approximated by $p(\\vec{x}|\\hat{\\vec{\\theta}}(\\vec{x}_i))$,where $\\hat{\\vec{\\theta}}(\\vec{x}_i)$ is a parameter estimate computed using a single data vector. This is called a \\textbf{probability product kernel}(Jebara et al. 2004).\n\nAlthough it seems strange to fit a model to a single data point, it is important to bear in mind that the fitted model is only being used to see how similar two objects are. In particular, if we fit the model to $\\vec{x}_i$ and then the model thinks $\\vec{x}_j$ is likely, this means that $\\vec{x}_i$ and $\\vec{x}_j$ are similar. For example, suppose $p(\\vec{x}|\\vec{\\theta}) \\sim \\mathcal{N}(\\vec{\\mu},\\sigma^2\\vec{I})$, where $\\sigma^2$ is fixed. If $\\rho=1$, and we use $\\hat{\\vec{\\mu}}(\\vec{x}_i)=\\vec{x}_i$ and $\\hat{\\vec{\\mu}}(\\vec{x}_j)=\\vec{x}_j$, we find (Jebara et al. 2004, p825) that\n\\begin{equation}\n\\kappa(\\vec{x}_i,\\vec{x}_j)=\\frac{1}{(4\\pi\\sigma^2)^{D/2}}\\exp\\left(-\\frac{1}{4\\sigma^2}\\lVert\\vec{x}_i-\\vec{x}_j\\rVert^2\\right)\n\\end{equation}\nwhich is (up to a constant factor) the RBF kernel.\n\nIt turns out that one can compute Equation \\ref{eqn:Probability-product-kernels} for a variety of generative models, including ones with latent variables, such as HMMs. This provides one way to define kernels on variable length sequences. Furthermore, this technique works even if the sequences are of real-valued vectors, unlike the string kernel in Section \\ref{sec:String-kernels}. See (Jebara et al. 2004) for further details\n\n\n\\subsubsection{Fisher kernels}\nA more efficient way to use generative models to define kernels is to use a \\textbf{Fisher kernel} (Jaakkola and Haussler 1998) which is defined as follows:\n\\begin{equation}\n\\kappa(\\vec{x}_i,\\vec{x}_j)=g(\\vec{x}_i)^T\\vec{F}^{-1}g(\\vec{x}_j)\n\\end{equation}\nwhere $g$ is the gradient of the log likelihood, or \\textbf{score vector}, evaluated at the MLE $\\hat{\\vec{\\theta}}$\n\\begin{equation}\ng(\\vec{x}) \\triangleq \\frac{\\mathrm{d}}{\\mathrm{d}\\vec{\\theta}}\\log p(\\vec{x}|\\vec{\\theta})|_{\\hat{\\vec{\\theta}}}\n\\end{equation}\nand $\\vec{F}$ is the Fisher information matrix, which is essentially the Hessian:\n\\begin{equation}\n\\vec{F} \\triangleq \\left[\\frac{\\partial^2}{\\partial \\theta_i \\partial \\theta_j}\\log p(\\vec{x}|\\vec{\\theta})\\right]|_{\\hat{\\vec{\\theta}}}\n\\end{equation}\n\nNote that $\\hat{\\vec{\\theta}}$ is a function of all the data, so the similarity of $\\vec{x}_i$ and $\\vec{x}_j$ is computed in the context of all the data as well. Also, note that we only have to fit one model.\n\n\n\\section{Using kernels inside GLMs}\n\n\n\\subsection{Kernel machines}\nWe define a \\textbf{kernel machine} to be a GLM where the input feature vector has the form\n\\begin{equation}\\label{eqn:kernel-machine}\n\\phi(\\vec{x})=(\\kappa(\\vec{x},\\vec{\\mu}_1),\\cdots,\\kappa(\\vec{x},\\vec{\\mu}_K))\n\\end{equation}\n\nwhere $\\vec{\\mu}_k \\in \\mathcal{X}$ are a set of $K$ centroids. If $\\kappa$ is an RBF kernel, this is called an \\textbf{RBF network}. We discuss ways to choose the $\\vec{\\mu}_k$ parameters below. We will call Equation \\ref{eqn:kernel-machine} a \\textbf{kernelised feature vector}. Note that in this approach, the kernel need not be a Mercer kernel.\n\nWe can use the kernelized feature vector for logistic regression by defining $p(y|\\vec{x},\\vec{\\theta})=\\mathrm{Ber}(y|\\vec{w}^T\\phi(\\vec{x}))$. This provides a simple way to define a non-linear decision boundary. For example, see Figure \\ref{fig:kenel-machine-xor}.\n\n\\begin{figure}[hbtp]\n\\centering\n\\subfloat[]{\\includegraphics[scale=.70]{kenel-machine-xor-a.png}} \\\\\n\\subfloat[]{\\includegraphics[scale=.70]{kenel-machine-xor-b.png}} \\\\\n\\subfloat[]{\\includegraphics[scale=.70]{kenel-machine-xor-c.png}}\n\\caption{(a) xor truth table. (b) Fitting a linear logistic regression classifier using degree 10 polynomial expansion. (c) Same model, but using an RBF kernel with centroids specified by the 4 black crosses.}\n\\label{fig:kenel-machine-xor} \n\\end{figure}\n\nWe can also use the kernelized feature vector inside a linear regression model by defining $p(y|\\vec{x},\\vec{\\theta})=\\mathcal{N}(y|\\vec{w}^T\\phi(\\vec{x}),\\sigma^2)$. \n\n\n\\subsection{L1VMs, RVMs, and other sparse vector machines}\n\\label{sec:sparse-kernel-machines}\nThe main issue with kernel machines is: how do we choose the centroids $\\vec{\\mu}_k$? We can use \\textbf{sparse vector machine}, \\textbf{L1VM}, \\textbf{L2VM}, \\textbf{RVM}, \\textbf{SVM}.\n\n% In Figure \\ref{fig:L2VM-L1VM-RVM-SVM-2d}, we compare L2VM, L1VM, RVM and an SVM using the same RBF kernel on a binary classification problem in 2d.\n\n% \\begin{figure}[hbtp]\n% \\centering\n% \\subfloat[]{\\includegraphics[scale=.50]{L2VM-L1VM-RVM-SVM-2d-a.png}} \\\\\n% \\subfloat[]{\\includegraphics[scale=.50]{L2VM-L1VM-RVM-SVM-2d-b.png}} \\\\\n% \\subfloat[]{\\includegraphics[scale=.50]{L2VM-L1VM-RVM-SVM-2d-c.png}} \\\\\n% \\subfloat[]{\\includegraphics[scale=.50]{L2VM-L1VM-RVM-SVM-2d-d.png}}\n% \\caption{Example of non-linear binary classification using an RBF kernel with bandwidth $\\sigma=0.3$. (a) L2VM with $\\lambda=5$. (b) L1VM with $\\lambda=1$. (c) RVM. (d) SVM with $C=1/\\lambda$ chosen by cross validation. Black circles denote the support vectors.}\n% \\label{fig:L2VM-L1VM-RVM-SVM-2d} \n% \\end{figure}\n\n% In Figure \\ref{fig:L2VM-L1VM-RVM-SVM-1d}, we compare L2VM, L1VM, RVM and an SVM using an RBF kernel on a 1d regression problem. \n% \\begin{figure}[hbtp]\n% \\centering\n%     \\includegraphics[scale=.70]{L2VM-L1VM-RVM-SVM-1d.png}\n% \\caption{Example of kernel based regression on the noisy sinc function using an RBF kernel with bandwidth $\\sigma=0.3$. (a) L2VM with $\\lambda=0.5$. (b) L1VM with $\\lambda=0.5$. (c) RVM. (d) SVM regression with $C=1/\\lambda$ chosen by cross validation, and $\\epsilon=0.1$ (the default for SVMlight). Red circles denote the retained training exemplars.}\n% \\label{fig:L2VM-L1VM-RVM-SVM-1d} \n% \\end{figure}\n\n\n\\section{The kernel trick}\nRather than defining our feature vector in terms of kernels, $\\phi(\\vec{x})=(\\kappa(\\vec{x},\\vec{x}_1),\\cdots,\\kappa(\\vec{x},\\vec{x}_N))$, we can instead work with the original feature vectors $\\vec{x}$, but modify the algorithm so that it replaces all inner products of the form $<\\vec{x}_i,\\vec{x}_j>$ with a call to the kernel function, $\\kappa(\\vec{x}_i,\\vec{x}_j)$. This is called the \\textbf{kernel trick}. It turns out that many algorithms can be kernelized in this way. We give some examples below. Note that we require that the kernel be a Mercer kernel for this trick to work.\n\n\n\\subsection{Kernelized KNN}\nThe Euclidean distance can be unrolled as\n\\begin{equation}\\label{eqn:Euclidean-distance}\n\\lVert\\vec{x}_i-\\vec{x}_j\\rVert=<\\vec{x}_i,\\vec{x}_i>+<\\vec{x}_j,\\vec{x}_j>-2<\\vec{x}_i,\\vec{x}_j>\n\\end{equation}\nthen by replacing all $<\\vec{x}_i,\\vec{x}_j>$ with $\\kappa(\\vec{x}_i,\\vec{x}_j)$ we get Kernelized KNN.\n\n\n\\subsection{Kernelized K-medoids clustering}\n\\textbf{K-medoids algorothm} is similar to K-means(see Section \\ref{sec:K-means}), but instead of representing each cluster’s centroid by the mean of all data vectors assigned to this cluster, we make each centroid be one of the data vectors themselves. Thus we always deal with integer indexes, rather than data objects.\n\nThis algorithm can be kernelized by using Equation \\ref{eqn:Euclidean-distance} to replace the distance computation.\n\n\n\\subsection{Kernelized ridge regression}\nApplying the kernel trick to distance-based methods was straightforward. It is not so obvious how to apply it to parametric models such as ridge regression. However, it can be done, as we now explain. This will serve as a good “warm up” for studying SVMs.\n\n\n\\subsubsection{The primal problem}\nwe rewrite Equation \\ref{eqn:Ridge-regression-J} as the following\n\\begin{equation}\\label{eqn:Ridge-regression-primal-form}\nJ(\\vec{w})=(\\vec{y}-\\vec{X}\\vec{w})^T(\\vec{y}-\\vec{X}\\vec{w})+\\lambda\\lVert\\vec{w}\\rVert^2\n\\end{equation}\nand its solution is given by Equation \\ref{eqn:Ridge-regression-solution}.\n\n\n\\subsubsection{The dual problem}\nEquation \\ref{eqn:Ridge-regression-primal-form} is not yet in the form of inner products. However, using the matrix inversion lemma (Equation 4.107 TODO) we rewrite the ridge estimate as follows\n\\begin{equation}\n\\vec{w}=\\vec{X}^T(\\vec{X}\\vec{X}^T+\\lambda\\vec{I}_N)^{-1}\\vec{y}\n\\end{equation}\nwhich takes $O(N^3+N^2D)$ time to compute. This can be advantageous if $D$ is large. Furthermore, we see that we can partially kernelize this, by replacing $\\vec{X}\\vec{X}^T$ with the Gram matrix $\\vec{K}$. But what about the leading $\\vec{X}^T$ term?\n\nLet us define the following \\textbf{dual variables}:\n\\begin{equation}\n\\vec{\\alpha}=(\\vec{K}+\\lambda\\vec{I}_N)^{-1}\\vec{y}\n\\end{equation}\n\nThen we can rewrite the \\textbf{primal variables} as follows\n\\begin{equation}\n\\vec{w}=\\vec{X}^T\\vec{\\alpha}=\\sum\\limits_{i=1}^N \\alpha_i\\vec{x}_i\n\\end{equation}\n\nThis tells us that the solution vector is just a linear sum of the $N$ training vectors. When we plug this in at test time to compute the predictive mean, we get\n\\begin{equation}\ny=f(\\vec{x})=\\sum\\limits_{i=1}^N \\alpha_i\\vec{x}_i^T\\vec{x}=\\sum\\limits_{i=1}^N \\alpha_i\\kappa(\\vec{x}_i,\\vec{x})\n\\end{equation}\n\nSo we have succesfully kernelized ridge regression by changing from primal to dual variables. This technique can be applied to many other linear models, such as logistic regression.\n\n\n\\subsubsection{Computational cost}\nThe cost of computing the dual variables $\\vec{\\alpha}$ is $O(N^3)$, whereas the cost of computing the primal variables $\\vec{w}$ is $O(D^3)$. Hence the kernel method can be useful in high dimensional settings, even if we only use a linear kernel (c.f., the SVD trick in Equation \\ref{eqn:Ridge-regression-SVD}). However, prediction using the dual variables takes $O(ND)$ time, while prediction using the primal variables only takes $O(D)$ time. We can speedup prediction by making $\\vec{\\alpha}$ sparse, as we discuss in Section \\ref{sec:SVMs}.\n\n\n\\subsection{Kernel PCA}\nTODO\n\n\n\\section{Support vector machines (SVMs)}\n\\label{sec:SVMs}\nIn Section \\ref{sec:sparse-kernel-machines}, we saw one way to derive a sparse kernel machine, namely by using a GLM with kernel basis functions, plus a sparsity-promoting prior such as $\\ell_1$ or ARD. An alternative approach is to change the objective function from negative log likelihood to some other loss function, as we discussed in Section \\ref{sec:Surrogate-loss-functions}. In particular, consider the $\\ell_2$ regularized empirical risk function\n\\begin{equation}\nJ(\\vec{w}, \\lambda)=\\sum\\limits{i=1}^N L(y_i, \\hat{y_i})+\\lambda\\lVert\\vec{w}\\rVert^2\n\\end{equation}\nwhere $\\hat{y_i}=\\vec{w}^T\\vec{x}_i+w_0$.\n\nIf $L$ is quadratic loss, this is equivalent to ridge regression, and if $L$ is the log-loss defined in Equation \\ref{eqn:log-loss}, this is equivalent to logistic regression.\n\nHowever, if we replace the loss function with some other loss function, to be explained below, we can ensure that the solution is sparse, so that predictions only depend on a subset of the training data, known as \\textbf{support vectors}. This combination of the kernel trick plus a modified loss function is known as a \\textbf{support vector machine} or \\textbf{SVM}. \n\nNote that SVMs are very unnatural from a probabilistic point of view. \n\\begin{itemize}\n\\item{First, they encode sparsity in the loss function rather than the prior.}\n\\item{Second, they encode kernels by using an algorithmic trick, rather than being an explicit part of the model. }\n\\item{Finally, SVMs do not result in probabilistic outputs, which causes various difficulties, especially in the multi-class classification setting (see Section 14.5.2.4 TODO for details).}\n\\end{itemize}\n\nIt is possible to obtain sparse, probabilistic, multi-class kernel-based classifiers, which work as well or better than SVMs, using techniques such as the L1VM or RVM, discussed in Section \\ref{sec:sparse-kernel-machines}. However, we include a discussion of SVMs, despite their non-probabilistic nature, for two main reasons. \n\\begin{itemize}\n\\item{First, they are very popular and widely used, so all students of machine learning should know about them.}\n\\item{Second, they have some computational advantages over probabilistic methods in the structured output case; see Section 19.7 TODO.}\n\\end{itemize}\n\n\n\\subsection{SVMs for classification}\n\n\n\\subsubsection{Primal form}\n\\textbf{Representation}\n\\begin{equation}\n\\mathcal{H}:y=f(\\vec{x})=\\text{sign}(\\vec{w}\\vec{x}+b)\n\\end{equation}\n\n\\textbf{Evaluation}\n\\begin{eqnarray}\n\\min_{\\vec{w},b}  && \\frac{1}{2}\\|\\vec{w}\\|^2 \\\\\n       & s.t. \\quad & y_i(\\vec{w}\\vec{x}_i+b)\\geqslant 1, i=1,2, \\dots , N\n\\end{eqnarray}\n\n\n\\subsubsection{Dual form}\n\\textbf{Representation}\n\\begin{equation}\n\\mathcal{H}:y=f(\\vec{x})=\\text{sign}\\left(\\sum\\limits_{i=1}^N{\\alpha_iy_i(\\vec{x} \\cdot \\vec{x}_i)}+b\\right)\n\\end{equation}\n\n\\textbf{Evaluation}\n\\begin{eqnarray}\n \\min_{\\alpha} && \\frac{1}{2} \\sum\\limits_{i=1}^N\\sum\\limits_{j=1}^N \\alpha_i\\alpha_j y_i y_j (\\vec{x}_i \\cdot \\vec{x}_j) - \\sum\\limits_{i=1}^N \\alpha_i \\\\\n               & s.t.  \\quad &\\sum\\limits_{i=1}^N\\alpha_i y_i=0 \\\\\n               && \\alpha_i \\geqslant 0, i=1,2, \\dots, N\n\\end{eqnarray}\n\n\n\\subsubsection{Primal form with slack variables}\n\\textbf{Representation}\n\\begin{equation}\n\\mathcal{H}:y=f(\\vec{x})=\\text{sign}(\\vec{w}\\vec{x}+b)\n\\end{equation}\n\n\\textbf{Evaluation}\n\\begin{eqnarray}\n\\min_{\\vec{w},b}  &&  C \\sum\\limits_{i=1}^N\\xi_i + \\frac{1}{2}\\|\\vec{w}\\|^2 \\label{eqn:pfwr1} \\\\\n      & s.t. \\quad & y_i(\\vec{w}\\vec{x}_i+b)\\geqslant 1-\\xi_i  \\label{eqn:pfwr2} \\\\\n                  && \\xi_i \\geqslant 0, \\quad i=1,2, \\dots, N \\label{eqn:pfwr3}\n\\end{eqnarray}\n\n\n\\subsubsection{Dual form with slack variables}\n\\textbf{Representation}\n\\begin{equation}\n\\mathcal{H}:y=f(\\vec{x})=\\text{sign}\\left(\\sum\\limits_{i=1}^N{\\alpha_iy_i(\\vec{x} \\cdot \\vec{x}_i)}+b\\right)\n\\end{equation}\n\n\\textbf{Evaluation}\n\\begin{eqnarray}\n \\min_{\\alpha} && \\frac{1}{2} \\sum\\limits_{i=1}^N\\sum\\limits_{j=1}^N \\alpha_i\\alpha_j y_i y_j (\\vec{x}_i \\cdot \\vec{x}_j) - \\sum\\limits_{i=1}^N \\alpha_i \\\\\n               & s.t.  \\quad & \\sum\\limits_{i=1}^N\\alpha_i y_i=0 \\\\\n               && 0 \\leqslant  \\alpha_i \\leqslant C, i=1,2, \\dots, N\n\\end{eqnarray}\n\n\\begin{eqnarray}\n\\alpha_i=0 \\Rightarrow y_i(\\vec{w} \\cdot \\vec{x}_i+b)\\geqslant 1 \\\\\n\\alpha_i=C \\Rightarrow y_i(\\vec{w} \\cdot \\vec{x}_i+b)\\leqslant 1 \\\\\n0<\\alpha_i<C \\Rightarrow y_i(\\vec{w} \\cdot \\vec{x}_i+b)= 1\n\\end{eqnarray}\n\n\n\\subsubsection{Hinge Loss}\nLinear support vector machines can also be interpreted as hinge loss minimization:\n\\begin{equation}\\label{eqn:Hinge-Loss-objective}\n\\min_{\\vec{w},b} \\sum\\limits_{i=1}^N{L(y_i,f(\\vec{x}_i))} + \\lambda\\|\\vec{w}\\|^2\n\\end{equation}\nwhere $L(y, f(\\vec{x}))$ is a \\textbf{hinge loss function}:\n\\begin{equation}\nL(y, f(\\vec{x})) = \\begin{cases}\n1-yf(x),  & 1-yf(x) > 0 \\\\\n0,  & 1-yf(x) \\leqslant 0\n\\end{cases}\n\\end{equation}\n\n\\begin{proof}\nWe can write equation \\ref{eqn:Hinge-Loss-objective} as equations \\ref{eqn:pfwr1} $\\sim$ \\ref{eqn:pfwr3}.\n\nDefine slack variables\n\\begin{equation}\n\\xi_i \\triangleq 1-y_i(\\vec{w} \\cdot \\vec{x}_i + b),\\xi_i \\geqslant 0\n\\end{equation}\n\nThen $\\vec{w},b,\\xi_i$ satisfy the constraints \\ref{eqn:pfwr1} and \\ref{eqn:pfwr2}. And objective function \\ref{eqn:pfwr3} can be written as\n\\begin{equation}\n\\min_{\\vec{w},b} \\sum\\limits_{i=1}^N{\\xi_i}+ \\lambda\\|\\vec{w}\\|^2 \\nonumber\n\\end{equation}\n\nIf $\\lambda=\\dfrac{1}{2C}$, then \n\\begin{equation}\n\\min_{\\vec{w},b} \\dfrac{1}{C}\\left(C\\sum\\limits_{i=1}^N{\\xi_i}+\\dfrac{1}{2}\\|\\vec{w}\\|^2\\right)\n\\end{equation}\nIt is equivalent to equation \\ref{eqn:pfwr1}.\n\n\\end{proof}\n\n\n\\subsubsection{Optimization}\nQP, SMO\n\n\n\\subsection{SVMs for regression}\n\n\n\\subsubsection{Representation}\n\\begin{equation}\n\\mathcal{H}: y=f(\\vec{x})=\\vec{w}^T\\vec{x}+b\n\\end{equation}\n\n\n\\subsubsection{Evaluation}\n\\begin{equation}\nJ(\\vec{w})=C\\sum\\limits_{i=1}^N L(y_i,f(\\vec{x}_i))++\\dfrac{1}{2}\\lVert\\vec{w}\\rVert^2\n\\end{equation}\nwhere $L(y,f(\\vec{x}))$ is a \\textbf{epsilon insensitive loss function}:\n\\begin{equation}\nL(y,f(\\vec{x})) = \\begin{cases}\n0  & , |y-f(\\vec{x})|<\\epsilon \\\\\n|y-f(\\vec{x})|-\\epsilon  & , \\text{ otherwise}\n\\end{cases}\n\\end{equation}\nand $C=1/\\lambda$ is a regularization constant. \n\nThis objective is convex and unconstrained, but not differentiable, because of the absolute value function in the loss term. As in Section 13.4 TODO, where we discussed the lasso problem, there are several possible algorithms we could use. One popular approach is to formulate the problem as a constrained optimization problem. In particular, we introduce \\textbf{slack variables} to represent the degree to which each point lies outside the tube:\n\\begin{align*}\ny_i \\leq & f(\\vec{x}_i)+\\epsilon+\\xi_i^+ \\\\\ny_i \\geq & f(\\vec{x}_i)-\\epsilon-\\xi_i^- \n\\end{align*}\n\nGiven this, we can rewrite the objective as follows:\n\\begin{equation}\nJ(\\vec{w})=C\\sum\\limits_{i=1}^N (\\xi_i^+ + \\xi_i^-)++\\dfrac{1}{2}\\lVert\\vec{w}\\rVert^2\n\\end{equation}\nThis is a standard quadratic problem in $2N+D+1$ variables.\n\n\n\\subsection{Choosing $C$}\n\\label{sec:SVM-Choosing-C}\nSVMs for both classification and regression require that you specify the kernel function and the parameter $C$. Typically $C$ is chosen by cross-validation. Note, however, that $C$ interacts quite strongly with the kernel parameters. For example, suppose we are using an RBF kernel with precision $\\gamma=\\frac{1}{2\\sigma^2}$. If $\\gamma=5$, corresponding to narrow kernels, we need heavy regularization, and hence small $C$(so $\\lambda=1/C$is big). If $\\gamma=1$, a larger value of $C$should be used. So we see that $\\gamma$ and $C$ are tightly coupled. This is illustrated in Figure \\ref{fig:choosing-C}, which shows the CV estimate of the 0-1 risk as a function of $C$ and $\\gamma$.\n\n\\begin{figure}[hbtp]\n\\centering\n\\subfloat[]{\\includegraphics[scale=.50]{choosing-C-a.png}} \\\\\n\\subfloat[]{\\includegraphics[scale=.50]{choosing-C-b.png}}\n\\caption{(a) A cross validation estimate of the 0-1 error for an SVM classifier with RBF kernel with different precisions $\\gamma=1/(2\\sigma^2)$ and different regularizer $\\gamma=1/C$, applied to a synthetic data set drawn from a mixture of 2 Gaussians. (b) A slice through this surface for $\\gamma=5$ The red dotted line is the Bayes optimal error, computed using Bayes rule applied to the model used to generate the data. Based on Figure 12.6 of (Hastie et al. 2009). }\n\\label{fig:choosing-C} \n\\end{figure}\n\nThe authors of libsvm recommend (Hsu et al. 2009) using CV over a 2d grid with values $C \\in \\{2^{−5},2^{−3},\\cdots,2^{15}\\}$ and $\\gamma \\in \\{2^{−15},2^{−13},\\cdots,2^3\\}$. In addition, it is important to standardize the data first, for a spherical Gaussian kernel to make sense.\n\nTo choose $C$ efficiently, one can develop a path following algorithm in the spirit of lars (Section 13.3.4 TODO). The basic idea is to start with $\\lambda$ large, so that the margin $1/\\lVert\\vec{w}(\\lambda)\\rVert$ is wide, and hence all points are inside of it and have $\\alpha_i =1$. By slowly decreasing $\\lambda$, a small set of points will move from inside the margin to outside, and their $\\alpha_i$ values will change from 1 to 0, as they cease to be support vectors. When $\\lambda$ is maximal, the function is completely smoothed, and no support vectors remain. See (Hastie et al. 2004) for the details.\n\n\n\\subsection{A probabilistic interpretation of SVMs}\nTODO see MLAPP Section 14.5.5\n\n\n\\subsection{Summary of key points}\nSummarizing the above discussion, we recognize that SVM classifiers involve three key ingredients: the kernel trick, sparsity, and the large margin principle. The kernel trick is necessary to prevent underfitting, i.e., to ensure that the feature vector is sufficiently rich that a linear classifier can separate the data. (Recall from Section \\ref{sec:Mercer-kernels} that any Mercer kernel can be viewed as implicitly defining a potentially high dimensional feature vector.) If the original features are already high dimensional (as in many gene expression and text classification problems), it suffices to use a linear kernel, $\\kappa(\\vec{x},\\vec{x}')=\\vec{x}^T\\vec{x}'$ , which is equivalent to working with the original features.\n\nThe sparsity and large margin principles are necessary to prevent overfitting, i.e., to ensure that we do not use all the basis functions. These two ideas are closely related to each other, and both arise (in this case) from the use of the hinge loss function. However, there are other methods of achieving sparsity (such as $\\ell_1$), and also other methods of maximizing the margin(such as boosting). A deeper discussion of this point takes us outside of the scope of this book. See e.g., (Hastie et al. 2009) for more information.\n\n\n\\section{Comparison of discriminative kernel methods}\nWe have mentioned several different methods for classification and regression based on kernels, which we summarize in Table \\ref{tab:Comparison-of-kernel-based-classifiers}. (GP stands for “Gaussian process”, which we discuss in Chapter 15 TODO.) The columns have the following meaning:\n\\begin{itemize}\n\\item{Optimize $\\vec{w}$: a key question is whether the objective $J(\\vec{w}=-\\log p(\\mathcal{D}|\\vec{w})-\\log p(\\vec{w}))$ is convex or not. L2VM, L1VM and SVMs have convex objectives. RVMs do not. GPs are Bayesian methods that do not perform parameter estimation.}\n\\item{Optimize kernel: all the methods require that one “tune” the kernel parameters, such as the bandwidth of the RBF kernel, as well as the level of regularization. For methods based on Gaussians, including L2VM, RVMs and GPs, we can use efficient gradient based optimizers to maximize the marginal likelihood. For SVMs, and L1VM, we must use cross validation, which is slower (see Section \\ref{sec:SVM-Choosing-C}).}\n\\item{Sparse: L1VM, RVMs and SVMs are sparse kernel methods, in that they only use a subset of the training examples. GPs and L2VM are not sparse: they use all the training examples. The principle advantage of sparsity is that prediction at test time is usually faster. In addition, one can sometimes get improved accuracy.}\n\\item{Probabilistic: All the methods except for SVMs produce probabilistic output of the form $p(y|\\vec{x})$. SVMs produce a “confidence” value that can be converted to a probability, but such probabilities are usually very poorly calibrated (see Section 14.5.2.3 TODO).}\n\\item{Multiclass: All the methods except for SVMs naturally work in the multiclass setting, by using a multinoulli output instead of Bernoulli. The SVM can be made into a multiclass classifier, but there are various difficulties with this approach, as discussed in Section 14.5.2.4 TODO.}\n\\item{Mercer kernel: SVMs and GPs require that the kernel is positive definite; the other techniques do not.}\n\\end{itemize}\n\n\\begin{table}\n\\centering\n\\begin{tabular}{llllllll}\n\\hline\\noalign{\\smallskip}\nMethod & Opt. \\vec{w} & Opt. & Sparse & Prob. & Multiclass & Non-Mercer & Section \\\\\n\\noalign{\\smallskip}\\svhline\\noalign{\\smallskip}\nL2VM & Convex & EB & No & Yes & Yes & Yes & 14.3.2 \\\\\nL1VM & Convex & CV & Yes & Yes & Yes & Yes & 14.3.2 \\\\\nRVM & Not convex & EB & Yes & Yes & Yes & Yes & 14.3.2 \\\\\nSVM & Convex & CV & Yes & No & Indirectly & No & 14.5 \\\\\nGP & N/A & EB & No & Yes & Yes & No & 15 \\\\\n\\noalign{\\smallskip}\\hline\n\\end{tabular}\n\\caption{Comparison of various kernel based classifiers. EB = empirical Bayes, CV = cross validation. See text for details}\\label{tab:Comparison-of-kernel-based-classifiers}\n\\end{table}\n\n\n\\section{Kernels for building generative models}\nTODO\n"
  },
  {
    "path": "chapterLVM.tex",
    "content": "\\chapter{Latent variable models for discrete data}\n\n\n\\section{Introduction}\nIn this chapter, we are concerned with latent variable models for discrete data, such as bit vectors, sequences of categorical variables, count vectors, graph structures, relational data, etc. These models can be used to analyse voting records, text and document collections, low-intensity images, movie ratings, etc. However, we will mostly focus on text analysis, and this will be reflected in our terminology.\n\nSince we will be dealing with so many different kinds of data, we need some precise notation to keep things clear. When modeling variable-length sequences of categorical variables (i.e., symbols or \\textbf{tokens}), such as words in a document, we will let $y_{il} \\in \\{1,\\cdots,V\\}$ represent the identity of the $l$'th word in document $i$,where $V$ is the number of possible words in the vocabulary. We assume $l=1:L_i$, where $L_i$ is the (known) length of document $i$, and $i=1:N$, where $N$ is the number of documents.\n\nWe will often ignore the word order, resulting in a \\textbf{bag of words}. This can be reduced to a fixed length vector of counts (a histogram). We will use $n_{iv} \\in \\{0,1,\\cdots,Li\\}$ to denote the number of times word $v$ occurs in document $i$, for $v=1:V$. Note that the $N \\times V$ count matrix $\\vec{N}$ is often large but sparse, since we typically have many documents, but most words do not occur in any given document.\n\nIn some cases, we might have multiple different bags of words, e.g., bags of text words and bags of visual words. These correspond to different “channels” or types of features. We will denote these by $y_{irl}$, for $r=1:R$(the number of responses) and $l=1:L_{ir}$. If $L_{ir} =1$,it means we have a single token (a bag of length 1); in this case, we just write $y_{ir} \\in \\{1,\\cdots,V_r\\}$ for brevity. If every channel is just a single token, we write the fixed-size response vector as $y_{i,1:R}$; in this case, the $N \\times R$ design matrix \\vec{Y} will not be sparse. For example, in social science surveys, $y_{ir}$ could be the response of personito the $r$'th multi-choice question.\n\nOut goal is to build joint probability models of $p(\\vec{y}_i)$ or $p(\\vec{n}_i)$ using latent variables to capture the correlations. We will then try to interpret the latent variables, which provide a compressed representation of the data. We provide an overview of some approaches in Section 27.2 TODO, before going into more detail in later sections.\n\n\n\\section{Distributed state LVMs for discrete data}\n\n"
  },
  {
    "path": "chapterLatentLinearModels.tex",
    "content": "\\chapter{Latent linear models}\n\n\n\\section{Factor analysis}\nOne problem with mixture models is that they only use a single latent variable to generate the observations. In particular, each observation can only come from one of $K$ prototypes. One can think of a mixture model as using $K$ hidden binary variables, representing a one-hot encoding of the cluster identity. But because these variables are mutually exclusive, the model is still limited in its representational power.\n\nAn alternative is to use a vector of real-valued latent variables,$\\vec{z}_i \\in \\mathbb{R}^L$. The simplest prior to use is a Gaussian (we will consider other choices later):\n\\begin{equation}\\label{eqn:FA-prior}\np(\\vec{z}_i)=\\mathcal{N}(\\vec{z}_i|\\vec{\\mu}_0,\\vec{\\Sigma}_0)\n\\end{equation}\nIf the observations are also continuous, so $\\vec{x}_i \\in \\mathbb{R}^D$, we may use a Gaussian for the likelihood. Just as in linear regression, we will assume the mean is a linear function of the (hidden) inputs, thus yielding\n\\begin{equation}\\label{eqn:FA-class-conditional-density}\np(\\vec{x}_i|\\vec{z}_i,\\vec{\\theta})=\\mathcal{N}(\\vec{x}_i|\\vec{W}\\vec{z}_i+\\vec{\\mu},\\vec{\\Psi})\n\\end{equation}\nwhere \\vec{W} is a $D \\times L$ matrix, known as the \\textbf{factor loading matrix}, and $\\vec{\\Psi}$ is a $D \\times D$ covariance matrix. We take $\\vec{\\Psi}$ to be diagonal, since the whole point of the model is to “force” $\\vec{z}_i$ to explain the correlation, rather than “baking it in” to the observation’s covariance. This overall model is called \\textbf{factor analysis} or \\textbf{FA}. The special case in which $\\vec{\\Psi}=\\sigma^2\\vec{I}$ is called \\textbf{probabilistic principal components analysis} or \\textbf{PPCA}. The reason for this name will become apparent later.\n\n\n\\subsection{FA is a low rank parameterization of an MVN}\nFA can be thought of as a way of specifying a joint density model on $\\vec{x}$ using a small number of parameters. To see this, note that from Equation \\ref{eqn:Linear-Gaussian-system-normalizer}, the induced marginal distribution $p(\\vec{x}_i|\\vec{\\theta})$ is a Gaussian:\n\\begin{align}\np(\\vec{x}_i|\\vec{\\theta}) & = \\int \\mathcal{N}(\\vec{x}_i|\\vec{W}\\vec{z}_i+\\vec{\\mu},\\vec{\\Psi})\\mathcal{N}(\\vec{z}_i|\\vec{\\mu}_0,\\vec{\\Sigma}_0)\\mathrm{d}\\vec{z}_i \\nonumber \\\\\n & = \\mathcal{N}(\\vec{x}_i|\\vec{W}\\vec{\\mu}_0+\\vec{\\mu},\\vec{\\Psi}+\\vec{W}\\vec{\\Sigma}_0\\vec{W})\n\\end{align}\nFrom this, we see that we can set $\\vec{\\mu}_0=0$ without loss of generality, since we can always absorb $\\vec{W}\\vec{\\mu}_0$ into $\\vec{\\mu}$. Similarly, we can set $\\vec{\\Sigma}_0=\\vec{I}$ without loss of generality, because we can always “emulate” a correlated prior by using defining a new weight matrix, $\\tilde{\\vec{W}}=\\vec{W}\\vec{\\Sigma}_0^{-\\frac{1}{2}}$. So we can rewrite Equation \\ref{eqn:FA-prior} and \\ref{eqn:FA-class-conditional-density} as:\n\\begin{align}\np(\\vec{z}_i)&=\\mathcal{N}(\\vec{z}_i|\\vec{0},\\vec{I}) \\\\\np(\\vec{x}_i|\\vec{z}_i,\\vec{\\theta})&=\\mathcal{N}(\\vec{x}_i|\\vec{W}\\vec{z}_i+\\vec{\\mu},\\vec{\\Psi})\n\\end{align}\n\nWe thus see that FA approximates the covariance matrix of the visible vector using a low-rank decomposition:\n\\begin{equation}\\label{eqn:FA-prior}\n\\vec{C} \\triangleq \\mathrm{cov}[\\vec{x}]=\\vec{W}\\vec{W}^T+\\vec{\\Psi}\n\\end{equation}\nThis only uses $O(LD)$ parameters, which allows a flexible compromise between a full covariance Gaussian, with $O(D^2)$ parameters, and a diagonal covariance, with $O(D)$ parameters. Note that if we did not restrict $\\vec{\\Psi}$ to be diagonal, we could trivially set $\\vec{\\Psi}$ to a full covariance matrix; then we could set $\\vec{W}=0$, in which case the latent factors would not be required.\n\n\n\\subsection{Inference of the latent factors}\n\\begin{align}\np(\\vec{z}_i|\\vec{x}_i,\\vec{\\theta}) & = \\mathcal{N}(\\vec{z}_i|\\vec{\\mu}_i,\\vec{\\Sigma}_i) \\\\\n\\vec{\\Sigma}_i & \\triangleq (\\vec{\\Sigma}_0^{-1}+\\vec{W}^T\\vec{\\Psi}^{-1}\\vec{W})^{-1} \\\\\n               & =(\\vec{I}+\\vec{W}^T\\vec{\\Psi}^{-1}\\vec{W})^{-1} \\\\\n\\vec{\\mu}_i & \\triangleq \\vec{\\Sigma}_i[\\vec{W}^T\\vec{\\Psi}^{-1}(\\vec{x}_i-\\vec{\\mu})+\\vec{\\Sigma}_0^{-1}\\vec{\\mu}_0] \\\\\n            & =\\vec{\\Sigma}_i\\vec{W}^T\\vec{\\Psi}^{-1}(\\vec{x}_i-\\vec{\\mu})\n\\end{align}\nNote that in the FA model, $\\vec{\\Sigma}_i$ is actually independent of $i$, so we can denote it by $\\vec{\\Sigma}$. Computing this matrix takes $O(L^3+L^2D)$ time, and computing each $\\vec{\\mu}_i=\\mathbb{E}[\\vec{z}_i|\\vec{x}_i,\\vec{\\theta}]$ takes $O(L^2+LD)$ time. The $\\vec{\\mu}_i$ are sometimes called the \\textbf{latent scores}, or \\textbf{latent factors}.\n\n\n\\subsection{Unidentifiability}\nJust like with mixture models, FA is also unidentifiable. To see this, suppose $\\vec{R}$ is an arbitrary orthogonal rotation matrix, satisfying $\\vec{R}\\vec{R}^T=\\vec{I}$. Let us define $\\tilde{\\vec{W}}=\\vec{W}\\vec{R}$, then the likelihood function of this modified matrix is the same as for the unmodified matrix, since $\\vec{W}\\vec{R}\\vec{R}^T\\vec{W}^T+\\vec{\\Psi}=\\vec{W}\\vec{W}^T+\\vec{\\Psi}$. Geometrically, multiplying $\\vec{W}$ by an orthogonal matrix is like rotating $\\vec{z}$ before generating $\\vec{x}$.\n\nTo ensure a unique solution, we need to remove $L(L-1)/2$ degrees of freedom, since that is the number of orthonormal matrices of size $L \\times L$.\\footnote{To see this, note that there are $L-1$ free parameters in $\\vec{R}$ in the first column (since the column vector must be normalized to unit length), there are $L-2$ free parameters in the second column (which must be orthogonal to the first), and so on.} In total, the FA model has $D+LD-L(L-1)/2$ free parameters (excluding the mean), where the first term arises from $\\vec{\\Psi}$. Obviously we require this to be less than or equal to $D(D+1)/2$, which is the number of parameters in an unconstrained (but symmetric) covariance matrix. This gives us an upper bound on $L$, as follows:\n\\begin{equation}\nL_{\\mathrm{max}}=\\lfloor D+0.5(1-\\sqrt{1+8D}) \\rfloor\n\\end{equation}\n\nFor example, $D=6$ implies $L \\leq 3$. But we usually never choose this upper bound, since it would result in overfitting (see discussion in Section \\ref{sec:FA-Choosing-L} on how to choose $L$).\n\n\nUnfortunately, even if we set $L < L_{\\mathrm{max}}$, we still cannot uniquely identify the parameters, since the rotational ambiguity still exists. Non-identifiability does not affect the predictive performance of the model. However, it does affect the loading matrix, and hence the interpretation of the latent factors. Since factor analysis is often used to uncover structure in the data, this problem needs to be addressed. Here are some commonly used solutions:\n\\begin{itemize}\n\\item{\\textbf{Forcing $\\vec{W}$ to be orthonormal} Perhaps the cleanest solution to the identifiability problem is to force $\\vec{W}$ to be orthonormal, and to order the columns by decreasing variance of the corresponding latent factors. This is the approach adopted by PCA, which we will discuss in Section \\ref{sec:PCA}. The result is not necessarily more interpretable, but at least it is unique.}\n\\item{\\textbf{Forcing $\\vec{W}$ to be lower triangular} One way to achieve identifiability, which is popular in the Bayesian community (e.g., (Lopes and West 2004)), is to ensure that the first visible feature is only generated by the first latent factor, the second visible feature is only generated by the first two latent factors, and so on. For example, if $L=3$ and $D=4$, the correspond factor loading matrix is given by\n\\begin{equation*}\n\\vec{W}=\\left(\\begin{array}{ccc}\nw_{11} & 0 & 0 \\\\\nw_{21} & w_{22} & 0 \\\\\nw_{31} & w_{32} & w_{33} \\\\\nw_{41} & w_{32} & w_{43}\n\\end{array}\\right)\n\\end{equation*}\nWe also require that $w_{jj} >0$ for $j =1:L$. The total number of parameters in this constrained matrix is $D+DL-L(L-1)/2$, which is equal to the number of uniquely identifiable parameters. The disadvantage of this method is that the first $L$ visible variables, known as the \\textbf{founder variables}, affect the interpretation of the latent factors, and so must be chosen carefully.}\n\\item{\\textbf{Sparsity promoting priors on the weights} Instead of pre-specifying which entries in $\\vec{W}$ are zero, we can encourage the entries to be zero, using $\\ell_1$ regularization (Zou et al. 2006), ARD (Bishop 1999; Archambeau and Bach 2008), or spike-and-slab priors (Rattray et al. 2009). This is called sparse factor analysis. This does not necessarily ensure a unique MAP estimate, but it does encourage interpretable solutions. See Section 13.8 TODO.}\n\\item{\\textbf{Choosing an informative rotation matrix} There are a variety of heuristic methods that try to find rotation matrices $\\vec{R}$ which can be used to modify $\\vec{W}$(and hence the latent factors) so as to try to increase the interpretability, typically by encouraging them to be (approximately) sparse. One popular method is known as \\textbf{varimax}(Kaiser 1958).}\n\\item{\\textbf{Use of non-Gaussian priors for the latent factors} In Section \\ref{sec:ICA}, we will dicuss how replacing $p(\\vec{z}_i)$ with a non-Gaussian distribution can enable us to sometimes uniquely identify $\\vec{W}$ as well as the latent factors. This technique is known as ICA.}\n\\end{itemize}\n\n\n\\subsection{Mixtures of factor analysers}\nThe FA model assumes that the data lives on a low dimensional linear manifold. In reality, most\ndata is better modeled by some form of low dimensional \\emph{curved} manifold. We can approximate a curved manifold by a piecewise linear manifold. This suggests the following model: let the $k$'th linear subspace of dimensionality $L_k$ be represented by $\\vec{W}_k$, for $k=1:K$. Suppose we have a latent indicator $qi \\in \\{1,\\cdots,K\\}$ specifying which subspace we should use to generate the data. We then sample $\\vec{z}_i$ from a Gaussian prior and pass it through the $\\vec{W}_k$ matrix (where $k=q_i$), and add noise. More precisely, the model is as follows:\n\\begin{align}\np(q_i|\\vec{\\theta}) & =\\mathrm{Cat}(q_i\\vec{\\pi}) \\\\\np(\\vec{z}_i|\\vec{\\theta}) & =\\mathcal{N}(\\vec{z}_i|\\vec{0},\\vec{I}) \\\\\np(\\vec{x}_i|q_i=k,\\vec{z}_i,\\vec{\\theta}) & =\\mathcal{N}(\\vec{x}_i|\\vec{W}\\vec{z}_i+\\vec{\\mu}_k,\\vec{\\Psi})\n\\end{align}\nThis is called a \\textbf{mixture of factor analysers}(MFA) (Hinton et al. 1997).\n\nAnother way to think about this model is as a low-rank version of a mixture of Gaussians. In particular, this model needs $O(KLD)$ parameters instead of the $O(KD^2)$ parameters needed for a mixture of full covariance Gaussians. This can reduce overfitting. In fact, MFA is a good generic density model for high-dimensional real-valued data.\n\n\n\\subsection{EM for factor analysis models}\nBelow we state the results without proof. The derivation can be found in (Ghahramani and Hinton 1996a). To obtain the results for a single factor analyser, just set $r_{ic} =1$ and $c=1$ in the equations below. In Section \\ref{sec:EM-for-PCA} we will see a further simplification of these equations that arises when fitting a PPCA model, where the results will turn out to have a particularly simple and elegant interpretation.\n\nIn the E-step, we compute the posterior responsibility of cluster $k$ for data point $i$ using\n\\begin{equation}\nr_{ik} \\triangleq p(q_i=k|\\vec{x}_i,\\vec{\\theta}) \\propto \\pi_k\\mathcal{N}(\\vec{x}_i|\\vec{\\mu}_k,\\vec{W}_k\\vec{W}_k^T\\vec{\\Psi}_k)\n\\end{equation}\n\nThe conditional posterior for $\\vec{z}_i$ is given by\n\\begin{align}\np(\\vec{z}_i|\\vec{x}_i,q_i=k,\\vec{\\theta}) & = \\mathcal{N}(\\vec{z}_i|\\vec{\\mu}_{ik},\\vec{\\Sigma}_{ik}) \\\\\n\\vec{\\Sigma}_{ik} & \\triangleq (\\vec{I}+\\vec{W}_k^T\\vec{\\Psi}_k^{-1}\\vec{W})_k^{-1} \\\\\n\\vec{\\mu}_{ik} & \\triangleq \\vec{\\Sigma}_{ik}\\vec{W}_k^T\\vec{\\Psi}_k^{-1}(\\vec{x}_i-\\vec{\\mu}_k)\n\\end{align}\n\nIn the M step, it is easiest to estimate $\\vec{\\mu}_k$ and $\\vec{W}_k$ at the same time, by defining $\\tilde{\\vec{W}}_k=(\\vec{W}_k,\\vec{\\mu}_k)$, $\\tilde{\\vec{z}}=(\\vec{z},1)$, also, define\n\\begin{align}\n\\tilde{\\vec{W}}_k & =(\\vec{W}_k,\\vec{\\mu}_k) \\\\\n\\tilde{\\vec{z}} & =(\\vec{z},1) \\\\\n\\vec{b}_{ik} & \\triangleq \\mathbb{E}[\\tilde{\\vec{z}}|\\vec{x}_i,q_i=k]=\\mathbb{E}[(\\vec{\\mu}_{ik};1)] \\\\\n\\vec{C}_{ik} & \\triangleq \\mathbb{E}[\\tilde{\\vec{z}}\\tilde{\\vec{z}}^T|\\vec{x}_i,q_i=k] \\\\\n    & =\\left(\\begin{array}{cc}\n\\mathbb{E}[\\vec{z}\\vec{z}^T|\\vec{x}_i,q_i=k] & \\mathbb{E}[\\vec{z}|\\vec{x}_i,q_i=k] \\\\\n\\mathbb{E}[\\vec{z}|\\vec{x}_i,q_i=k]^T & 1\n\\end{array}\\right)\n\\end{align}\nThen the M step is as follows:\n\\begin{align}\n\\hat{\\pi}_k & = \\frac{1}{N}\\sum\\limits_{i=1}^N r_{ik} \\\\\n\\hat{\\tilde{\\vec{W}}}_k & = \\left(\\sum\\limits_{i=1}^N r_{ik}\\vec{x}_i\\vec{b}_{ik}^T\\right)\\left(\\sum\\limits_{i=1}^N r_{ik}\\vec{x}_i\\vec{C}_{ik}^T\\right)^{-1} \\label{eqn:FA-EM-W} \\\\\n\\hat{\\vec{\\Psi}} & = \\frac{1}{N}\\mathrm{diag}\\left[\\sum\\limits_{i=1}^N r_{ik}(\\vec{x}_i-\\hat{\\tilde{\\vec{W}}}_{ik}\\vec{b}_{ik})\\vec{x}_i^T\\right]\n\\end{align}\n\nNote that these updates are for “vanilla” EM. A much faster version of this algorithm, based on ECM, is described in (Zhao and Yu 2008).\n\n\n\\subsection{Fitting FA models with missing data}\n\\label{sec:Fitting-FA-models-with-missing-data}\nIn many applications, such as collaborative filtering, we have missing data. One virtue of the EM approach to fitting an FA/PPCA model is that it is easy to extend to this case. However, overfitting can be a problem if there is a lot of missing data. Consequently it is important to perform MAP estimation or to use Bayesian inference. See e.g., (Ilin and Raiko 2010) for details.\n\n\n\\section{Principal components analysis (PCA)}\n\\label{sec:PCA}\nConsider the FA model where we constrain $\\vec{\\Psi}=\\sigma^2\\vec{I}$, and $\\vec{W}$ to be orthonormal. It can be shown (Tipping and Bishop 1999) that, as $\\sigma^2 \\rightarrow 0$, this model reduces to classical (nonprobabilistic) \\textbf{principal components analysis}(PCA), also known as the Karhunen Loeve transform. The version where $\\sigma^2 > 0$ is known as \\textbf{probabilistic PCA}(\\textbf{PPCA}) (Tipping and Bishop 1999), orsensible PCA(Roweis 1997).\n\n\n\\subsection{Classical PCA}\n\n\n\\subsubsection{Statement of the theorem}\nThe synthesis viewof classical PCA is summarized in the forllowing theorem.\n\n\\begin{theorem}\nSuppose we want to find an orthogonal set of $L$ linear basis vectors $\\vec{w}_j \\in \\mathbb{R}^D$, and the corresponding scores $\\vec{z}_i \\in \\mathbb{R}^L$, such that we minimize the average \\textbf{reconstruction error}\n\\begin{equation}\nJ(\\vec{W},\\vec{Z})=\\frac{1}{N}\\sum\\limits_{i=1}^N \\lVert\\vec{x}_i-\\hat{\\vec{x}}_i\\rVert^2\n\\end{equation}\nwhere $\\hat{\\vec{x}}_i=\\vec{W}\\vec{z}_i$, subject to the constraint that $\\vec{W}$ is orthonormal. Equivalently, we can write this objective as follows\n\\begin{equation}\nJ(\\vec{W},\\vec{Z})=\\frac{1}{N} \\lVert\\vec{X}-\\vec{W}\\vec{Z}^T\\rVert^2\n\\end{equation}\nwhere $\\vec{Z}$ is an $N \\times L$ matrix with the $\\vec{z}_i$ in its rows, and $\\lVert A\\rVert_F$ is the \\textbf{Frobenius norm} of matrix $\\vec{A}$, defined by\n\\begin{equation}\n\\lVert A\\rVert_F \\triangleq \\sqrt{\\sum\\limits_{i=1}^M \\sum\\limits_{j=1}^N a_{ij}^2}=\\sqrt{\\mathrm{tr}(\\vec{A}^T\\vec{A})}\n\\end{equation}\n\nThe optimal solution is obtained by setting $\\hat{\\vec{W}}=\\vec{V}_L$, where $\\vec{V}_L$ contains the $L$ eigenvectors with largest eigenvalues of the empirical covariance matrix, $\\hat{\\vec{\\Sigma}}=\\frac{1}{N}\\sum_{i=1}^N \\vec{x}_i\\vec{x}_i^T$. (We assume the $\\vec{x}_i$ have zero mean, for notational simplicity.) Furthermore, the optimal low-dimensional encoding of the data is given by $\\hat{\\vec{z}}_i=\\vec{W}^T\\vec{x}_i$, which is an orthogonal projection of the data onto the column space spanned by the eigenvectors.\n\\end{theorem}\n\nAn example of this is shown in Figure \\ref{fig:PCA-PPCA}(a) for $D=2$ and $L=1$. The diagonal line is the vector $\\vec{w}_1$; this is called the first principal component or principal direction. The data points $\\vec{x}_i \\in \\mathbb{R}^2$ are orthogonally projected onto this line to get $\\vec{z}_i \\in \\mathbb{R}$. This is the best 1-dimensional approximation to the data. (We will discuss Figure \\ref{fig:PCA-PPCA}(b) later.)\n\n\\begin{figure}[hbtp]\n\\centering\n\\subfloat[]{\\includegraphics[scale=.60]{PCA-PPCA-a.png}} \\\\\n\\subfloat[]{\\includegraphics[scale=.60]{PCA-PPCA-b.png}}\n\\caption{An illustration of PCA and PPCA where $D=2$ and $L=1$. Circles are the original data points, crosses are the reconstructions. The red star is the data mean. (a) PCA. The points are orthogonally projected onto the line. (b) PPCA. The projection is no longer orthogonal: the reconstructions are shrunk towards the data mean (red star).}\n\\label{fig:PCA-PPCA} \n\\end{figure}\n\nThe principal directions are the ones along which the data shows maximal variance. This means that PCA can be “misled” by directions in which the variance is high merely because of the measurement scale. It is therefore standard practice to standardize the data first, or equivalently, to work with correlation matrices instead of covariance matrices. \n\n\n\\subsubsection{Proof *}\nSee Section 12.2.2 of MLAPP.\n\n\n\\subsection{Singular value decomposition (SVD)}\nWe have defined the solution to PCA in terms of eigenvectors of the covariance matrix. However, there is another way to obtain the solution, based on the \\textbf{singular value decomposition}, or \\textbf{SVD}. This basically generalizes the notion of eigenvectors from square matrices to any kind of matrix.\n\n\\begin{theorem}(\\textbf{SVD}).\nAny matrix can be decomposed as follows\n\\begin{equation}\\label{eqn:SVD}\n\\underbrace{\\vec{X}}_{N \\times D}=\\underbrace{\\vec{U}}_{N \\times N}\\underbrace{\\vec{\\Sigma}}_{N \\times D}\\underbrace{\\vec{V}^T}_{D \\times D}\n\\end{equation}\nwhere $\\vec{U}$ is an $N \\times N$ matrix whose columns are orthornormal(so $\\vec{U}^T\\vec{U}=\\vec{I}$), $\\vec{V}$ is $D \\times D$ matrix whose rows and columns are orthonormal (so $\\vec{V}^T\\vec{V}=\\vec{V}\\vec{V}^T=\\vec{I}_D$), and $\\vec{\\Sigma}$ is a $N \\times D$ matrix containing the $r=\\min(N,D)$ singular values $\\sigma_i \\geq 0$ on the main diagonal, with 0s filling the rest of the matrix.\n\\end{theorem}\n\nThis shows how to decompose the matrix $X$ into the product of three matrices: $\\vec{V}$ describes an orthonormal basis in the domain, and $\\vec{U}$ describes an orthonormal basis in the co-domain, and $\\vec{\\Sigma}$ describes how much the vectors in $\\vec{V}$ are stretched to give the vectors in $\\vec{U}$.\n\nSince there are at most $D$ singular values (assuming $N>D$), the last $N−D$ columns of $\\vec{U}$ are irrelevant, since they will be multiplied by 0. The \\textbf{economy sized SVD}, or \\textbf{thin SVD}, avoids computing these unnecessary elements. Let us denote this decomposition by $\\hat{\\vec{U}}\\hat{\\vec{\\Sigma}}\\hat{\\vec{V}}^T$.If $N>D$, we have\n\\begin{equation}\n\\underbrace{\\vec{X}}_{N \\times D}=\\underbrace{\\hat{\\vec{U}}}_{N \\times D}\\underbrace{\\hat{\\vec{\\Sigma}}}_{D \\times D}\\underbrace{\\hat{\\vec{V}}^T}_{D \\times D}\n\\end{equation}\nas in Figure \\ref{fig:SVD}(a). If $N<D$, we have\n\\begin{equation}\n\\underbrace{\\vec{X}}_{N \\times D}=\\underbrace{\\hat{\\vec{U}}}_{N \\times N}\\underbrace{\\hat{\\vec{\\Sigma}}}_{N \\times N}\\underbrace{\\hat{\\vec{V}}^T}_{N \\times D}\n\\end{equation}\nComputing the economy-sized SVD takes $O(ND\\min(N,D))$ time (Golub and van Loan 1996, p254).\n\n\\begin{figure}[hbtp]\n\\centering\n\\subfloat[]{\\includegraphics[scale=.50]{SVD-a.png}} \\\\\n\\subfloat[]{\\includegraphics[scale=.50]{SVD-b.png}}\n\\caption{(a) SVD decomposition of non-square matrices $\\vec{X}=\\vec{U}\\vec{\\Sigma}\\vec{V}^T$. The shaded parts of $\\vec{\\Sigma}$, and all the off-diagonal terms, are zero. The shaded entries in $\\vec{U}$ and $\\vec{\\Sigma}$ are not computed in the economy-sized version, since they are not needed. (b) Truncated SVD approximation of rank $L$.}\n\\label{fig:SVD} \n\\end{figure}\n\nThe connection between eigenvectors and singular vectors is the following:\n\\begin{align}\n\\vec{U}&=\\mathrm{evec}(\\vec{X}\\vec{X}^T) \\\\\n\\vec{V}&=\\mathrm{evec}(\\vec{X}^T\\vec{X}) \\\\\n\\vec{\\Sigma}^2&=\\mathrm{eval}(\\vec{X}\\vec{X}^T)=\\mathrm{eval}(\\vec{X}^T\\vec{X})\n\\end{align}\nFor the proof please read Section 12.2.3 of MLAPP.\n\nSince the eigenvectors are unaffected by linear scaling of a matrix, we see that the right singular vectors of $\\vec{X}$ are equal to the eigenvectors of the empirical covariance $\\hat{\\vec{\\Sigma}}$. Furthermore, the eigenvalues of $\\hat{\\vec{\\Sigma}}$ are a scaled version of the squared singular values.\n\nHowever, the connection between PCA and SVD goes deeper. From Equation \\ref{eqn:SVD}, we can represent a rank $r$ matrix as follows:\n\\begin{equation*}\n\\vec{X}=\\sigma_1\\left(\\begin{array}{c} | \\\\ \\vec{u}_1 \\\\ | \\end{array}\\right)\\left(\\begin{array}{ccc} - & \\vec{v}_1 & - \\end{array}\\right)+\\cdots+\\sigma_r\\left(\\begin{array}{c} | \\\\ \\vec{u}_r \\\\ | \\end{array}\\right)\\left(\\begin{array}{ccc} - & \\vec{v}_r^T & - \\end{array}\\right)\n\\end{equation*}\nIf the singular values die off quickly, we can produce a rank $L$ approximation to the matrix as follows:\n\\begin{align}\n\\vec{X} & \\approx \\sigma_1\\left(\\begin{array}{c} | \\\\ \\vec{u}_1 \\\\ | \\end{array}\\right)\\left(\\begin{array}{ccc} - & \\vec{v}_1 & - \\end{array}\\right)+\\cdots+\\sigma_r\\left(\\begin{array}{c} | \\\\ \\vec{u}_L \\\\ | \\end{array}\\right)\\left(\\begin{array}{ccc} - & \\vec{v}_L^T & - \\end{array}\\right) \\nonumber \\\\\n & = \\vec{U}_{:,1:L}\\vec{\\Sigma}_{1:L,1:L}\\vec{V}_{:,1:L}^T\n\\end{align}\nThis is called a \\textbf{truncated SVD} (see Figure \\ref{fig:SVD}(b)).\n\nOne can show that the error in this approximation is given by\n\\begin{equation}\n\\lVert \\vec{X}-\\vec{X}_L \\rVert_F \\approx \\sigma_L\n\\end{equation}\nFurthermore, one can show that the SVD offers the best rank $L$ approximation to a matrix (best in the sense of minimizing the above Frobenius norm).\n\nLet us connect this back to PCA. Let $\\vec{X}=\\vec{U}\\vec{\\Sigma}\\vec{V}^T$ be a truncated SVD of $\\vec{X}$. We know that $\\hat{\\vec{W}}=\\vec{V}$, and that $\\hat{\\vec{Z}}=\\vec{X}\\hat{\\vec{W}}$, so\n\\begin{equation}\n\\hat{\\vec{Z}}=\\vec{U}\\vec{\\Sigma}\\vec{V}^T\\vec{V}=\\vec{U}\\vec{\\Sigma}\n\\end{equation}\nFurthermore, the optimal reconstruction is given by $\\hat{\\vec{X}}=\\vec{Z}\\hat{\\vec{W}}$,so we find\n\\begin{equation}\n\\hat{\\vec{X}}=\\vec{U}\\vec{\\Sigma}\\vec{V}^T\n\\end{equation}\nThis is precisely the same as a truncated SVD approximation! This is another illustration of the fact that PCA is the best low rank approximation to the data.\n\n\n\\subsection{Probabilistic PCA}\n\\begin{theorem}((\\textbf{Tipping and Bishop 1999})).\nConsider a factor analysis model in which $\\vec{\\Psi}=\\sigma^2\\vec{I}$ and $\\vec{W}$ is orthogonal. The observed data log likelihood is given by\n\\begin{align}\n\\log p(\\vec{X}|\\vec{W},\\sigma^2\\vec{I}) & =-\\frac{N}{2}\\ln|\\vec{C}|-\\frac{1}{2}\\sum\\limits_{i=1}^N \\vec{x}_i^T\\vec{C}^{-1}\\vec{x}_i \\nonumber \\\\\n   & =-\\frac{N}{2}\\ln|\\vec{C}|+\\mathrm{tr}(\\vec{C}^{-1}\\vec{\\Sigma})\n\\end{align}\nwhere $\\vec{C}=\\vec{W}\\vec{W}^T+\\sigma^2\\vec{I}$ and $\\vec{\\Sigma}=\\frac{1}{N}\\sum_{i=1}^N \\vec{x}_i\\vec{x}_i^T=\\frac{1}{N}\\vec{X}\\vec{X}^T$. (We are assuming centred data, for notational simplicity.) The maxima of the log-likelihood are given by\n\\begin{equation}\n\\hat{\\vec{W}}=\\vec{V}(\\vec{\\Lambda}-\\sigma^2\\vec{I})^{\\frac{1}{2}}\\vec{R}\n\\end{equation}\nwhere $\\vec{R}$ is an arbitrary $L \\times L$ orthogonal matrix, $\\vec{V}$ is the $D \\times L$ matrix whose columns are the first $L$ eigenvectors of $\\vec{\\Sigma}$, and $\\vec{\\Lambda}$ is the corresponding diagonal matrix of eigenvalues. Without loss of generality, we can set $\\vec{R}=\\vec{I}$. Furthermore, the MLE of the noise variance is given by\n\\begin{equation}\n\\hat{\\sigma}^2=\\frac{1}{D-L}\\sum\\limits_{j=L+1}^D \\lambda_j\n\\end{equation}\nwhich is the average variance associated with the discarded dimensions.\n\\end{theorem}\n\nThus, as $\\sigma^2 \\rightarrow 0$, we have $\\hat{\\vec{W}} \\rightarrow \\vec{V}$, as in classical PCA. What about $\\hat{\\vec{Z}}$? It is easy to see that the posterior over the latent factors is given by\n\\begin{align}\np(\\vec{z}_i|\\vec{x}_i,\\hat{\\vec{\\theta}}) & = \\mathcal{N}(\\vec{z}_i|\\hat{\\vec{F}}^{-1}\\hat{\\vec{W}}^T\\vec{x}_i,\\sigma^2\\hat{\\vec{F}}^{-1}) \\label{eqn:PPCA-posterior}\\\\\n\\hat{\\vec{F}} & \\triangleq \\hat{\\vec{W}}^T\\hat{\\vec{W}}+\\sigma^2\\vec{I}\n\\end{align}\n(Do not confuse $\\vec{F} = \\vec{W}^T\\vec{W}+\\sigma^2\\vec{I}$ with $\\vec{C}=\\vec{W}\\vec{W}^T+\\sigma^2\\vec{I}$.) Hence, as $\\sigma^2 \\rightarrow 0$, we find $\\hat{\\vec{W}} \\rightarrow \\vec{V}$, $\\hat{\\vec{F}} \\rightarrow \\vec{I}$ and $\\vec{z}_i \\rightarrow \\vec{V}^T\\vec{x}_i$. Thus the posterior mean is obtained by an orthogonal projection of the data onto the column space of $\\vec{V}$, as in classical PCA.\n\nNote, however, that if $\\sigma^2 \\rightarrow 0$, the posterior mean is not an orthogonal projection, since it is shrunk somewhat towards the prior mean, as illustrated in Figure \\ref{fig:PCA-PPCA}(b). This sounds like an undesirable property, but it means that the reconstructions will be closer to the overall data mean, $\\hat{\\vec{\\mu}}=\\bar{\\vec{x}}$.\n\n\n\\subsection{EM algorithm for PCA}\n\\label{sec:EM-for-PCA}\nAlthough the usual way to fit a PCA model uses eigenvector methods, or the SVD, we can also use EM, which will turn out to have some advantages that we discuss below. EM for PCA relies on the probabilistic formulation of PCA. However the algorithm continues to work in the zero noise limit, $\\sigma^2=0$, as shown by (Roweis 1997).\n\nLet $\\tilde{\\vec{Z}}$ be a $L \\times N$ matrix storing the posterior means (low-dimensional representations) along its columns. Similarly, let $\\tilde{\\vec{X}}=\\vec{X}^T$ store the original data along its columns. From Equation \\ref{eqn:PPCA-posterior}, when $\\sigma^2=0$, we have\n\\begin{equation}\n\\tilde{\\vec{Z}}=(\\vec{W}^T\\vec{W})^{-1}\\vec{W}^T\\tilde{\\vec{X}}\n\\end{equation}\nThis constitutes the E step. Notice that this is just an orthogonal projection of the data.\n\nFrom Equation \\ref{eqn:FA-EM-W}, the M step is given by\n\\begin{equation}\n\\hat{\\vec{W}}=\\left(\\sum\\limits_{i=1}^N \\vec{x}_i\\mathbb{E}[\\vec{z}_i]^T\\right)\\left(\\sum\\limits_{i=1}^N \\mathbb{E}[\\vec{z}_i]\\mathbb{E}[\\vec{z}_i]^T\\right)^{-1}\n\\end{equation}\nwhere we exploited the fact that $\\vec{\\Sigma}=\\mathrm{cov}[\\vec{z}_i|\\vec{x}_i,\\vec{\\theta}]=\\vec{0}$ when $\\sigma^2=0$.\n\n(Tipping and Bishop 1999) showed that the only stable fixed point of the EM algorithm is the globally optimal solution. That is, the EM algorithm converges to a solution where $\\vec{W}$ spans the same linear subspace as that defined by the first $L$ eigenvectors. However, if we want $\\vec{W}$ to be orthogonal, and to contain the eigenvectors in descending order of eigenvalue, we have to orthogonalize the resulting matrix (which can be done quite cheaply). Alternatively, we can modify EM to give the principal basis directly (Ahn and Oh 2003).\n\nThis algorithm has a simple physical analogy in the case $D=2$ and $L=1$(Roweis 1997). Consider some points in $\\mathbb{R}^2$ attached by springs to a rigid rod, whose orientation is defined by a vector $\\vec{w}$. Let $\\vec{z}_i$ be the location where the $i$'th spring attaches to the rod. See Figure 12.11 of MLAPP for an illustration.\n\nApart from this pleasing intuitive interpretation, EM for PCA has the following advantages over eigenvector methods:\n\\begin{itemize}\n\\item{EM can be faster. In particular, assuming $N,D \\gg L$, the dominant cost of EM is the projection operation in the E step, so the overall time is $O(TLND)$, where $T$ is the number of iterations. This is much faster than the $O(\\min(ND^2,DN^2))$ time required by straightforward eigenvector methods, although more sophisticated eigenvector methods, such as the Lanczos algorithm, have running times comparable to EM.}\n\\item{EM can be implemented in an online fashion, i.e., we can update our estimate of $\\vec{W}$ as the data streams in.}\n\\item{EM can handle missing data in a simple way (see Section \\ref{sec:Fitting-FA-models-with-missing-data}).}\n\\item{EM can be extended to handle mixtures of PPCA/ FA models.}\n\\item{EM can be modified to variational EM or to variational Bayes EM to fit more complex models.}\n\\end{itemize}\n\n\n\\section{Choosing the number of latent dimensions}\n\\label{sec:FA-Choosing-L}\nIn Section \\ref{sec:Model-selection-for-LVM}, we discussed how to choose the number of components $K$ in a mixture model. In this section, we discuss how to choose the number of latent dimensions $L$ in a FA/PCA model.\n\n\n\\subsection{Model selection for FA/PPCA}\nTODO\n\n\\subsection{Model selection for PCA}\nTODO\n\n\n\n\\section{PCA for categorical data}\nIn this section, we consider extending the factor analysis model to the case where the observed data is categorical rather than real-valued. That is, the data has the form $y_{ij} \\in \\{1,...,C\\}$, where $j=1:R$ is the number of observed response variables. We assume each $y_{ij}$ is generated from a latent variable $\\vec{z}_i \\in \\mathbb{R}^L$, with a Gaussian prior, which is passed through the softmax function as follows:\n\\begin{align}\np(\\vec{z}_i) & = \\mathcal{N}(\\vec{z}_i|\\vec{0},\\vec{I}) \\\\\np(\\vec{y}_i|\\vec{z}_i,\\vec{\\theta}) & = \\prod\\limits_{j=1}^R \\mathrm{Cat}(y_{ir}|\\mathcal{S}(\\vec{W}_r^T\\vec{z}_i+\\vec{w}_{0r}))\n\\end{align}\nwhere $\\vec{W}_r \\in \\mathbb{R}^L$ is the factor loading matrix for response $j$, and $\\vec{W}_{0r} \\in \\mathbb{R}^M$ is the offset term for response $r$, and $\\vec{\\theta}=(\\vec{W}_r,\\vec{W}_{0r})_{r=1}^R$. (We need an explicit offset term, since clamping one element of $\\vec{z}_i$ to 1 can cause problems when computing the posterior covariance.) As in factor analysis, we have defined the prior mean to be $\\vec{\\mu}_0=\\vec{0}$ and the prior covariance $\\vec{V}_0=\\vec{I}$, since we can capture non-zero mean by changing $\\vec{w}_{0j}$ and non-identity covariance by changing $\\vec{W}_r$. We will call this categorical PCA. See Chapter 27 TODO for a discussion of related models.\n\nIn (Khan et al. 2010), we show that this model outperforms finite mixture models on the task of imputing missing entries in design matrices consisting of real and categorical data. This is useful for analysing social science survey data, which often has missing data and variables of mixed type.\n\n\n\\section{PCA for paired and multi-view data}\n\n\n\\subsection{Supervised PCA (latent factor regression)}\n\n\n\\subsection{Discriminative supervised PCA}\n\n\n\\subsection{Canonical correlation analysis}\n\n\n\\section{Independent Component Analysis (ICA)}\n\\label{sec:ICA}\nLet $\\vec{x}_t \\in \\mathbb{R}^D$ be the observed signal at the sensors at “time” $t$, and $\\vec{z}_t \\in \\mathbb{R}^L$ be the vector of source signals. We assume that\n\\begin{equation}\n\\vec{x}_t=\\vec{W}\\vec{z}_t+\\vec{\\epsilon}_t\n\\end{equation}\nwhere $\\vec{W}$ is an $D \\times L$ matrix, and $\\vec{\\epsilon}_t \\sim \\mathcal{N}(\\vec{0},\\vec{\\Psi})$. In this section, we treat each time point as an independent observation, i.e., we do not model temporal correlation (so we could replace the $t$ index with $i$, but we stick with t to be consistent with much of the ICA literature). The goal is to infer the source signals, $p(\\vec{z}_t|\\vec{x}_t,\\vec{\\theta})$. In this context, $\\vec{W}$ is called the \\textbf{mixing matrix}. If $L=D$ (number of sources = number of sensors), it will be a square matrix. Often we will assume the noise level, $|\\vec{\\Psi}|$, is zero, for simplicity.\n\nSo far, the model is identical to factor analysis. However, we will use a different prior for $p(\\vec{z}_t)$. In PCA, we assume each source is independent, and has a Gaussian distribution. We will now relax this Gaussian assumption and let the source distributions be any \\emph{non-Gaussian} distribution\n\\begin{equation}\np(\\vec{z}_t) =\\prod\\limits_{j=1}^L p_j(z_{tj})\n\\end{equation}\nWithout loss of generality, we can constrain the variance of the source distributions to be \\vec{1}, because any other variance can be modelled by scaling the rows of $\\vec{W}$ appropriately. The resulting model is known as \\textbf{independent component analysis} or \\textbf{ICA}.\n\nThe reason the Gaussian distribution is disallowed as a source prior in ICA is that it does not permit unique recovery of the sources. This is because the PCA likelihood is invariant to any orthogonal transformation of the sources $\\vec{z}_t$ and mixing matrix $\\vec{W}$. PCA can recover the best linear subspace in which the signals lie, but cannot uniquely recover the signals themselves.\n\nICA requires that $\\vec{W}$ is square and hence invertible. In the non-square case (e.g., where we have more sources than sensors), we cannot uniquely recover the true signal, but we can compute the posterior $p(\\vec{z}_t|\\vec{x}_t,\\hat{\\vec{W}})$, which represents our beliefs about the source. In both cases, we need to estimate Was well as the source distributions $p_j$. We discuss how to do this below.\n\n\n\\subsection{Maximum likelihood estimation}\nIn this section, we discuss ways to estimate square mixing matrices $\\vec{W}$ for the noise-free ICA model. As usual, we will assume that the observations have been centered; hence we can also assume $\\vec{z}$ is zero-mean. In addition, we assume the observations have been whitened, which can be done with PCA. \n\nIf the data is centered and whitened, we have $\\mathbb{E}[\\vec{x}\\vec{x}^T]=\\vec{I}$. But in the noise free case, we also have\n\\begin{equation}\n\\mathrm{cov}[\\vec{x}]=\\mathbb{E}[\\vec{x}\\vec{x}^T]=\\vec{W}\\mathbb{E}[\\vec{z}\\vec{z}^T]\\vec{W}^T\n\\end{equation}\nHence we see that $\\vec{W}$ must be orthogonal. This reduces the number of parameters we have to estimate from $D^2$ to $D(D-1)/2$. It will also simplify the math and the algorithms.\n\nLet $\\vec{V}=\\vec{W}^{-1}$; these are often called the recognition weights, as opposed to $\\vec{W}$, which are the generative weights.\n\nSince $\\vec{x}=\\vec{W}\\vec{z}$, we have, from Equation \\ref{eqn:Multivariate-transformation},\n\\begin{align}\np_x(\\vec{W}\\vec{z}_t) & =p_z(\\vec{z}_t)|\\mathrm{det}(\\vec{W}^{-1})| \\nonumber \\\\\n   & = p_z(\\vec{V}\\vec{x}_t)|\\mathrm{det}(\\vec{V})|\n\\end{align}\nHence we can write the log-likelihood, assuming $T$ iid samples, as follows:\n\\begin{equation*}\n\\frac{1}{T} \\log p(\\mathcal{D}|\\vec{V})=\\log|\\mathrm{det}(\\vec{V})|+\\frac{1}{T}\\sum\\limits_{j=1}^L \\sum\\limits_{t=1}^T \\log p_j(\\vec{v}_j^T\\vec{x}_t)\n\\end{equation*}\nwhere $\\vec{v}_j$ is the $j$'th row of $\\vec{V}$. Since we are constraining $\\vec{V}$ to be orthogonal, the first term is a constant, so we can drop it. We can also replace the average over the data with an expectation operator to get the following objective\n\\begin{equation}\n\\mathrm{NLL}(\\vec{V})=\\sum\\limits_{j=1}^L \\mathbb{E}[G_j(\\vec{z}_j)]\n\\end{equation}\nwhere $\\vec{z}_j=\\vec{v}_j^T\\vec{x}$ and $G_j(\\vec{z}) \\triangleq -\\log p_j(\\vec{z})$. We want to minimize this subject to the constraint that the rows of $\\vec{V}$ are orthogonal. We also want them to be unit norm, since this ensures that the variance of the factors is unity (since, with whitened data, $\\mathbb{E}[\\vec{v}_j^T\\vec{x}]=\\lVert \\vec{v}_j \\rVert^2$, which is necessary to fix the scale of the weights. In otherwords, $\\vec{V}$ should be an orthonormal matrix.\n\nIt is straightforward to derive a gradient descent algorithm to fit this model; however, it is rather slow. One can also derive a faster algorithm that follows the natural gradient; see e.g., (MacKay 2003, ch 34) for details. A popular alternative is to use an approximate Newton method, which we discuss in Section \\ref{sec:FastICA}. Another approach is to use EM, which we discuss in Section \\ref{sec:ICA-EM}.\n\n\n\\subsection{The FastICA algorithm}\n\\label{sec:FastICA}\n\n\n\\subsection{Using EM}\n\\label{sec:ICA-EM}\n\n\n\\subsection{Other estimation principles *}\n\n"
  },
  {
    "path": "chapterLinearRegression.tex",
    "content": "\\chapter{Linear Regression}\n\n\n\\section{Introduction}\nLinear regression is the “work horse” of statistics and (supervised) machine learning. When augmented with kernels or other forms of basis function expansion, it can model also nonlinear relationships. And when the Gaussian output is replaced with a Bernoulli or multinoulli distribution, it can be used for classification, as we will see below. So it pays to study this model in detail.\n\n\n\\section{Representation}\n\n\\begin{equation}\np(y|\\vec{x},\\vec{\\theta})=\\mathcal{N}(y|\\vec{w}^T\\vec{x}, \\sigma^2)\n\\end{equation}\nwhere $\\vec{w}$ and $\\vec{x}$ are extended vectors, $\\vec{x}=(1,x)$, $\\vec{w}=(b,w)$.\n\nLinear regression can be made to model non-linear relationships by replacing $\\vec{x}$ with some non-linear function of the inputs, $\\phi(\\vec{x})$ \\begin{equation}\np(y|\\vec{x},\\vec{\\theta})=\\mathcal{N}(y|\\vec{w}^T\\phi(\\vec{x}), \\sigma^2)\n\\end{equation}\n\nThis is known as \\textbf{basis function expansion}. (Note that the model is still linear in the parameters $\\vec{w}$, so it is still called linear regression; the importance of this will become clear below.) A simple example are polynomial basis functions, where the model has the form\n\\begin{equation}\n\\phi(x)=(1, x, \\cdots, x^d)\n\\end{equation}\n\n\n\n\\section{MLE}\nInstead of maximizing the log-likelihood, we can equivalently minimize the \\textbf{negative log likelihood} or \\textbf{NLL}:\n\\begin{equation}\n\\text{NLL}(\\vec{\\theta}) \\triangleq -\\ell(\\vec{\\theta})=-\\log(\\mathcal{D}|\\vec{\\theta})\n\\end{equation}\n\nThe NLL formulation is sometimes more convenient, since many optimization software packages are designed to find the minima of functions, rather than maxima.\n\nNow let us apply the method of MLE to the linear regression setting. Inserting the definition of the Gaussian into the above, we find that the log likelihood is given by\n\\begin{align}\n\\ell(\\vec{\\theta})& =\\sum\\limits_{i=1}^N \\log\\left[\\dfrac{1}{\\sqrt{2\\pi}\\sigma}\\exp\\left(-\\dfrac{1}{2\\sigma^2}(y_i-\\vec{w}^T\\vec{x}_i)^2\\right)\\right] \\\\\n     & =-\\dfrac{1}{2\\sigma^2}\\text{RSS}(\\vec{w})-\\dfrac{N}{2}\\log(2\\pi\\sigma^2)\n\\end{align}\n\nRSS stands for \\textbf{residual sum of squares} and is defined by\n\\begin{equation}\n\\text{RSS}(\\vec{w}) \\triangleq \\sum\\limits_{i=1}^N (y_i-\\vec{w}^T\\vec{x}_i)^2\n\\end{equation}\n\nWe see that the MLE for $\\vec{w}$ is the one that minimizes the RSS, so this method is known as \\textbf{least squares}.\n\nLet's drop constants wrt $\\vec{w}$ and NLL can be written as\n\\begin{equation}\n\\text{NLL}(\\vec{w}) = \\dfrac{1}{2}\\sum\\limits_{i=1}^N (y_i-\\vec{w}^T\\vec{x}_i)^2\n\\end{equation}\n\nThere two ways to minimize NLL$(\\vec{w})$.\n\n\n\\subsection{OLS}\nDefine $\\vec{y}=(y_1,y_2,\\cdots,y_N)$, $\\vec{X}=\\left(\\begin{array}{c}\\vec{x}_1^T \\\\ \\vec{x}_2^T \\\\ \\vdots \\\\ \\vec{x}_N^T\\end{array}\\right)$, then NLL$(\\vec{w})$ can be written as\n\\begin{equation}\n\\text{NLL}(\\vec{w})=\\dfrac{1}{2}(\\vec{y}-\\vec{X}\\vec{w})^T(\\vec{y}-\\vec{X}\\vec{w})\n\\end{equation}\n\nWhen $\\mathcal{D}$ is small(for example, $N < 1000$), we can use the following equation to compute \\vec{w} directly\n\\begin{equation}\n\\hat{\\vec{w}}_{\\mathrm{OLS}}=(\\vec{X}^T\\vec{X})^{-1}\\vec{X}^T\\vec{y}\n\\end{equation}\n\nThe corresponding solution $\\hat{\\vec{w}}_{\\mathrm{OLS}}$ to this linear system of equations is called the \\textbf{ordinary least squares} or \\textbf{OLS} solution.\n\n\\begin{proof}\nWe now state without proof some facts of matrix derivatives (we won’t need all of these at this section).\n\\begin{eqnarray}\ntrA &\\triangleq& \\sum\\limits_{i=1}^n A_{ii} \\nonumber \\\\\n\\frac{\\partial}{\\partial A}AB &=& B^T \\\\\n\\frac{\\partial}{\\partial A^T}f(A) &=& \\left[\\frac{\\partial}{\\partial A}f(A)\\right]^T \\label{eqn:matrix-1} \\\\\n\\frac{\\partial}{\\partial A}ABA^TC &=& CAB+C^TAB^T \\label{eqn:matrix-2} \\\\\n\\frac{\\partial}{\\partial A}|A| &=& |A|(A^{-1})^T\n\\end{eqnarray}\n\nThen,\n\\begin{eqnarray*}\n\\text{NLL}(\\vec{w}) &=& \\frac{1}{2N}(\\vec{X}\\vec{w}-\\vec{y})^T(\\vec{X}\\vec{w}-\\vec{y}) \\\\\n\\frac{\\partial \\text{NLL}}{\\vec{w}} &=& \\frac{1}{2} \\frac{\\partial}{\\vec{w}} (\\vec{w}^T\\vec{X}^T\\vec{X}\\vec{w}-\\vec{w}^T\\vec{X}^T\\vec{y}-\\vec{y}^T\\vec{X}\\vec{w}+\\vec{y}^T\\vec{y}) \\\\\n                           &=& \\frac{1}{2} \\frac{\\partial}{\\vec{w}} (\\vec{w}^T\\vec{X}^T\\vec{X}\\vec{w}-\\vec{w}^T\\vec{X}^T\\vec{y}-\\vec{y}^T\\vec{X}\\vec{w}) \\\\\n\t\t\t\t\t\t   &=& \\frac{1}{2} \\frac{\\partial}{\\vec{w}} tr(\\vec{w}^T\\vec{X}^T\\vec{X}\\vec{w}-\\vec{w}^T\\vec{X}^T\\vec{y}-\\vec{y}^T\\vec{X}\\vec{w}) \\\\\n\t\t\t\t\t\t   &=& \\frac{1}{2} \\frac{\\partial}{\\vec{w}} (tr\\vec{w}^T\\vec{X}^T\\vec{X}\\vec{w}-2tr\\vec{y}^T\\vec{X}\\vec{w})\n\\end{eqnarray*}\n\nCombining Equations \\ref{eqn:matrix-1} and \\ref{eqn:matrix-2}, we find that \n\\begin{equation*}\n\\frac{\\partial}{\\partial A^T}ABA^TC = B^TA^TC^T+BA^TC\n\\end{equation*}\n\nLet $A^T=\\vec{w}, B=B^T=\\vec{X}^T\\vec{X}$, and $C=I$, Hence,\n\\begin{eqnarray}\n\\frac{\\partial \\text{NLL}}{\\vec{w}} &=& \\frac{1}{2} (\\vec{X}^T\\vec{X}\\vec{w}+\\vec{X}^T\\vec{X}\\vec{w} -2\\vec{X}^T\\vec{y}) \\nonumber \\\\\n\t\t\t\t\t\t   &=& \\frac{1}{2} (\\vec{X}^T\\vec{X}\\vec{w} - \\vec{X}^T\\vec{y}) \\nonumber \\\\\n\\frac{\\partial \\text{NLL}}{\\vec{w}} &=& 0 \\Rightarrow \\vec{X}^T\\vec{X}\\vec{w} - \\vec{X}^T\\vec{y} =0 \\nonumber \\\\\n\\vec{X}^T\\vec{X}\\vec{w} &=& \\vec{X}^T\\vec{y} \\label{eqn:normal-equation} \\\\\n\\hat{\\vec{w}}_{\\mathrm{OLS}} &=& (\\vec{X}^T\\vec{X})^{-1}\\vec{X}^T\\vec{y} \\nonumber\n\\end{eqnarray}\n\\end{proof}\n\nEquation \\ref{eqn:normal-equation} is known as the \\textbf{normal equation}.\n\n\n\\subsubsection{Geometric interpretation}\n\nSee Figure \\ref{fig:graphical-interpretation-of-OLS}.\n\\begin{figure}[hbtp]\n\\centering\n    \\includegraphics[scale=.50]{graphical-interpretation-of-OLS.png}\n\\caption{Graphical interpretation of least squares for $N=3$ examples and $D=2$ features. $\\tilde{\\vec{x}}_1$ and $\\tilde{\\vec{x}}_2$˜ are vectors in $\\mathbb{R}^3$; together they define a 2D plane. $\\vec{y}$ is also a vector in $\\mathbb{R}^3$ but does not lie on this 2D plane. The orthogonal projection of $\\vec{y}$ onto this plane is denoted $\\hat{\\vec{y}}$. The red line from $\\vec{y}$ to $\\hat{\\vec{y}}$ is the residual, whose norm we want to minimize. For visual clarity, all vectors have been converted to unit norm.}\n\\label{fig:graphical-interpretation-of-OLS} \n\\end{figure}\n\nTo minimize the norm of the residual, $\\vec{y}-\\hat{\\vec{y}}$, we want the residual vector to be orthogonal to every column of $\\vec{X}$,so˜ $\\tilde{\\vec{x}}_j(\\vec{y}-\\hat{\\vec{y}})=0$ for $j=1:D$. Hence\n\\begin{equation}\\begin{split}\n\\tilde{\\vec{x}}_j(\\vec{y}-\\hat{\\vec{y}})=0 & \\Rightarrow \\vec{X}^T(\\vec{y}-\\vec{X}\\vec{w})=0 \\\\\n                                           & \\Rightarrow \\vec{w}=(\\vec{X}^T\\vec{X})^{-1}\\vec{X}^T\\vec{y}\n\\end{split}\\end{equation}\n\n\n\\subsection{SGD}\nWhen $\\mathcal{D}$ is large, use stochastic gradient descent(SGD).\n\n\\begin{align}\n\\because \\dfrac{\\partial}{\\partial w_i}\\text{NLL}(\\vec{w})=& \\sum\\limits_{i=1}^N (\\vec{w}^T\\vec{x}_i-y_i)x_{ij} \\\\\n\\therefore w_j=& w_j - \\alpha\\dfrac{\\partial}{\\partial w_j}\\text{NLL}(\\vec{w}) \\nonumber \\\\\n                  =& w_j - \\sum\\limits_{i=1}^N \\alpha(\\vec{w}^T\\vec{x}_i-y_i)x_{ij} \\\\\n\\therefore \\vec{w}=& \\vec{w}-\\alpha(\\vec{w}^T\\vec{x}_i-y_i)\\vec{x}\n\\end{align}\n\n\n\\section{Ridge regression(MAP)}\nOne problem with ML estimation is that it can result in overfitting. In this section, we discuss a way to ameliorate this problem by using MAP estimation with a Gaussian prior.\n\n\n\\subsection{Basic idea}\nWe can encourage the parameters to be small, thus resulting in a smoother curve, by using a zero-mean Gaussian prior:\n\\begin{equation}\np(\\vec{w})=\\prod\\limits_j \\mathcal{N}(w_j|0,\\tau^2)\n\\end{equation}\nwhere $1/\\tau^2$ controls the strength of the prior. The corresponding MAP estimation problem becomes\n\\begin{equation}\n\\arg\\max_{\\vec{w}} \\sum\\limits_{i=1}^N \\log{\\mathcal{N}(y_i|w_0+\\vec{w}^T\\vec{x}_i,\\sigma^2)}+\\sum\\limits_{j=1}^D \\log{\\mathcal{N}(w_j|0,\\tau^2)}\n\\end{equation}\n\nIt is a simple exercise to show that this is equivalent to minimizing the following\n\\begin{equation}\\label{eqn:Ridge-regression-J}\nJ(\\vec{w})=\\dfrac{1}{N}\\sum\\limits_{i=1}^N (y_i-(w_0+\\vec{w}^T\\vec{x}_i))^2+\\lambda\\lVert\\vec{w}\\rVert^2 , \\lambda \\triangleq \\dfrac{\\sigma^2}{\\tau^2}\n\\end{equation}\n\nHere the first term is the MSE/ NLL as usual, and the second term, $\\lambda \\geq 0$, is a complexity penalty. The corresponding solution is given by\n\\begin{equation}\\label{eqn:Ridge-regression-solution}\n\\hat{\\vec{w}}_{\\mathrm{ridge}}=(\\lambda\\vec{I}_D+\\vec{X}^T\\vec{X})^{-1}\\vec{X}^T\\vec{y}\n\\end{equation}\n\nThis technique is known as \\textbf{ridge regression},or \\textbf{penalized least squares}. In general, adding a Gaussian prior to the parameters of a model to encourage them to be small is called $\\ell_2$ \\textbf{regularization} or \\textbf{weight decay}. Note that the offset term $w_0$ is not regularized, since this just affects the height of the function, not its complexity.\n\nWe will consider a variety of different priors in this book. Each of these corresponds to a different form of \\textbf{regularization}. This technique is very widely used to prevent overfitting.\n\n\n\\subsection{Numerically stable computation *}\n\n\\begin{equation}\\label{eqn:Ridge-regression-SVD}\n\\hat{\\vec{w}}_{\\mathrm{ridge}}=\\vec{V}(\\vec{Z}^T\\vec{Z}+\\lambda\\vec{I}_N)^{-1}\\vec{Z}^T\\vec{y}\n\\end{equation}\n\n\n\\subsection{Connection with PCA *}\n\n\n\\subsection{Regularization effects of big data}\nRegularization is the most common way to avoid overfitting. However, another effective approach — which is not always available — is to use lots of data. It should be intuitively obvious that the more training data we have, the better we will be able to learn.\n\nIn domains with lots of data, simple methods can work surprisingly well (Halevy et al. 2009). However, there are still reasons to study more sophisticated learning methods, because there will always be problems for which we have little data. For example, even in such a data-rich domain as web search, as soon as we want to start personalizing the results, the amount of data available for any given user starts to look small again (relative to the complexity of the problem).\n\n\n\\section{Bayesian linear regression}\nTODO\n\n"
  },
  {
    "path": "chapterLogisticRegression.tex",
    "content": "\\chapter{Logistic Regression}\n\n\n\\section{Representation}\nLogistic regression can be binomial or multinomial. The \\textbf{binomial logistic regression} model has the following form\n\\begin{equation}\np(y|\\vec{x},\\vec{w})=\\mathrm{Ber}(y|\\mathrm{sigm}(\\vec{w}^T\\vec{x}))\n\\end{equation}\nwhere $\\vec{w}$ and $\\vec{x}$ are extended vectors, i.e., $\\vec{w}=(b, w_1, w_2,\\cdots, w_D)$, $\\vec{x}=(1, x_1, x_2,\\cdots, x_D)$.\n\n\n\\section{Optimization}\n\\label{sec:binomial-LR-Optimization}\n\n\\subsection{MLE}\n\\begin{align}\n\\ell(\\vec{w}) &= \\log\\left\\{\\prod\\limits_{i=1}^N{\\left[\\pi(\\vec{x}_i)\\right]^{y_i}\\left[1-\\pi(\\vec{x}_i)\\right]^{1-y_i}}\\right\\} \\nonumber \\\\\n              & \\quad \\text{, where } \\pi(\\vec{x}) \\triangleq P(y=1|\\vec{x},\\vec{w}) \\nonumber \\\\\n           &= \\sum\\limits_{i=1}^N\\left[y_i\\log\\pi(\\vec{x}_i)+(1-y_i)\\log(1-\\pi(\\vec{x}_i))\\right] \\label{eqn:cross-entropy-error} \\nonumber \\\\\n\t\t   &= \\sum\\limits_{i=1}^N\\left[y_i\\log\\dfrac{\\pi(\\vec{x}_i)}{1-\\pi(\\vec{x}_i)}+\\log(1-\\pi(\\vec{x}_i))\\right] \\nonumber \\\\\n\t\t   &= \\sum\\limits_{i=1}^N\\left[y_i(\\vec{w}\\cdot\\vec{x}_i)-\\log(1+\\exp(\\vec{w}\\cdot\\vec{x}_i))\\right] \\nonumber \\\\\nJ(\\vec{w}) & \\triangleq \\mathrm{NLL}(\\vec{w})= -\\ell(\\vec{w}) \\nonumber \\\\\n           & = -\\sum\\limits_{i=1}^N\\left[y_i(\\vec{w}\\cdot\\vec{x}_i)-\\log(1+\\exp(\\vec{w}\\cdot\\vec{x}_i))\\right] \n\\end{align}\n\nEquation \\ref{eqn:cross-entropy-error} is also called the \\textbf{cross-entropy} error function (see Equation \\ref{eqn:cross-entropy}).\n\nUnlike linear regression, we can no longer write down the MLE in closed form. Instead, we need to use an optimization algorithm to compute it, see Appendix \\ref{chap:Optimization-methods}. For this, we need to derive the gradient and Hessian.\n\nIn the case of logistic regression, one can show that the gradient and Hessian of this are given by the following\n\\begin{align}\n\\vec{g}(\\vec{w}) &= \\dfrac{\\mathrm{d} J}{\\mathrm{d} \\vec{w}} = \\sum\\limits_{i=1}^N \\left[\\pi(\\vec{x}_i) - y_i \\right]\\vec{x}_i = \\vec{X}(\\vec{\\pi}-\\vec{y})\\\\\n\\vec{H}(\\vec{w}) &= \\dfrac{\\mathrm{d} \\vec{g}^T}{\\mathrm{d} \\vec{w}}= \\dfrac{\\mathrm{d}}{\\mathrm{d} \\vec{w}} (\\vec{\\pi}-\\vec{y})^T\\vec{X}^T \\nonumber \\\\\n        &= \\dfrac{\\mathrm{d}}{\\mathrm{d} \\vec{w}} \\vec{\\pi}^T\\vec{X}^T \\nonumber \\\\\n\t\t&= (\\pi(\\vec{x}_i)(1-\\pi(\\vec{x}_i))\\vec{x}_i, \\cdots,)\\vec{X}^T \\nonumber \\\\\n\t\t&= \\vec{X}\\vec{S}\\vec{X}^T, \\quad \\vec{S} \\triangleq \\mathrm{diag}(\\pi(\\vec{x}_i)(1-\\pi(\\vec{x}_i))\\vec{x}_i)\n\\end{align}\n\n\n\\subsubsection{Iteratively reweighted least squares (IRLS)}\n\\label{sec:IRLS}\nTODO\n\n\n\\subsection{MAP}\nJust as we prefer ridge regression to linear regression, so we should prefer MAP estimation for logistic regression to computing the MLE. \n$\\ell_2$ regularization\n\nwe can use $\\ell_2$ regularization, just as we did with ridge regression. We note that the new objective, gradient and Hessian have the following forms:\n\\begin{align}\nJ'(\\vec{w}) & \\triangleq \\mathrm{NLL}(\\vec{w})+\\lambda \\vec{w}^T\\vec{w} \\\\\n\\vec{g}'(\\vec{w}) &= \\vec{g}(\\vec{w})+\\lambda\\vec{w} \\\\\n\\vec{H}'(\\vec{w}) &= \\vec{H}(\\vec{w})+\\lambda\\vec{I}\n\\end{align}\n\nIt is a simple matter to pass these modified equations into any gradient-based optimizer.\n\n\n\\section{Multinomial logistic regression}\n\n\n\\subsection{Representation}\n\\textbf{Multinomial logistic regression} model is also called a \\textbf{maximum entropy classifier}, which has the following form\n\\begin{align}\np(y=c|\\vec{x},\\vec{W}) & =\\dfrac{\\exp(\\vec{w}_c^T\\vec{x})}{\\sum_{c=1}^C \\exp(\\vec{w}_c^T\\vec{x})}\n\\end{align}\n\n\n\\subsection{MLE}\nLet $\\vec{y}_i=(\\mathbb{I}(y_i=1),\\mathbb{I}(y_i=1),\\cdots, \\mathbb{I}(y_i=C))$, $\\vec{\\mu}_i=(p(y=1|\\vec{x}_i,\\vec{W}),p(y=2|\\vec{x}_i,\\vec{W}),\\cdots, p(y=C|\\vec{x}_i,\\vec{W}))$, then the log-likelihood function can be written as\n\\begin{align}\n\\ell(\\vec{W}) & =\\log\\prod\\limits_{i=1}^N\\prod\\limits_{c=1}^C \\mu_{ic}^{y_{ic}}=\\sum\\limits_{i=1}^N\\sum\\limits_{c=1}^C y_{ic}\\log \\mu_{ic} \\\\\n     & = \\sum\\limits_{i=1}^N\\left[\\left(\\sum\\limits_{c=1}^C y_{ic}\\vec{w}_c^T\\vec{x}_i\\right)-\\log\\left(\\sum\\limits_{c=1}^C \\exp(\\vec{w}_c^T\\vec{x}_i)\\right)\\right]\n\\end{align}\n\nDefine the objective function as NLL\n\\begin{equation}\nJ(\\vec{W})=\\mathrm{NLL}(\\vec{W})=-\\ell(\\vec{W})\n\\end{equation}\n\nDefine $\\vec{A} \\otimes \\vec{B}$ be the \\textbf{kronecker product} of matrices $\\vec{A}$ and $\\vec{B}$.If $\\vec{A}$ is an $m \\times n$ matrix and $\\vec{B}$ is a $p \\times q$ matrix, then $\\vec{A} \\otimes \\vec{B}$ is the $mp \\times nq$ block matrix\n\\begin{equation}\n\\vec{A} \\otimes \\vec{B} \\triangle \\left(\\begin{array}{ccc}\na_{11}\\vec{B} & \\cdots & a_{1n}\\vec{B} \\\\\n\\vdots & \\vdots & \\vdots \\\\\na_{m1}\\vec{B} & \\cdots & a_{mn}\\vec{B}\n\\end{array}\\right)\n\\end{equation}\n\nThe gradient and Hessian are given by\n\\begin{align}\n\\vec{g}(\\vec{W}) & =\\sum\\limits_{i=1}^N (\\vec{\\mu}-\\vec{y}_i) \\otimes \\vec{x}_i \\\\\n\\vec{H}(\\vec{W}) & =\\sum\\limits_{i=1}^N (\\mathrm{diag}(\\vec{\\mu}_i)-\\vec{\\mu}_i\\vec{\\mu}_i^T) \\otimes (\\vec{x}_i\\vec{x}_i^T)\n\\end{align}\nwhere $\\vec{y}_i=(\\mathbb{I}(y_i=1),\\mathbb{I}(y_i=1),\\cdots, \\mathbb{I}(y_i=C-1))$ and $\\vec{\\mu}_i=(p(y=1|\\vec{x}_i,\\vec{W}),p(y=2|\\vec{x}_i,\\vec{W}),\\cdots, p(y=C-1|\\vec{x}_i,\\vec{W}))$ are column vectors of length $C-1$.\n\nPass them to any gradient-based optimizer.\n\n\n\\subsection{MAP}\nThe new objective\n\\begin{align}\nJ'(\\vec{W}) & =\\mathrm{NLL}(\\vec{w})-\\log{p(\\vec{W})} \\\\\n            & \\quad \\text{, where } p(\\vec{W}) \\triangleq \\prod\\limits_{c=1}^C \\mathcal{N}(\\vec{w}_c|\\vec{0},\\vec{V}_0) \\nonumber \\\\\n   & = J(\\vec{W})+\\dfrac{1}{2}\\sum\\limits_{c=1}^C \\vec{w}_c\\vec{V}_0^{-1}\\vec{w}_c \\\\\n\\end{align}\n\nIts gradient and Hessian are given by\n\\begin{align}\n\\vec{g}'(\\vec{w}) & =\\vec{g}(\\vec{W})+\\vec{V}_0^{-1}\\left(\\sum\\limits_{c=1}^C \\vec{w}_c\\right) \\\\\n\\vec{H}'(\\vec{w}) & =\\vec{H}(\\vec{w})+\\vec{I_C} \\otimes \\vec{V}_0^{-1}\n\\end{align}\n\nThis can be passed to any gradient-based optimizer to find the MAP estimate. Note, however, that the Hessian has size $((CD)×(CD))$, which is $C$ times more row and columns than in the binary case, so limited memory BFGS is more appropriate than Newton’s method.\n\n\n\\section{Bayesian logistic regression}\nIt is natural to want to compute the full posterior over the parameters, $p(\\vec{w}|\\mathcal{D})$, for logistic regression models. This can be useful for any situation where we want to associate confidence intervals with our predictions (e.g., this is necessary when solving contextual bandit problems, discussed in Section TODO).\n\nUnfortunately, unlike the linear regression case, this cannot be done exactly, since there is no convenient conjugate prior for logistic regression. We discuss one simple approximation below; some other approaches include MCMC (Section TODO), variational inference (Section TODO), expectation propagation (Kuss and Rasmussen 2005), etc. For notational simplicity, we stick to binary logistic regression.\n\n\n\\subsection{Laplace approximation}\n\n\n\\subsection{Derivation of the BIC}\n\n\n\\subsection{Gaussian approximation for logistic regression}\n\\label{sec:Gaussian-approximation-for-logistic-regression}\n\n\n\\subsection{Approximating the posterior predictive}\n\n\n\\subsection{Residual analysis (outlier detection) *}\n\n\n\\section{Online learning and stochastic optimization}\nTraditionally machine learning is performed \\textbf{offline}, however, if we have \\textbf{streaming data}, we need to perform \\textbf{online learning}, so we can update our estimates as each new data point arrives rather than waiting until “the end” (which may never occur). And even if we have a batch of data, we might want to treat it like a stream if it is too large to hold in main memory. Below we discuss learning methods for this kind of scenario.\n\nTODO\n\n\n\\subsection{The perceptron algorithm}\n\n\\subsubsection{Representation}\n\\begin{equation}\n\\mathcal{H}:y=f(\\vec{x})=\\text{sign}(\\vec{w}^T\\vec{x}+b)\n\\end{equation}\nwhere $\\text{sign}(x)=\\begin{cases}+1, & x \\geq 0\\\\-1, & x<0\\\\\\end{cases}$, see Fig. \\ref{fig:perceptron}\\footnote{\\url{https://en.wikipedia.org/wiki/Perceptron}}.\n\n\\begin{figure}[hbtp]\n\\centering\n    \\includegraphics[scale=.50]{perceptron.png}\n\\caption{Perceptron}\n\\label{fig:perceptron} \n\\end{figure}\n\n\n\\subsubsection{Evaluation}\n\\begin{eqnarray}\nL(\\vec{w},b)&=&-y_i(\\vec{w}^T\\vec{x}_i+b)\\\\\nR_{emp}(f)&=&-\\sum\\limits_i y_i(\\vec{w}^T\\vec{x}_i+b)\\\\\n\\end{eqnarray}\n\n\n\\subsubsection{Optimization}\n\\textbf{Primal form}\n\\begin{algorithm}[htbp]\n\\caption{Perceptron learning algorithm, primal form, using SGD}\n  \n    $\\vec{w} \\leftarrow 0;\\; b \\leftarrow 0;\\; k \\leftarrow 0$\\;\n    \\While{no mistakes made within the for loop}{\n        \\For{$i\\leftarrow 1$ \\KwTo $N$}{\n\t\t\t\\If{$y_i(\\vec{w} \\cdot \\vec{x}_i+b) \\leq 0$}{\n\t\t\t\t$\\vec{w} \\leftarrow \\vec{w}+\\eta y_i \\vec{x}_i$\\;\n\t\t\t\t$b \\leftarrow b+\\eta y_i$\\;\n\t\t\t\t$k \\leftarrow k+1$\\;\n\t\t\t}\n\t\t}\n    }\n\\end{algorithm}\n\n\\textbf{Convergency}\n\\begin{theorem}\n(\\textbf{Novikoff}) If traning data set $\\mathcal{D}$ is linearly separable, then\n\\begin{enumerate}\n\\item There exists a hyperplane denoted as $\\widehat{\\vec{w}}_{opt} \\cdot \\vec{x}+b_{opt}=0$ which can correctly seperate all samples, and \n\\begin{equation}\n\\exists\\gamma>0,\\; \\forall i, \\; y_i(\\vec{w}_{opt} \\cdot \\vec{x}_i+b_{opt}) \\geq \\gamma\n\\end{equation}\n\\item \\begin{equation}k \\leq \\left(\\dfrac{R}{\\gamma}\\right)^2,\\text{ where } R=\\max\\limits_{1 \\leq i \\leq N} \\abs{\\abs{\\widehat{\\vec{x}}_i}}\n\\end{equation}\n\\end{enumerate}\n\\end{theorem}\n\n\\begin{proof}\n(1) let $\\gamma=\\min\\limits_{i} y_i(\\vec{w}_{opt} \\cdot \\vec{x}_i+b_{opt})$, then we get $y_i(\\vec{w}_{opt} \\cdot \\vec{x}_i+b_{opt}) \\geq \\gamma$.\n\n(2) The algorithm start from $\\widehat{\\vec{x}}_0=0$, if a instance is misclassified, then update the weight. Let $\\widehat{\\vec{w}}_{k-1}$ denotes the extended weight before the k-th misclassified instance, then we can get\n\\begin{eqnarray}\ny_i(\\widehat{\\vec{w}}_{k-1} \\cdot \\widehat{\\vec{x}_i})&=&y_i(\\vec{w}_{k-1} \\cdot \\vec{x}_i+b_{k-1}) \\leq 0\\\\\n\\widehat{\\vec{w}}_k&=&\\widehat{\\vec{w}}_{k-1}+\\eta y_i \\widehat{\\vec{x}_i}\n\\end{eqnarray}\n\nWe could infer the following two equations, the proof procedure are omitted.\n\\begin{enumerate}\n\\item $\\widehat{\\vec{w}}_k \\cdot \\widehat{\\vec{w}}_{opt} \\geq k\\eta\\gamma$\n\\item $\\abs{\\abs{\\widehat{\\vec{w}}_k}}^2 \\leq k\\eta^2R^2$\n\\end{enumerate}\n\nFrom above two equations we get\n\\begin{eqnarray}\n\\nonumber k\\eta\\gamma & \\leq & \\widehat{\\vec{w}}_k \\cdot \\widehat{\\vec{w}}_{opt} \\leq \\abs{\\abs{\\widehat{\\vec{w}}_k}}\\abs{\\abs{\\widehat{\\vec{w}}_{opt}}} \\leq \\sqrt k \\eta R \\\\\n\\nonumber k^2\\gamma^2 & \\leq & kR^2 \\\\\n\\nonumber \\text{i.e. } k & \\leq & \\left(\\dfrac{R}{\\gamma}\\right)^2\n\\end{eqnarray}\n\\end{proof}\n\n\n\\textbf{Dual form}\n\\begin{eqnarray}\n\\vec{w}&=&\\sum\\limits_{i=1}^{N} \\alpha_iy_i\\vec{x}_i \\\\\nb&=&\\sum\\limits_{i=1}^{N} \\alpha_iy_i \\\\\nf(\\vec{x})&=&\\text{sign}\\left(\\sum\\limits_{j=1}^{N} \\alpha_jy_j\\vec{x}_j \\cdot \\vec{x}+b\\right)\n\\end{eqnarray}\n\n\\begin{algorithm}[htbp]\n    %\\SetAlgoLined\n    \\SetAlgoNoLine\n  \n    $\\vec{\\alpha} \\leftarrow 0;\\; b \\leftarrow 0;\\; k \\leftarrow 0$\\;\n    \\While{no mistakes made within the for loop}{\n        \\For{$i\\leftarrow 1$ \\KwTo $N$}{\n\t\t\t\\If{$y_i\\left(\\sum\\limits_{j=1}^{N} \\alpha_jy_j\\vec{x}_j \\cdot \\vec{x}_i+b\\right) \\leq 0$}{\n\t\t\t\t$\\vec{\\alpha} \\leftarrow \\vec{\\alpha}+\\eta$\\;\n\t\t\t\t$b \\leftarrow b+\\eta y_i$\\;\n\t\t\t\t$k \\leftarrow k+1$\\;\n\t\t\t}\n\t\t}\n    }\n\\caption{Perceptron learning algorithm, dual form}\n\\end{algorithm}\n\n\n\\section{Generative vs discriminative classifiers}\n\n\n\\subsection{Pros and cons of each approach}\n\\begin{itemize}\n\\item{\\textbf{Easy to fit?} As we have seen, it is usually very easy to fit generative classifiers. For example, in Sections \\ref{sec:NBC-Optimization} and \\ref{sec:MLE-for-discriminant-analysis}, we show that we can fit a naive Bayes model and an LDA model by simple counting and averaging. By contrast, logistic regression requires solving a convex optimization problem (see Section \\ref{sec:binomial-LR-Optimization} for the details), which is much slower.}\n\n\\item{\\textbf{Fit classes separately?} In a generative classifier, we estimate the parameters of each class conditional density independently, so we do not have to retrain the model when we add more classes. In contrast, in discriminative models, all the parameters interact, so the whole model must be retrained if we add a new class. (This is also the case if we train a generative model to maximize a discriminative objective Salojarvi et al. (2005).)}\n\n\\item{\\textbf{Handle missing features easily?} Sometimes some of the inputs (components ofx) are not observed. In a generative classifier, there is a simple method for dealing with this, as we discuss in Section \\ref{sec:Dealing-with-missing-data}. However, in a discriminative classifier, there is no principled solution to this problem, since the model assumes that $\\vec{x}$is always available to be conditioned on (although see (Marlin 2008) for some heuristic approaches).}\n\n\\item{\\textbf{Can handle unlabeled training data?} There is much interest in \\textbf{semi-supervised learning}, which uses unlabeled data to help solve a supervised task. This is fairly easy to do using generative models (see e.g., (Lasserre et al. 2006; Liang et al. 2007)), but is much harder to do with discriminative models.}\n\n\\item{\\textbf{Symmetric in inputs and outputs?} We can run a generative model “backwards”, and infer probable inputs given the output by computing $p(\\vec{x}|y)$. This is not possible with a discriminative model. The reason is that a generative model defines a joint distribution on $\\vec{x}$ and $y$, and hence treats both inputs and outputs symmetrically.}\n\n\\item{\\textbf{Can handle feature preprocessing?} A big advantage of discriminative methods is that they allow us to preprocess the input in arbitrary ways, e.g., we can replace $\\vec{x}$ with $\\phi(\\vec{x})$, which could be some basis function expansion, etc. It is often hard to define a generative model on such pre-processed data, since the new features are correlated in complex ways.}\n\n\\item{\\textbf{Well-calibrated probabilities?} Some generative models, such as naive Bayes, make strong independence assumptions which are often not valid. This can result in very extreme posterior class probabilities (very near 0 or 1). Discriminative models, such as logistic regression, are usually better calibrated in terms of their probability estimates.}\n\\end{itemize}\n\nSee Table \\ref{tab:List-of-various-models-for-classification} for a summary of the classification and regression techniques we cover in this book.\n\n\\begin{table*}\n\\centering\n\\begin{tabular}{lllll}\n\\hline\\noalign{\\smallskip}\n\\textbf{Model} & \\textbf{Classif/regr} & \\textbf{Gen/Discr} & \\textbf{Param/Non} & \\textbf{Section} \\\\\n\\noalign{\\smallskip}\\svhline\\noalign{\\smallskip}\nDiscriminant analysis & Classif & Gen & Param & Sec. \\ref{sec:Linear-discriminant-analysis}, \\ref{sec:MLE-for-discriminant-analysis} \\\\\nNaive Bayes classifier & Classif & Gen & Param & Sec. \\ref{sec:NBC}, \\ref{sec:Bayesian-naive-Bayes} \\\\\nTree-augmented Naive Bayes classifier & Classif & Gen & Param & Sec. 10.2.1 \\\\\nLinear regression & Regr & Discrim & Param & Sec. 1.4.5, 7.3, 7.6 \\\\\nLogistic regression & Classif & Discrim & Param & Sec. 1.4.6, \\ref{sec:IRLS}, \\ref{sec:Gaussian-approximation-for-logistic-regression}, 21.8.1.1 \\\\\nSparse linear/ logistic regression & Both & Discrim & Param & Ch. 13 \\\\\nMixture of experts & Both & Discrim & Param & Sec. 11.2.4 \\\\\nMultilayer perceptron (MLP)/ Neural network & Both & Discrim & Param & Ch. 16 \\\\\nConditional random field (CRF) & Classif & Discrim & Param & Sec. 19.6 \\\\\n\\noalign{\\smallskip}\\hline \\\\\n$K$ nearest neighbor classifier & Classif & Gen & Non & Sec. TODO, TODO \\\\\n(Infinite) Mixture Discriminant analysis & Classif & Gen & Non & Sec. 14.7.3 \\\\\nClassification and regression trees (CART) & Both & Discrim & Non & Sec. 16.2 \\\\\nBoosted model & Both & Discrim & Non & Sec. 16.4 \\\\\nSparse kernelized lin/logreg (SKLR) & Both & Discrim & Non & Sec. 14.3.2 \\\\\nRelevance vector machine (RVM) & Both & Discrim & Non & Sec. 14.3.2 \\\\\nSupport vector machine (SVM) & Both & Discrim & Non & Sec. 14.5 \\\\\nGaussian processes (GP) & Both & Discrim & Non & Ch. 15 \\\\\nSmoothing splines & Regr & Discrim & Non & Section 15.4.6 \\\\\n\\noalign{\\smallskip}\\hline\n\\end{tabular}\n\\caption{List of various models for classification and regression which we discuss in this book. Columns are as follows: Model name; is the model suitable for classification, regression, or both; is the model generative or discriminative; is the model parametric or non-parametric; list of sections in book which discuss the model. See also \\url{http://pmtk3.googlecode.com/svn/trunk/docs/tutorial/html/tutSupervised.html} for the PMTK equivalents of these models. Any generative probabilistic model (e.g., HMMs, Boltzmann machines, Bayesian networks, etc.) can be turned into a classifier by using it as a class conditional density}\n\\label{tab:List-of-various-models-for-classification}\n\\end{table*}\n\n\n\\subsection{Dealing with missing data}\n\\label{sec:Dealing-with-missing-data}\nSometimes some of the inputs (components of $\\vec{x}$) are not observed; this could be due to a sensor failure, or a failure to complete an entry in a survey, etc. This is called the \\textbf{missing data problem} (Little. and Rubin 1987). The ability to handle missing data in a principled way is one of the biggest advantages of generative models.\n\nTo formalize our assumptions, we can associate a binary response variable $r_i \\in \\{0,1\\}$ that specifies whether each value $\\vec{x}_i$ is observed or not. The joint model has the form $p(\\vec{x}_i,r_i|\\vec{\\theta},\\vec{\\phi})=p(r_i|\\vec{x}_i,\\vec{\\phi})p(\\vec{x}_i|\\vec{\\theta})$, where $\\vec{\\phi}$ are the parameters controlling whether the item is observed or not. \n\\begin{itemize}\n\\item{If we assume $p(r_i|\\vec{x}_i,\\vec{\\phi})=p(r_i|\\vec{\\phi})$, we say the data is \\textbf{missing completely at random} or \\textbf{MCAR}.}\n\\item{If we assume $p(r_i|\\vec{x}_i,\\vec{\\phi})=p(r_i|\\vec{x}_i^o,\\vec{\\phi})$, where $\\vec{x}_i^o$ is the observed part of $\\vec{x}_i$, we say the data is \\textbf{missing at random} or \\textbf{MAR}.}\n\\item{If neither of these assumptions hold, we say the data is \\textbf{not missing at random} or \\textbf{NMAR}. In this case, we have to model the missing data mechanism, since the pattern of missingness is informative about the values of the missing data and the corresponding parameters. This is the case in most collaborative filtering problems, for example.}\n\\end{itemize}\n\nSee e.g., (Marlin 2008) for further discussion. We will henceforth assume the data is MAR.\n\nWhen dealing with missing data, it is helpful to distinguish the cases when there is missingness only at test time (so the training data is \\textbf{complete data}), from the harder case when there is missingness also at training time. We will discuss these two cases below. Note that the class label is always missing at test time, by definition; if the class label is also sometimes missing at training time, the problem is called semi-supervised learning.\n\n\n\\subsubsection{Missing data at test time}\nIn a generative classifier, we can handle features that are MAR by marginalizing them out. For example, if we are missing the value ofx1, we can compute\n\\begin{align}\np(y=c|\\vec{x}_{2:D},\\vec{\\theta}) & \\propto p(y=c|\\vec{\\theta})p(\\vec{x}_{2:D}|y=c,\\vec{\\theta}) \\\\\n      & = \\propto p(y=c|\\vec{\\theta})\\sum\\limits_{x_1}p(x_1, \\vec{x}_{2:D}|y=c,\\vec{\\theta})\n\\end{align}\n\nSimilarly, in discriminant analysis, no matter what regularization method was used to estimate the parameters, we can always analytically marginalize out the missing variables (see Section \\ref{sec:Inference-in-jointly-Gaussian-distributions}):\n\\begin{equation}\np(\\vec{x}_{2:D}|y=c,\\vec{\\theta})=\\mathcal{N}(\\vec{x}_{2:D}|\\vec{\\mu}_{c,2:D},\\vec{\\Sigma}_{c,2:D})\n\\end{equation}\n\n\n\\subsubsection{Missing data at training time}\nMissing data at training time is harder to deal with. In particular, computing the MLE or MAP estimate is no longer a simple optimization problem, for reasons discussed in Section TODO. However, soon we will study are a variety of more sophisticated algorithms (such as EM algorithm, in Section 11.4) for finding approximate ML or MAP estimates in such cases.\n\n\n\\subsection{Fisher’s linear discriminant analysis (FLDA) *}\nTODO"
  },
  {
    "path": "chapterMCMC.tex",
    "content": "\\chapter{Markov chain Monte Carlo (MCMC)inference}\n\n\n\\section{Introduction}\nIn Chapter \\ref{chap:Monte-Carlo-inference}, we introduced some simple Monte Carlo methods, including rejection sampling and importance sampling. The trouble with these methods is that they do not work well in high dimensional spaces. The most popular method for sampling from high-dimensional distributions is \\textbf{Markov chain Monte Carlo} or \\textbf{MCMC}.\n\nThe basic idea behind MCMC is to construct a Markov chain (Section \\ref{sec:Markov-models}) on the state space $\\mathcal{X}$ whose stationary distribution is the target density $p^*(\\vec{x})$ of interest (this may be a prior or a posterior). That is, we perform a random walk on the state space, in such a way that the fraction of time we spend in each state $\\vec{x}$ is proportional to $p^*(\\vec{x})$. By drawing (correlated!) samples $\\vec{x}_0, \\vec{x}_1, \\vec{x}_2, \\cdots$ from the chain, we can perform Monte Carlo integration wrt $p^*$.\n\n\n\\section{Metropolis Hastings algorithm}\n\n\n\\section{Gibbs sampling}\n\n\n\\section{Speed and accuracy of MCMC}\n\n\n\\section{Auxiliary variable MCMC *}\n\n"
  },
  {
    "path": "chapterMVN.tex",
    "content": "\\chapter{Gaussian Models}\n\\label{chap:MVN}\n\nIn this chapter, we discuss the \\textbf{multivariate Gaussian} or \\textbf{multivariate normal(MVN)}, which is the most widely used joint probability density function for continuous variables. It will form the basis for many of the models we will encounter in later chapters.\n\n\n\\section{Basics}\nRecall from Section \\ref{sec:MVN} that the pdf for an MVN in $D$ dimensions is defined by the following:\n\\begin{equation}\n\\mathcal{N}(\\vec{x}|\\vec{\\mu},\\Sigma) \\triangleq \\dfrac{1}{(2\\pi)^{\\frac{D}{2}}|\\Sigma|^{\\frac{1}{2}}}\\exp\\left[-\\dfrac{1}{2}(\\vec{x}-\\vec{\\mu})^T\\Sigma^{-1}(\\vec{x}-\\vec{\\mu})\\right]\n\\end{equation}\n\nThe expression inside the exponent is the Mahalanobis distance between a data vector $\\vec{x}$ and the mean vector $\\vec{\\mu}$, We can gain a better understanding of this quantity by performing an \\textbf{eigendecomposition} of $\\vec{\\Sigma}$. That is, we write $\\vec{\\Sigma}=\\vec{U}\\vec{\\Lambda}\\vec{U}^T$, where $\\vec{U}$ is an orthonormal matrix of eigenvectors satsifying $\\vec{U}^T\\vec{U}=\\vec{I}$, and $\\vec{\\Lambda}$ is a diagonal matrix of eigenvalues. Using the eigendecomposition, we have that\n\\begin{equation}\n\\vec{\\Sigma}^{-1}=\\vec{U}^{-T}\\vec{\\Lambda}^{-1}\\vec{U}^{-1}=\\vec{U}\\vec{\\Lambda}^{-1}\\vec{U}^T=\\sum\\limits_{i=1}^D \\dfrac{1}{\\lambda_i}\\vec{u}_i\\vec{u}_i^T\n\\end{equation}\nwhere $\\vec{u}_i$ is the $i$'th column of $\\vec{U}$, containing the $i$'th eigenvector. Hence we can rewrite the Mahalanobis distance as follows:\n\\begin{align}\n(\\vec{x}-\\vec{\\mu})^T\\Sigma^{-1}(\\vec{x}-\\vec{\\mu}) & =(\\vec{x}-\\vec{\\mu})^T\\left(\\sum\\limits_{i=1}^D \\dfrac{1}{\\lambda_i}\\vec{u}_i\\vec{u}_i^T\\right)(\\vec{x}-\\vec{\\mu}) \\\\\n    & =\\sum\\limits_{i=1}^D \\dfrac{1}{\\lambda_i}(\\vec{x}-\\vec{\\mu})^T\\vec{u}_i\\vec{u}_i^T(\\vec{x}-\\vec{\\mu}) \\\\\n\t& =\\sum\\limits_{i=1}^D \\dfrac{y_i^2}{\\lambda_i}\n\\end{align}\nwhere $y_i \\triangleq \\vec{u}_i^T(\\vec{x}-\\vec{\\mu})$. Recall that the equation for an ellipse in 2d is\n\\begin{equation}\n\\dfrac{y_1^2}{\\lambda_1}+\\dfrac{y_2^2}{\\lambda_2}=1\n\\end{equation}\n\nHence we see that the contours of equal probability density of a Gaussian lie along ellipses. This is illustrated in Figure \\ref{fig:2d-MVN}. The eigenvectors determine the orientation of the ellipse, and the eigenvalues determine how elogonated it is.\n\n\\begin{figure}[hbtp]\n\\centering\n    \\includegraphics[scale=.70]{2d-MVN.png}\n\\caption{Visualization of a 2 dimensional Gaussian density. The major and minor axes of the ellipse are defined by the first two eigenvectors of the covariance matrix, namely $\\vec{u}_1$ and $\\vec{u}_2$. Based on Figure 2.7 of (Bishop 2006a)}\n\\label{fig:2d-MVN} \n\\end{figure}\n\nIn general, we see that the Mahalanobis distance corresponds to Euclidean distance in a transformed coordinate system, where we shift by $\\vec{\\mu}$ and rotate by $\\vec{U}$.\n\n\n\\subsection{MLE for a MVN}\n\\begin{theorem}(\\textbf{MLE for a MVN})\nIf we have $N$ iid samples $\\vec{x}_i \\sim \\mathcal{N}(\\vec{\\mu},\\vec{\\Sigma})$, then the MLE for the parameters is given by\n\\begin{align}\n\\bar{\\vec{\\mu}}    & =\\dfrac{1}{N}\\sum\\limits_{i=1}^N \\vec{x}_i \\triangleq \\bar{\\vec{x}} \\\\\n\\bar{\\vec{\\Sigma}} & =\\dfrac{1}{N}\\sum\\limits_{i=1}^N (\\vec{x}_i-\\bar{\\vec{x}})(\\vec{x}_i-\\bar{\\vec{x}})^T \\\\\n                     & =\\dfrac{1}{N}\\left(\\sum\\limits_{i=1}^N \\vec{x}_i\\vec{x}_i^T\\right)-\\bar{\\vec{x}}\\bar{\\vec{x}}^T\n\\end{align}\n\\end{theorem}\n\n\n\\subsection{Maximum entropy derivation of the Gaussian *}\nIn this section, we show that the multivariate Gaussian is the distribution with maximum entropy subject to having a specified mean and covariance (see also Section TODO). This is one reason the Gaussian is so widely used: the first two moments are usually all that we can reliably estimate from data, so we want a distribution that captures these properties, but otherwise makes as few addtional assumptions as possible.\n\nTo simplify notation, we will assume the mean is zero. The pdf has the form\n\\begin{equation}\nf(\\vec{x})=\\dfrac{1}{Z}\\exp\\left(-\\dfrac{1}{2}\\vec{x}^T\\vec{\\Sigma}^{-1}\\vec{x}\\right)\n\\end{equation}\n\n\n\\section{Gaussian discriminant analysis}\nOne important application of MVNs is to define the the class conditional densities in a generative classifier, i.e.,\n\\begin{equation}\np(\\vec{x}|y=c,\\vec{\\theta})=\\mathcal{N}(\\vec{x}|\\vec{\\mu}_c,\\vec{\\Sigma}_c)\n\\end{equation}\n\nThe resulting technique is called (Gaussian) \\textbf{discriminant analysis} or \\textbf{GDA} (even though it is a generative, not discriminative, classifier — see Section TODO for more on this distinction). If $\\vec{\\Sigma}_c$ is diagonal, this is equivalent to naive Bayes.\n\nWe can classify a feature vector using the following decision rule, derived from Equation \\ref{eqn:Generative-classifier}:\n\\begin{equation}\ny=\\arg\\max_{c} \\left[\\log p(y=c|\\vec{\\pi})+\\log p(\\vec{x}|\\vec{\\theta})\\right]\n\\end{equation}\n\nWhen we compute the probability of $\\vec{x}$ under each class conditional density, we are measuring the distance from $\\vec{x}$ to the center of each class, $\\vec{\\mu}_c$, using Mahalanobis distance. This can be thought of as a \\textbf{nearest centroids classifier}.\n\n\\begin{figure}[hbtp]\n\\centering\n\\subfloat[]{\\includegraphics[scale=.70]{2d-Gaussians-Visualization-a.png}} \\\\\n\\subfloat[]{\\includegraphics[scale=.70]{2d-Gaussians-Visualization-b.png}}\n\\caption{(a) Height/weight data. (b) Visualization of 2d Gaussians fit to each class. 95\\% of the probability mass is inside the ellipse.}\n\\label{fig:2d-Gaussians-Visualization} \n\\end{figure}\n\nAs an example, Figure \\ref{fig:2d-Gaussians-Visualization} shows two Gaussian class-conditional densities in 2d, representing the height and weight of men and women. We can see that the features are correlated, as is to be expected (tall people tend to weigh more). The ellipses for each class contain 95\\% of the probability mass. If we have a uniform prior over classes, we can classify a new test vector as follows:\n\\begin{equation}\ny=\\arg\\max_{c} (\\vec{x}-\\vec{\\mu}_c)^T\\vec{\\Sigma}_c^{-1}(\\vec{x}-\\vec{\\mu}_c)\n\\end{equation}\n\n\n\\subsection{Quadratic discriminant analysis (QDA)}\nBy plugging in the definition of the Gaussian density to Equation \\ref{eqn:Generative-classifier}, we can get\n\\begin{equation}\\label{eqn:QDA}\np(y|\\vec{x},\\vec{\\theta})=\\dfrac{\\pi_c|2\\pi\\vec{\\Sigma}_c|^{-\\frac{1}{2}}\\exp\\left[-\\frac{1}{2}(\\vec{x}-\\vec{\\mu})^T\\vec{\\Sigma}^{-1}(\\vec{x}-\\vec{\\mu})\\right]}{\\sum_{c'}\\pi_{c'}|2\\pi\\vec{\\Sigma}_{c'}|^{-\\frac{1}{2}}\\exp\\left[-\\frac{1}{2}(\\vec{x}-\\vec{\\mu})^T\\vec{\\Sigma}^{-1}(\\vec{x}-\\vec{\\mu})\\right]}\n\\end{equation}\n\nThresholding this results in a quadratic function of $\\vec{x}$. The result is known as quadratic discriminant analysis(QDA). Figure \\ref{fig:QDA} gives some examples of what the decision boundaries look like in 2D.\n\n\\begin{figure}[hbtp]\n\\centering\n\\subfloat[]{\\includegraphics[scale=.50]{QDA-a.png}} \\\\\n\\subfloat[]{\\includegraphics[scale=.50]{QDA-b.png}}\n\\caption{Quadratic decision boundaries in 2D for the 2 and 3 class case.}\n\\label{fig:QDA} \n\\end{figure}\n\n\n\\subsection{Linear discriminant analysis (LDA)}\n\\label{sec:Linear-discriminant-analysis}\nWe now consider a special case in which the covariance matrices are \\textbf{tied} or \\textbf{shared} across classes,$\\vec{\\Sigma}_c=\\vec{\\Sigma}$. In this case, we can simplify Equation \\ref{eqn:QDA} as follows:\n\\begin{align}\np(y|\\vec{x},\\vec{\\theta})& \\propto \\pi_c\\exp\\left(\\vec{\\mu}_c\\vec{\\Sigma}^{-1}\\vec{x}-\\dfrac{1}{2}\\vec{x}^T\\vec{\\Sigma}^{-1}\\vec{x}-\\dfrac{1}{2}\\vec{\\mu}_c^T\\vec{\\Sigma}^{-1}\\vec{\\mu}_c\\right) \\nonumber \\\\\n & =\\exp\\left(\\vec{\\mu}_c\\vec{\\Sigma}^{-1}\\vec{x}-\\dfrac{1}{2}\\vec{\\mu}_c^T\\vec{\\Sigma}^{-1}\\vec{\\mu}_c+\\log \\pi_c\\right) \\nonumber \\\\\n & \\quad \\exp\\left(-\\dfrac{1}{2}\\vec{x}^T\\vec{\\Sigma}^{-1}\\vec{x}\\right) \\nonumber \\\\\n & \\propto \\exp\\left(\\vec{\\mu}_c\\vec{\\Sigma}^{-1}\\vec{x}-\\dfrac{1}{2}\\vec{\\mu}_c^T\\vec{\\Sigma}^{-1}\\vec{\\mu}_c+\\log \\pi_c\\right)\n\\end{align}\n\nSince the quadratic term $\\vec{x}^T\\vec{\\Sigma}^{-1}\\vec{x}$ is independent of $c$, it will cancel out in the numerator and denominator. If we define\n\\begin{align}\n\\gamma_c& \\triangleq -\\dfrac{1}{2}\\vec{\\mu}_c^T\\vec{\\Sigma}^{-1}\\vec{\\mu}_c+\\log \\pi_c \\\\\n\\vec{\\beta}_c& \\triangleq \\vec{\\Sigma}^{-1}\\vec{\\mu}_c\n\\end{align}\nthen we can write\n\\begin{equation}\\label{eqn:LDA}\np(y|\\vec{x},\\vec{\\theta})=\\dfrac{e^{\\vec{\\beta}_c^T\\vec{x}+\\gamma_c}}{\\sum_{c'}e^{\\vec{\\beta}_{c'}^T\\vec{x}+\\gamma_{c'}}} \\triangleq \\sigma(\\vec{\\eta}, c)\n\\end{equation}\nwhere $\\vec{\\eta} \\triangleq (e^{\\vec{\\beta}_1^T\\vec{x}}+\\gamma_1,\\cdots, e^{\\vec{\\beta}_C^T\\vec{x}}+\\gamma_C)$, $\\sigma()$ is the \\textbf{softmax activation function}\\footnote{\\url{http://en.wikipedia.org/wiki/Softmax_activation_function}}, defined as follows:\n\\begin{equation}\n\\sigma(\\vec{q},i) \\triangleq \\dfrac{\\exp(q_i)}{\\sum_{j=1}^n \\exp(q_j)}\n\\end{equation}\n\nWhen parameterized by some constant, $\\alpha > 0$, the following formulation becomes a smooth, differentiable approximation of the maximum function:\n\\begin{equation}\n\\mathcal{S}_{\\alpha}(\\vec{x}) = \\dfrac{\\sum_{j=1}^D x_je^{\\alpha x_j}}{\\sum_{j=1}^D e^{\\alpha x_j}}\n\\end{equation}\n\n$\\mathcal{S}_{\\alpha}$ has the following properties:\n\\begin{enumerate}\n\\item $\\mathcal{S}_{\\alpha} \\rightarrow \\max$ as $\\alpha \\rightarrow \\infty$\n\\item $\\mathcal{S}_0$ is the average of its inputs\n\\item $\\mathcal{S}_{\\alpha} \\rightarrow \\min$ as $\\alpha \\rightarrow -\\infty$\n\\end{enumerate}\n\nNote that the softmax activation function comes from the area of statistical physics, where it is common to use the \\textbf{Boltzmann distribution}, which has the same form as the softmax activation function.\n\nAn interesting property of Equation \\ref{eqn:LDA} is that, if we take logs, we end up with a linear function of $\\vec{x}$. (The reason it is linear is because the $\\vec{x}^T\\vec{\\Sigma}^{-1}\\vec{x}$ cancels from the numerator and denominator.) Thus the decision boundary between any two classes, says $c$ and $c'$, will be a straight line. Hence this technique is called \\textbf{linear discriminant analysis} or \\textbf{LDA}.\n\nAn alternative to fitting an LDA model and then deriving the class posterior is to directly fit $p(y|\\vec{x},\\vec{W})=\\text{Cat}(y|\\vec{W}\\vec{x})$ for some $C \\times D$ weight matrix $\\vec{W}$. This is called \\textbf{multi-class logistic regression}, or \\textbf{multinomial logistic regression}. We will discuss this model in detail in Section TODO. The difference between the two approaches is explained in Section TODO.\n\n\n\\subsection{Two-class LDA}\nTo gain further insight into the meaning of these equations, let us consider the binary case. In this case, the posterior is given by\n\\begin{align}\np(y=1|\\vec{x},\\vec{\\theta})& =\\dfrac{e^{\\vec{\\beta}_1^T\\vec{x}+\\gamma_1}}{e^{\\vec{\\beta}_0^T\\vec{x}+\\gamma_0}+e^{\\vec{\\beta}_1^T\\vec{x}+\\gamma_1}}) \\\\\n  & =\\dfrac{1}{1+e^(\\vec{\\beta}_0-\\vec{\\beta}_1)^T\\vec{x}+(\\gamma_0-\\gamma_1)} \\\\\n  & =\\text{sigm}((\\vec{\\beta}_1-\\vec{\\beta}_0)^T\\vec{x}+(\\gamma_0-\\gamma_1))\n\\end{align}\nwhere sigm$(x)$ refers to the sigmoid function\\footnote{\\url{http://en.wikipedia.org/wiki/Sigmoid_function}}.\n\nNow\n\\begin{align}\n\\gamma_1-\\gamma_0& = -\\dfrac{1}{2}\\vec{\\mu}_1^T\\vec{\\Sigma}^{-1}\\vec{\\mu}_1+\\dfrac{1}{2}\\vec{\\mu}_0^T\\vec{\\Sigma}^{-1}\\vec{\\mu}_0 + \\log(\\pi_1/\\pi_0) \\\\\n & =-\\dfrac{1}{2}(\\vec{\\mu}_1-\\vec{\\mu}_0)^T\\vec{\\Sigma}^{-1}(\\vec{\\mu}_1+\\vec{\\mu}_0)+ \\log(\\pi_1/\\pi_0)\n\\end{align}\n\nSo if we define\n\\begin{align}\n\\vec{w}& =\\vec{\\beta}_1-\\vec{\\beta}_0=\\vec{\\Sigma}^{-1}(\\vec{\\mu}_1-\\vec{\\mu}_0) \\\\\n\\vec{x}_0& =\\dfrac{1}{2}(\\vec{\\mu}_1+\\vec{\\mu}_0)-(\\vec{\\mu}_1-\\vec{\\mu}_0)\\dfrac{\\log(\\pi_1/\\pi_0)}{(\\vec{\\mu}_1-\\vec{\\mu}_0)^T\\vec{\\Sigma}^{-1}(\\vec{\\mu}_1-\\vec{\\mu}_0)}\n\\end{align}\nthen we have $\\vec{w}^T\\vec{x}_0=-(\\gamma_1-\\gamma_0)$, and hence\n\\begin{equation}\np(y=1|\\vec{x},\\vec{\\theta})=\\text{sigm}(\\vec{w}^T(\\vec{x}-\\vec{x}_0))\n\\end{equation}\n\n(This is closely related to logistic regression, which we will discuss in Section TODO.) So the final decision rule is as follows: shift $\\vec{x}$ by $\\vec{x}_0$, project onto the line \\vec{w}, and see if the result is positive or negative.\n\n\\begin{figure}[hbtp]\n\\centering\n    \\includegraphics[scale=.50]{2d-LDA.png}\n\\caption{Geometry of LDA in the 2 class case where $\\vec{\\Sigma}_1=\\vec{\\Sigma}_2=\\vec{I}$.}\n\\label{fig:2d-LDA} \n\\end{figure}\n\nIf $\\vec{\\Sigma}=\\sigma^2\\vec{I}$, then $\\vec{w}$ is in the direction of $\\vec{\\mu}_1-\\vec{\\mu}_0$. So we classify the point based on whether its projection is closer to $\\vec{\\mu}_0$ or $\\vec{\\mu}_1$ . This is illustrated in Figure \\ref{fig:2d-LDA}. Furthemore, if $\\vec{\\pi}_1=\\vec{\\pi}_0$, then $\\vec{x}_0=\\frac{1}{2}(\\vec{\\mu}_1+\\vec{\\mu}_0)$, which is half way between the means. If we make $\\vec{\\pi}_1>\\vec{\\pi}_0$, then $\\vec{x}_0$ gets closer to $\\vec{\\mu}_0$, so more of the line belongs to class 1 a \\emph{priori}. Conversely if $\\vec{\\pi}_1<\\vec{\\pi}_0$, the boundary shifts right. Thus we see that the class prior, πc, just changes the decision threshold, and not the overall geometry, as we claimed above. (A similar argument applies in the multi-class case.)\n\nThe magnitude of $\\vec{w}$ determines the steepness of the logistic function, and depends on how well-separated the means are, relative to the variance. In psychology and signal detection theory, it is common to define the \\textbf{discriminability} of a signal from the background noise using a quantity called \\textbf{d-prime}:\n\\begin{equation}\nd' \\triangleq \\dfrac{\\mu_1-\\mu_0}{\\sigma}\n\\end{equation}\nwhere $\\mu_1$ is the mean of the signal and $\\mu_0$ is the mean of the noise, and $\\sigma$ is the standard deviation of the noise. If $d'$ is large, the signal will be easier to discriminate from the noise.\n\n\n\\subsection{MLE for discriminant analysis}\n\\label{sec:MLE-for-discriminant-analysis}\nThe log-likelihood function is as follows:\n\\begin{equation}\np(\\mathcal{D}|\\vec{\\theta})=\\sum\\limits_{c=1}^C{\\sum\\limits_{i:y_i=c}{\\log\\pi_c}}+\\sum\\limits_{c=1}^C{\\sum\\limits_{i:y_i=c}{\\log\\mathcal{N}(\\vec{x}_i|\\vec{\\mu}_c,\\vec{\\Sigma}_c)}}\n\\end{equation}\n\nThe MLE for each parameter is as follows:\n\\begin{align}\n\\bar{\\vec{\\mu}}_c& = \\dfrac{N_c}{N} \\\\\n\\bar{\\vec{\\mu}}_c& = \\dfrac{1}{N_c}\\sum\\limits_{i:y_i=c}\\vec{x}_i \\\\\n\\bar{\\vec{\\Sigma}}_c& = \\dfrac{1}{N_c}\\sum\\limits_{i:y_i=c}(\\vec{x}_i-\\bar{\\vec{\\mu}}_c)(\\vec{x}_i-\\bar{\\vec{\\mu}}_c)^T\n\\end{align}\n\n\n\\subsection{Strategies for preventing overfitting}\nThe speed and simplicity of the MLE method is one of its greatest appeals. However, the MLE can badly overfit in high dimensions. In particular, the MLE for a full covariance matrix is singular if $N_c <D$. And even when $N_c >D$, the MLE can be ill-conditioned, meaning it is close to singular. There are several possible solutions to this problem:\n\\begin{itemize}\n\\item{Use a diagonal covariance matrix for each class, which assumes the features are conditionally independent; this is equivalent to using a naive Bayes classifier (Section \\ref{sec:NBC})}.\n\\item{Use a full covariance matrix, but force it to be the same for all classes,$\\vec{\\Sigma}_c=\\vec{\\Sigma}$. This is an example of \\textbf{parameter tying} or \\textbf{parameter sharing}, and is equivalent to LDA (Section \\ref{sec:Linear-discriminant-analysis}).}\n\\item{Use a diagonal covariance matrix and forced it to be shared. This is called diagonal covariance LDA, and is discussed in Section TODO.}\n\\item{Use a full covariance matrix, but impose a prior and then integrate it out. If we use a conjugate prior, this can be done in closed form, using the results from Section TODO; this is analogous to the “Bayesian naive Bayes” method in Section \\ref{sec:Bayesian-naive-Bayes}. See (Minka 2000f) for details.}\n\\item{Fit a full or diagonal covariance matrix by MAP estimation. We discuss two different kindsof prior below.}\n\\item{Project the data into a low dimensional subspace and fit the Gaussians there. See Section TODO for a way to find the best (most discriminative) linear projection.}\n\\end{itemize}\n\nWe discuss some of these options below.\n\n\n\\subsection{Regularized LDA *}\n\n\n\\subsection{Diagonal LDA}\n\n\n\\subsection{Nearest shrunken centroids classifier *}\nOne drawback of diagonal LDA is that it depends on all of the features. In high dimensional problems, we might prefer a method that only depends on a subset of the features, for reasons of accuracy and interpretability. One approach is to use a screening method, perhaps based on mutual information, as in Section 3.5.4. We now discuss another approach to this problem known as the \\textbf{nearest shrunken centroids} classifier (Hastie et al. 2009, p652).\n\n\n\\section{Inference in jointly Gaussian distributions}\n\\label{sec:Inference-in-jointly-Gaussian-distributions}\nGiven a joint distribution, $p(\\vec{x}_1,\\vec{x}_2)$, it is useful to be able to compute marginals $p(\\vec{x}_1)$ and conditionals $p(\\vec{x}_1|\\vec{x}_2)$. We discuss how to do this below, and then give some applications. These operations take $O(D^3)$ time in the worst case. See Section TODO for faster methods.\n\n\n\\subsection{Statement of the result}\n\n\\begin{theorem}(\\textbf{Marginals and conditionals of an MVN}). Suppose $X=(\\vec{x}_1,\\vec{x}_2)$is jointly Gaussian with parameters\n\\begin{equation}\n\\vec{\\mu}=\\left(\\begin{array}{c}\\vec{\\mu}_1 \\\\\n                                \\vec{\\mu}_2\\end{array}\\right),\n\\vec{\\Sigma}=\\left(\\begin{array}{cc}\n                   \\vec{\\Sigma}_{11} & \\vec{\\Sigma}_{12} \\\\\n \t\t\t\t   \\vec{\\Sigma}_{21} & \\vec{\\Sigma}_{22} \\end{array}\\right),\n\\vec{\\Lambda}=\\vec{\\Sigma}^{-1}=\\left(\\begin{array}{cc}\n                   \\vec{\\Lambda}_{11} & \\vec{\\Lambda}_{12} \\\\\n \t\t\t\t   \\vec{\\Lambda}_{21} & \\vec{\\Lambda}_{22} \\end{array}\\right),\n\\end{equation}\n\nThen the marginals are given by\n\\begin{equation}\n\\begin{split}\np(\\vec{x}_1)= \\mathcal{N}(\\vec{x}_1|\\vec{\\mu}_1,\\vec{\\Sigma}_{11})\\\\\np(\\vec{x}_2)= \\mathcal{N}(\\vec{x}_2|\\vec{\\mu}_2,\\vec{\\Sigma}_{22})\n\\end{split}\n\\end{equation}\nand the posterior conditional is given by\n\\begin{equation}\\label{eqn:Marginals-and-conditionals-of-an-MVN}\n  \\boxed{\\begin{split}\n    p(\\vec{x}_1|\\vec{x}_2)& =\\mathcal{N}(\\vec{x}_1|\\vec{\\mu}_{1|2},\\vec{\\Sigma}_{1|2}) \\\\\n    \\vec{\\mu}_{1|2}& = \\vec{\\mu}_1+\\vec{\\Sigma}_{12}\\vec{\\Sigma}_{22}^{-1}(\\vec{x}_2-\\vec{\\mu}_2) \\\\\n\t               & = \\vec{\\mu}_1-\\vec{\\Lambda}_{11}^{-1}\\vec{\\Lambda}_{12}(\\vec{x}_2-\\vec{\\mu}_2) \\\\\n\t\t\t\t   & = \\vec{\\Sigma}_{1|2}(\\vec{\\Lambda}_{11}\\vec{\\mu}_1-\\vec{\\Lambda}_{12}(\\vec{x}_2-\\vec{\\mu}_2)) \\\\\n\t\\vec{\\Sigma}_{1|2}& = \\vec{\\Sigma}_{11}-\\vec{\\Sigma}_{12}\\vec{\\Sigma}_{22}^{-1}\\vec{\\Sigma}_{21}=\\vec{\\Lambda}_{11}^{-1}\n  \\end{split}}\n\\end{equation}\n\\end{theorem}\n\nEquation \\ref{eqn:Marginals-and-conditionals-of-an-MVN} is of such crucial importance in this book that we have put a box around it, so you can easily find it. For the proof, see Section TODO.\n\nWe see that both the marginal and conditional distributions are themselves Gaussian. For the marginals, we just extract the rows and columns corresponding to $\\vec{x}_1$ or $\\vec{x}_2$. For the conditional, we have to do a bit more work. However, it is not that complicated: the conditional mean is just a linear function of $\\vec{x}_2$, and the conditional covariance is just a constant matrix that is independent of $\\vec{x}_2$. We give three different (but equivalent) expressions for the posterior mean, and two different (but equivalent) expressions for the posterior covariance; each one is useful in different circumstances.\n\n\n\\subsection{Examples}\nBelow we give some examples of these equations in action, which will make them seem more intuitive.\n\n\n\\subsubsection{Marginals and conditionals of a 2d Gaussian}\n\n\n\\section{Linear Gaussian systems}\nSuppose we have two variables, $\\vec{x}$ and $\\vec{y}$.Let $\\vec{x} \\in \\mathbb{R}^{D_x}$ be a hidden variable, and $\\vec{y} \\in \\mathbb{R}^{D_y}$ be a noisy observation of $\\vec{x}$. Let us assume we have the following prior and likelihood:\n\\begin{equation}\\label{eqn:Linear-Gaussian-system}\n  \\boxed{\\begin{split}\n    p(\\vec{x})&=\\mathcal{N}(\\vec{x}|\\vec{\\mu}_x,\\vec{\\Sigma}_x) \\\\\n\tp(\\vec{y}|\\vec{x})&=\\mathcal{N}(\\vec{y}|\\vec{W}\\vec{x}+\\vec{\\mu}_y,\\vec{\\Sigma}_y)\n  \\end{split}}\n\\end{equation}\nwhere $\\vec{W}$ is a matrix of size $D_y \\times D_x$. This is an example of a \\textbf{linear Gaussian system}. We can represent this schematically as $\\vec{x} \\rightarrow \\vec{y}$, meaning $\\vec{x}$ generates $\\vec{y}$. In this section, we show how to “invert the arrow”, that is, how to infer $\\vec{x}$ from $\\vec{y}$. We state the result below, then give several examples, and finally we derive the result. We will see many more applications of these results in later chapters.\n\n\n\\subsection{Statement of the result}\n\\begin{theorem}(\\textbf{Bayes rule for linear Gaussian systems}). \nGiven a linear Gaussian system, as in Equation \\ref{eqn:Linear-Gaussian-system}, the posterior $p(\\vec{x}|\\vec{y})$ is given by the following:\n\\begin{equation}\\label{eqn:Linear-Gaussian-system-posterior}\n  \\boxed{\\begin{split}\n    p(\\vec{x}|\\vec{y})&=\\mathcal{N}(\\vec{x}|\\vec{\\mu}_{x|y},\\vec{\\Sigma}_{x|y}) \\\\\n\t\\vec{\\Sigma}_{x|y}&=\\vec{\\Sigma}_x^{-1}+\\vec{W}^T\\vec{\\Sigma}_y^{-1}\\vec{W} \\\\\n\t\\vec{\\mu}_{x|y}&=\\vec{\\Sigma}_{x|y}\\left[\\vec{W}^T\\vec{\\Sigma}_y^{-1}(\\vec{y}-\\vec{\\mu}_y)+\\vec{\\Sigma}_x^{-1}\\vec{\\mu}_x\\right]\n  \\end{split}}\n\\end{equation}\nIn addition, the normalization constant $p(\\vec{y})$ is given by\n\\begin{equation}\\label{eqn:Linear-Gaussian-system-normalizer}\n  \\boxed{\n    p(\\vec{y})=\\mathcal{N}(\\vec{y}|\\vec{W}\\vec{\\mu}_x+\\vec{\\mu}_y,\\vec{\\Sigma}_y+\\vec{W}\\vec{\\Sigma}_x\\vec{W}^T)\n  }\n\\end{equation}\n\\end{theorem}\n\nFor the proof, see Section 4.4.3 TODO.\n\n\n\\section{Digression: The Wishart distribution *}\n\n\n\\section{Inferring the parameters of an MVN}\n\n\n\\subsection{Posterior distribution of $\\mu$}\n\n\n\n\\subsection{Posterior distribution of $\\Sigma$ *}\n\n\n\n\\subsection{Posterior distribution of $\\mu$ and $\\Sigma$ *}\n\\label{sec:Posterior-distribution-of-mu-and-Sigma}\n\n\n\\subsection{Sensor fusion with unknown precisions *}\n\n"
  },
  {
    "path": "chapterMonteCarloInference.tex",
    "content": "\\chapter{Monte Carlo inference}\n\\label{chap:Monte-Carlo-inference}\n\n\n"
  },
  {
    "path": "chapterMoreVariationalInference.tex",
    "content": "\\chapter{More variational inference}\n\n"
  },
  {
    "path": "chapterOptimization.tex",
    "content": "\\chapter{Optimization methods}\n\\label{chap:Optimization-methods}\n\n\n\\section{Convexity}\n\\label{sec:Convexity}\n\n\\begin{definition}\n(\\textbf{Convex set}) We say a set $\\mathcal{S}$ is convex if for any $\\vec{x}_1, \\vec{x}_2 \\in \\mathcal{S}$, we have\n\\begin{equation}\n\\lambda\\vec{x}_1+(1-\\lambda)\\vec{x}_2 \\in \\mathcal{S}, \\forall \\lambda \\in [0,1]\n\\end{equation}\n\\end{definition}\n\n\\begin{definition}\n(\\textbf{Convex function}) A function $f(\\vec{x})$ is called convex if its \\textbf{epigraph}(the set of points above the function) defines a convex set. Equivalently, a function $f(\\vec{x})$ is called convex if it is defined on a convex set and if, for any $\\vec{x}_1, \\vec{x}_2 \\in \\mathcal{S}$, and any $\\lambda \\in [0,1]$, we have\n\\begin{equation}\nf(\\lambda\\vec{x}_1+(1-\\lambda)\\vec{x}_2) \\leq \\lambda f(\\vec{x}_1)+(1-\\lambda)f(\\vec{x}_2)\n\\end{equation}\n\\end{definition}\n\n\\begin{definition}\nA function $f(\\vec{x})$ is said to be \\textbf{strictly convex} if the inequality is strict\n\\begin{equation}\nf(\\lambda \\vec{x}_1 + (1 - \\lambda)\\vec{x}_2) < \\lambda f(\\vec{x}_1) + (1 - \\lambda)f(\\vec{x}_2)\n\\end{equation}\n\\end{definition}\n\n\\begin{definition}\nA function $f(\\vec{x})$ is said to be (strictly) \\textbf{concave} if $-f(\\vec{x})$ is (strictly) convex.\n\\end{definition}\n\n\\begin{theorem}\nIf $f(x)$ is twice differentiable on $[a, b]$ and $f''(x) \\geq 0$ on $[a, b]$ then $f(x)$ is convex on $[a, b]$.\n\\end{theorem}\n\n\\begin{proposition}\n$\\log(x)$ is strictly convex on $(0, \\infty)$.\n\\end{proposition}\n\nIntuitively, a (strictly) convex function has a “bowl shape”, and hence has a unique global minimum $x^*$ corresponding to the bottom of the bowl. Hence its second derivative must be positive everywhere, $\\frac{\\mathrm{d}^2}{\\mathrm{d}x^2}f(x)>0$. A twice-continuously differentiable, multivariate function $f$ is convex iff its Hessian is positive definite for all $\\vec{x}$. In the machine learning context, the function $f$ often corresponds to the NLL.\n\nModels where the NLL is convex are desirable, since this means we can always find the globally optimal MLE. We will see many examples of this later in the book. However, many models of interest will not have concave likelihoods. In such cases, we will discuss ways to derive locally optimal parameter estimates.\n\n\n\\section{Gradient descent}\n\\label{sec:Gradient-descent}\n\n\n\\subsection{Stochastic gradient descent}\n\n\\begin{algorithm}[htbp]\n\t\\SetKwInOut{Input}{input}\\SetKwInOut{Output}{output}\n\t\n    \\Input{Training data $\\mathcal{D}=\\left\\{(\\vec{x}_i,y_i) | i=1:N\\right\\}$}\n\t\\Output{A linear model: $y_i=\\vec{\\theta}^T\\vec{x}$}\n    $\\vec{w} \\leftarrow 0;\\; b \\leftarrow 0;\\; k \\leftarrow 0$\\;\n    \\While{no mistakes made within the for loop}{\n        \\For{$i\\leftarrow 1$ \\KwTo $N$}{\n\t\t\t\\If{$y_i(\\vec{w} \\cdot \\vec{x}_i+b) \\leq 0$}{\n\t\t\t\t$\\vec{w} \\leftarrow \\vec{w}+\\eta y_i \\vec{x}_i$\\;\n\t\t\t\t$b \\leftarrow b+\\eta y_i$\\;\n\t\t\t\t$k \\leftarrow k+1$\\;\n\t\t\t}\n\t\t}\n    }\n\\caption{Stochastic gradient descent}\n\\end{algorithm}\n\n\n\\subsection{Batch gradient descent}\n\n\n\\subsection{Line search}\nThe \\textbf{line search}\\footnote{\\url{http://en.wikipedia.org/wiki/Line_search}} approach first finds a descent direction along which the objective function $f$ will be reduced and then computes a step size that determines how far $\\vec{x}$ should move along that direction. The descent direction can be computed by various methods, such as gradient descent(Section \\ref{sec:Gradient-descent}), Newton's method(Section \\ref{sec:Newtons-method}) and Quasi-Newton method(Section \\ref{sec:Quasi-Newton-method}). The step size can be determined either exactly or inexactly.\n\n\n\\subsection{Momentum term}\n\n\n\\section{Lagrange duality}\n\n\n\\subsection{Primal form}\nConsider the following, which we'll call the \\textbf{primal} optimization problem:\n\\begin{eqnarray}\nxyz\n\\end{eqnarray}\n\n\n\\subsection{Dual form}\n\n\n\\section{Newton's method}\n\\label{sec:Newtons-method}\n\\begin{align}\nf(\\vec{x})& \\approx f(\\vec{x}_k)+\\vec{g}_k^T(\\vec{x}-\\vec{x}_k)+\\dfrac{1}{2}(\\vec{x}-\\vec{x}_k)^T\\vec{H}_k(\\vec{x}-\\vec{x}_k) \\nonumber \\\\\n\\text{where } & \\vec{g}_k \\triangleq \\vec{g}(\\vec{x}_k)=f'(\\vec{x}_k), \\vec{H}_k \\triangleq \\vec{H}(\\vec{x}_k), \\nonumber \\\\\n              & \\vec{H}(\\vec{x}) \\triangleq \\left[\\dfrac{\\partial^2 f}{\\partial x_i \\partial x_j}\\right]_{D \\times D} \\quad \\text{(Hessian matrix)} \\nonumber \\\\\nf'(\\vec{x})& = \\vec{g}_k+\\vec{H}_k(\\vec{x}-\\vec{x}_k)=0 \\Rightarrow  \\label{eqn:newton-stationary-point} \\\\\n\\vec{x}_{k+1}& = \\vec{x}_k-\\vec{H}_k^{-1}\\vec{g}_k\n\\end{align}\n\n\\begin{algorithm}[htbp]\n    Initialize $\\vec{x}_0$ \\\\\n\t\n\t\\While{(!convergency)} {\n        Evaluate $\\vec{g}_k=\\nabla f(\\vec{x}_k)$ \\\\\n        Evaluate $\\vec{H}_k=\\nabla^2 f(\\vec{x}_k)$ \\\\\n        $\\vec{d}_k=-\\vec{H}_k^{-1}\\vec{g}_k$ \\\\\n        Use line search to find step size $\\eta_k$ along $\\vec{d}_k$ \\\\\n        $\\vec{x}_{k+1}=\\vec{x}_k+\\eta_k\\vec{d}_k$\n\t}\n\t\n\\caption{Newton’s method for minimizing a strictly convex function}\n\\end{algorithm}\n\n\n\\section{Quasi-Newton method}\n\\label{sec:Quasi-Newton-method}\nFrom Equation \\ref{eqn:newton-stationary-point} we can infer out the \\textbf{quasi-Newton condition} as follows:\n\\begin{align}\nf'(\\vec{x})-\\vec{g}_k & = \\vec{H}_k(\\vec{x}-\\vec{x}_k) \\nonumber \\\\\n\\vec{g}_{k-1}-\\vec{g}_k & = \\vec{H}_k(\\vec{x}_{k-1}-\\vec{x}_k) \\Rightarrow \\nonumber \\\\\n\\vec{g}_k- \\vec{g}_{k-1} & = \\vec{H}_k(\\vec{x}_k-\\vec{x}_{k-1}) \\nonumber \\\\\n\\vec{g}_{k+1}- \\vec{g}_k & = \\vec{H}_{k+1}(\\vec{x}_{k+1}-\\vec{x}_k) \\quad \\text{(quasi-Newton condition)} \\label{eqn:quasi-Newton-condition}\n\\end{align}\n\nThe idea is to replace $\\vec{H}_k^{-1}$ with a approximation $\\vec{B}_k$, which satisfies the following properties:\n\\begin{enumerate}\n\\item{$\\vec{B}_k$ must be symmetric}\n\\item{$\\vec{B}_k$ must satisfies the quasi-Newton condition, i.e., $\\vec{g}_{k+1} - \\vec{g}_k= \\vec{B}_{k+1}(\\vec{x}_{k+1}-\\vec{x}_k)$. \\\\\nLet $\\vec{y}_k=\\vec{g}_{k+1}- \\vec{g}_k$, $\\vec{\\delta}_k=\\vec{x}_{k+1}-\\vec{x}_k$, then\n\\begin{equation}\n\\vec{B}_{k+1}\\vec{y}_k=\\vec{\\delta}_k \\label{eqn:secant-equation}\n\\end{equation}\n}\n\\item{Subject to the above, $\\vec{B}_k$ should be as close as possible to $\\vec{B_{k-1}}$.}\n\\end{enumerate}\n\nNote that we did not require that $\\vec{B}_k$ be positive definite. That is because we can show that it must be \npositive definite if $\\vec{B_{k-1}}$ is. Therefore, as long as the initial Hessian approximation $\\vec{B}_0$ is positive definite, \nall $\\vec{B}_k$ are, by induction. \n\n\n\\subsection{DFP}\nUpdating rule:\n\\begin{equation}\n\\vec{B}_{k+1}=\\vec{B}_k+\\vec{P}_k+\\vec{Q}_k\n\\end{equation}\n\nFrom Equation \\ref{eqn:secant-equation} we can get\n\\begin{equation*}\n\\vec{B}_{k+1}\\vec{y}_k=\\vec{B}_k\\vec{y}_k+\\vec{P}_k\\vec{y}_k+\\vec{Q}_k\\vec{y}_k=\\vec{\\delta}_k\n\\end{equation*}\n\nTo make the equation above establish, just let\n\\begin{align*}\n\\vec{P}_k\\vec{y}_k & = \\vec{\\delta}_k \\\\\n\\vec{Q}_k\\vec{y}_k & = -\\vec{B}_k\\vec{y}_k\n\\end{align*}\n\nIn DFP algorithm, $\\vec{P}_k$ and $\\vec{Q}_k$ are\n\\begin{align}\n\\vec{P}_k &= \\dfrac{\\vec{\\delta}_k\\vec{\\delta}_k^T}{\\vec{\\delta}_k^T\\vec{y}_k} \\\\\n\\vec{Q}_k &= -\\dfrac{\\vec{B}_k\\vec{y}_k\\vec{y}_k^T\\vec{B}_k}{\\vec{y}_k^T\\vec{B}_k\\vec{y}_k}\n\\end{align}\n\n\n\\subsection{BFGS}\nUse $\\vec{B}_k$ as a approximation to $\\vec{H}_k$, then the quasi-Newton condition becomes\n\\begin{equation}\n\\vec{B}_{k+1}\\vec{\\delta}_k=\\vec{y}_k\n\\end{equation}\n\nThe updating rule is similar to DFP, but $\\vec{P}_k$ and $\\vec{Q}_k$ are different. Let \n\\begin{align*}\n\\vec{P}_k\\vec{\\delta}_k & = \\vec{y}_k \\\\\n\\vec{Q}_k\\vec{\\delta}_k & = -\\vec{B}_k\\vec{\\delta}_k\n\\end{align*}\n\nThen\n\\begin{align}\n\\vec{P}_k &= \\dfrac{\\vec{y}_k\\vec{y}_k^T}{\\vec{y}_k^T\\vec{\\delta}_k} \\\\\n\\vec{Q}_k &= -\\dfrac{\\vec{B}_k\\vec{\\delta}_k\\vec{\\delta}_k^T\\vec{B}_k}{\\vec{\\delta}_k^T\\vec{B}_k\\vec{\\delta}_k}\n\\end{align}\n\n\n\\subsection{Broyden}\nBroyden's algorithm is a linear combination of DFP and BFGS.\n"
  },
  {
    "path": "chapterProbability.tex",
    "content": "\\chapter{Probability}\n\n\\section{Frequentists vs. Bayesians}\nwhat is probability? \n\nOne is called the \\textbf{frequentist} interpretation. In this view, probabilities represent long run frequencies of events. For example, the above statement means that, if we flip the coin many times, we expect it to land heads about half the time.\n\nThe other interpretation is called the \\textbf{Bayesian} interpretation of probability. In this view, probability is used to quantify our \\textbf{uncertainty} about something; hence it is fundamentally related to information rather than repeated trials (Jaynes 2003). In the Bayesian view, the above statement means we believe the coin is equally likely to land heads or tails on the next toss\n\nOne big advantage of the Bayesian interpretation is that it can be used to model our uncertainty about events that do not have long term frequencies. For example, we might want to compute the probability that the polar ice cap will melt by 2020 CE. This event will happen zero or one times, but cannot happen repeatedly. Nevertheless, we ought to be able to quantify our uncertainty about this event. To give another machine learning oriented example, we might have observed a “blip” on our radar screen, and want to compute the probability distribution over the location of the corresponding target (be it a bird, plane, or missile). In all these cases, the idea of repeated trials does not make sense, but the Bayesian interpretation is valid and indeed quite natural. We shall therefore adopt the Bayesian interpretation in this book. Fortunately, the basic rules of probability theory are the same, no matter which interpretation is adopted.\n\n\n\\section{A brief review of probability theory}\n\n\n\\subsection{Basic concepts}\nWe denote a random event by defining a \\textbf{random variable} $X$.\n\n\\textbf{Discrete random variable}: $X$ can take on any value from a finite or countably infinite set.\n\n\\textbf{Continuous random variable}: the value of $X$ is real-valued.\n\n\n\\subsubsection{CDF}\n\n\\begin{equation}\nF(x) \\triangleq P(X \\leq x)=\\begin{cases}\n\\sum_{u \\leq x}p(u) & \\text{, discrete}\\\\\n\\int_{-\\infty}^{x} f(u)\\mathrm{d}u & \\text{, continuous}\\\\\n\\end{cases}\n\\end{equation}\n\n\n\\subsubsection{PMF and PDF}\nFor discrete random variable, We denote the probability of the event that $X=x$ by $P(X=x)$, or just $p(x)$ for short. Here $p(x)$ is called a \\textbf{probability mass function} or \\textbf{PMF}.A probability mass function is a function that gives the probability that a discrete random variable is exactly equal to some value\\footnote{\\url{http://en.wikipedia.org/wiki/Probability_mass_function}}. This satisfies the properties $0 \\leq p(x) \\leq 1$ and $\\sum_{x \\in \\mathcal{X}} p(x)=1$.\n\nFor continuous variable, in the equation $F(x)=\\int_{-\\infty}^{x} f(u)\\mathrm{d}u$, the function $f(x)$ is called a \\textbf{probability density function} or \\textbf{PDF}. A probability density function is a function that describes the relative likelihood for this random variable to take on a given value\\footnote{\\url{http://en.wikipedia.org/wiki/Probability_density_function}}.This satisfies the properties $f(x) \\geq 0$ and $\\int_{-\\infty}^{\\infty} f(x)\\mathrm{d}x=1$.\n\n\n\\subsection{Mutivariate random variables}\n\n\n\\subsubsection{Joint CDF}\nWe denote joint CDF by $F(x,y) \\triangleq P(X \\leq x \\cap Y \\leq y)=P(X \\leq x , Y \\leq y)$.\n\n\\begin{equation}\nF(x,y) \\triangleq P(X \\leq x, Y \\leq y)=\\begin{cases}\n\\sum_{u \\leq x, v \\leq y}p(u,v) \\\\\n\\int_{-\\infty}^{x}\\int_{-\\infty}^{y} f(u,v)\\mathrm{d}u\\mathrm{d}v \\\\\n\\end{cases}\n\\end{equation}\n\n\\textbf{product rule}:\n\\begin{equation}\\label{eqn:product-rule}\np(X,Y)=P(X|Y)P(Y)\n\\end{equation}\n\n\\textbf{Chain rule}:\n\\begin{equation}\np(X_{1:N})=p(X_1)p(X_2|X_1)p(X_3|X_2,X_1)...p(X_N|X_{1:N-1})\n\\end{equation}\n\n\n\\subsubsection{Marginal distribution}\n\\textbf{Marginal CDF}:\n\\begin{equation}\\begin{split}\n& F_X(x) \\triangleq F(x,+\\infty)= \\\\\n& \\begin{cases}\n\\sum\\limits_{x_i \\leq x}P(X=x_i)=\\sum\\limits_{x_i \\leq x}\\sum\\limits_{j=1}^{+\\infty}P(X=x_i,Y=y_j) \\\\\n\\int_{-\\infty}^{x}f_X(u)du=\\int_{-\\infty}^{x}\\int_{-\\infty}^{+\\infty} f(u,v)\\mathrm{d}u\\mathrm{d}v \\\\\n\\end{cases}\n\\end{split}\\end{equation}\n\n\\begin{equation}\\begin{split}\n& F_Y(y) \\triangleq F(+\\infty,y)= \\\\\n& \\begin{cases}\n\\sum\\limits_{y_j \\leq y}p(Y=y_j)=\\sum\\limits_{i=1}^{+\\infty}\\sum_{y_j \\leq y}P(X=x_i,Y=y_j) \\\\\n\\int_{-\\infty}^{y}f_Y(v)dv=\\int_{-\\infty}^{+\\infty}\\int_{-\\infty}^{y} f(u,v)\\mathrm{d}u\\mathrm{d}v \\\\\n\\end{cases}\n\\end{split}\\end{equation}\n\n\\textbf{Marginal PMF and PDF}:\n\\begin{equation} \\begin{cases}\nP(X=x_i)=\\sum_{j=1}^{+\\infty}P(X=x_i,Y=y_j) & \\text{, discrete}\\\\\nf_X(x)=\\int_{-\\infty}^{+\\infty} f(x,y)\\mathrm{d}y & \\text{, continuous}\\\\\n\\end{cases}\\end{equation}\n\n\\begin{equation}\\begin{cases}\np(Y=y_j)=\\sum_{i=1}^{+\\infty}P(X=x_i,Y=y_j) & \\text{, discrete}\\\\\nf_Y(y)=\\int_{-\\infty}^{+\\infty} f(x,y)\\mathrm{d}x & \\text{, continuous}\\\\\n\\end{cases}\\end{equation}\n\n\n\\subsubsection{Conditional distribution}\n\\textbf{Conditional PMF}:\n\\begin{equation}\np(X=x_i|Y=y_j)=\\dfrac{p(X=x_i,Y=y_j)}{p(Y=y_j)} \\text{ if } p(Y)>0\n\\end{equation}\nThe pmf $p(X|Y)$ is called \\textbf{conditional probability}.\n\n\\textbf{Conditional PDF}:\n\\begin{equation}\nf_{X|Y}(x|y)=\\dfrac{f(x,y)}{f_Y(y)}\n\\end{equation}\n\n\\subsection{Bayes rule}\n\\begin{equation}\n\\begin{split}\np(Y=y|X=x) & =\\dfrac{p(X=x,Y=y)}{p(X=x)} \\\\\n           & =\\dfrac{p(X=x|Y=y)p(Y=y)}{\\sum_{y'}p(X=x|Y=y')p(Y=y')}\n\\end{split}\n\\end{equation}\n\n\n\\subsection{Independence and conditional independence}\nWe say $X$ and $Y$ are unconditionally independent or marginally independent, denoted $X \\perp Y$, if we can represent the joint as the product of the two marginals, i.e.,\n\\begin{equation}\nX \\perp Y=P(X,Y)=P(X)P(Y)\n\\end{equation}\n\nWe say $X$ and $Y$ are conditionally independent(CI) given $Z$ if the conditional joint can be written as a product of conditional marginals:\n\\begin{equation}\nX \\perp Y|Z=P(X,Y|Z)=P(X|Z)P(Y|Z)\n\\end{equation}\n\n\\subsection{Quantiles}\nSince the cdf $F$ is a monotonically increasing function, it has an inverse; let us denote this by $F^{-1}$. If $F$ is the cdf of $X$ , then $F^{-1}(\\alpha)$ is the value of $x_{\\alpha}$ such that $P(X \\leq x_{\\alpha})=\\alpha$; this is called the $\\alpha$ quantile of $F$. The value $F^{-1}(0.5)$ is the \\textbf{median} of the distribution, with half of the probability mass on the left, and half on the right. The values $F^{-1}(0.25)$ and $F^{−1}(0.75)$are the lower and upper \\textbf{quartiles}.\n\n\\subsection{Mean and variance}\nThe most familiar property of a distribution is its \\textbf{mean},or \\textbf{expected value}, denoted by $\\mu$. For discrete rv’s, it is defined as $\\mathbb{E}[X] \\triangleq \\sum_{x \\in \\mathcal{X}}xp(x)$, and for continuous rv’s, it is defined as $\\mathbb{E}[X] \\triangleq \\int_{\\mathcal{X}}xp(x)\\mathrm{d}x$. If this integral is not finite, the mean is not defined (we will see some examples of this later). \n\nThe \\textbf{variance} is a measure of the “spread” of a distribution, denoted by $\\sigma^2$. This is defined as follows:\n\\begin{align}\nvar[X]& =\\mathbb{E}[(X-\\mu)^2] \\\\\n      & =\\int{(x-\\mu)^2p(x)\\mathrm{d}x} \\nonumber \\\\\n      & =\\int{x^2p(x)\\mathrm{d}x}+{\\mu}^2\\int{p(x)\\mathrm{d}x}-2\\mu\\int{xp(x)\\mathrm{d}x} \\nonumber \\\\\n\t  & =\\mathbb{E}[X^2]-{\\mu}^2\n\\end{align}\n\nfrom which we derive the useful result\n\\begin{equation}\n\\mathbb{E}[X^2]=\\sigma^2+{\\mu}^2\n\\end{equation}\n\nThe \\textbf{standard deviation} is defined as\n\\begin{equation}\nstd[X] \\triangleq \\sqrt{var[X]}\n\\end{equation}\n\nThis is useful since it has the same units as $X$ itself.\n\n\\url{https://en.wikipedia.org/wiki/Standardized_moment}\n\n\\section{Some common discrete distributions}\nIn this section, we review some commonly used parametric distributions defined on discrete state spaces, both finite and countably infinite.\n\n\n\\subsection{The Bernoulli and binomial distributions}\n\n\\begin{definition}\nNow suppose we toss a coin only once. Let $X \\in \\{0,1\\}$ be a binary random variable, with probability of “success” or “heads” of $\\theta$. We say that $X$ has a \\textbf{Bernoulli distribution}. This is written as $X \\sim \\text{Ber}(\\theta)$, where the pmf is defined as \n\\begin{equation}\n\\text{Ber}(x|\\theta) \\triangleq \\theta^{\\mathbb{I}(x=1)}(1-\\theta)^{\\mathbb{I}(x=0)}\n\\end{equation}\n\\end{definition}\n\n\n\\begin{definition}\nSuppose we toss a coin $n$ times. Let $X \\in \\{0,1,\\cdots,n\\}$ be the number of heads. If the probability of heads is $\\theta$, then we say $X$ has a \\textbf{binomial distribution}, written as $X \\sim \\text{Bin}(n, \\theta)$. The pmf is given by \n\\begin{equation}\\label{eqn:binomial-pmf}\n\\text{Bin}(k|n,\\theta) \\triangleq \\dbinom{n}{k}\\theta^k(1-\\theta)^{n-k}\n\\end{equation}\n\\end{definition}\n\n\n\\subsection{The multinoulli and multinomial distributions}\n\n\\begin{definition}\nThe Bernoulli distribution can be used to model the outcome of one coin tosses. To model the outcome of tossing a K-sided dice, let $\\vec{x} =(\\mathbb{I}(x=1),\\cdots,\\mathbb{I}(x=K)) \\in \\{0,1\\}^K$ be a random vector(this is called \\textbf{dummy encoding} or \\textbf{one-hot encoding}), then we say $X$ has a \\textbf{multinoulli distribution}(or \\textbf{categorical distribution}), written as $X \\sim \\text{Cat}(\\theta)$. The pmf is given by: \n\\begin{equation}\np(\\vec{x}) \\triangleq \\prod\\limits_{k=1}^K\\theta_k^{\\mathbb{I}(x_k=1)}\n\\end{equation}\n\\end{definition}\n\n\\begin{definition}\nSuppose we toss a K-sided dice $n$ times. Let $\\vec{x} =(x_1,x_2,\\cdots,x_K) \\in \\{0,1,\\cdots,n\\}^K$ be a random vector, where $x_j$ is the number of times side $j$ of the dice occurs, then we say $X$ has a \\textbf{multinomial distribution}, written as $X \\sim \\text{Mu}(n, \\vec{\\theta})$. The pmf is given by \n\\begin{equation}\\label{eqn:multinomial-pmf}\np(\\vec{x}) \\triangleq \\dbinom{n}{x_1 \\cdots x_k} \\prod\\limits_{k=1}^K\\theta_k^{x_k}\n\\end{equation}\nwhere $\\dbinom{n}{x_1 \\cdots x_k} \\triangleq \\dfrac{n!}{x_1!x_2! \\cdots x_K!}$\n\\end{definition}\n\nBernoulli distribution is just a special case of a Binomial distribution with $n=1$, and so is multinoulli distribution as to multinomial distribution. See Table \\ref{tab:multinomial-summary} for a summary.\n\n\\begin{table}\n\\caption{Summary of the multinomial and related distributions.}\n\\label{tab:multinomial-summary}\n\\centering\n\\begin{tabular}{llll}\n\\hline\\noalign{\\smallskip}\nName & K & n & X \\\\\n\\noalign{\\smallskip}\\svhline\\noalign{\\smallskip}\nBernoulli & 1 & 1 & $x \\in \\{0,1\\}$ \\\\\nBinomial & 1 & - & $\\vec{x} \\in \\{0,1,\\cdots,n\\}$ \\\\\nMultinoulli & - & 1 & $\\vec{x} \\in \\{0,1\\}^K, \\sum_{k=1}^K x_k=1$ \\\\\nMultinomial & - & - & $\\vec{x} \\in \\{0,1,\\cdots,n\\}^K, \\sum_{k=1}^K x_k=n$ \\\\\n\\noalign{\\smallskip}\\hline\n\\end{tabular}\n\\end{table} \n\n\n\\subsection{The Poisson distribution}\n\\begin{definition}\nWe say that $X \\in \\{0,1,2,\\cdots\\}$ has a \\textbf{Poisson distribution} with parameter $\\lambda>0$, written as $X \\sim \\text{Poi}(\\lambda)$, if its pmf is\n\\begin{equation}\np(x|\\lambda)=e^{-\\lambda}\\dfrac{\\lambda^x}{x!}\n\\end{equation}\n\\end{definition}\n\nThe first term is just the normalization constant, required to ensure the distribution sums to 1.\n\nThe Poisson distribution is often used as a model for counts of rare events like radioactive decay and traffic accidents. \n\n\\begin{table*}\n\\caption{Summary of Bernoulli, binomial multinoulli and multinomial distributions.}\n\\label{tab:Summary-distribution}\n\\centering\n\\begin{tabular}{llllll}\n\\hline\\noalign{\\smallskip}\nName & Written as & X & $p(x)$(or $p(\\vec{x})$) & $\\mathbb{E}[X]$ & $\\text{var}[X]$ \\\\\n\\noalign{\\smallskip}\\svhline\\noalign{\\smallskip}\nBernoulli & $X \\sim \\text{Ber}(\\theta)$ & $x \\in \\{0,1\\}$ & $\\theta^{\\mathbb{I}(x=1)}(1-\\theta)^{\\mathbb{I}(x=0)}$ & $\\theta$ & $\\theta(1-\\theta)$ \\\\\nBinomial & $X \\sim \\text{Bin}(n,\\theta)$ & $x \\in \\{0,1,\\cdots,n\\}$ & $\\dbinom{n}{k}\\theta^k(1-\\theta)^{n-k}$ & $n\\theta$ & $n\\theta(1-\\theta)$ \\\\\nMultinoulli & $X \\sim \\text{Cat}(\\vec{\\theta})$ & $\\vec{x} \\in \\{0,1\\}^K, \\sum_{k=1}^K x_k=1$ & $\\prod\\limits_{k=1}^K\\theta_j^{\\mathbb{I}(x_j=1)}$ & - & - \\\\\nMultinomial & $X \\sim \\text{Mu}(n,\\vec{\\theta})$ & $\\vec{x} \\in \\{0,1,\\cdots,n\\}^K, \\sum_{k=1}^K x_k=n$ & $\\dbinom{n}{x_1 \\cdots x_k} \\prod\\limits_{k=1}^K\\theta_j^{x_j}$ & - & - \\\\\nPoisson & $X \\sim \\text{Poi}(\\lambda)$ & $x \\in \\{0,1,2,\\cdots\\}$ & $e^{-\\lambda}\\dfrac{\\lambda^x}{x!}$ & $\\lambda$ & $\\lambda$ \\\\\n\\noalign{\\smallskip}\\hline\n\\end{tabular}\n\\end{table*}\n\n\n\\subsection{The empirical distribution}\nThe \\textbf{empirical distribution function}\\footnote{\\url{http://en.wikipedia.org/wiki/Empirical_distribution_function}}, or \\textbf{empirical cdf}, is the cumulative distribution function associated with the empirical measure of the sample. Let $\\mathcal{D}=\\{x_1,x_2,\\cdots,x_N\\}$ be a sample set, it is defined as \n\\begin{equation}\nF_n(x) \\triangleq \\dfrac{1}{N}\\sum\\limits_{i=1}^N\\mathbb{I}(x_i \\leq x)\n\\end{equation}\n\n\n\\section{Some common continuous distributions}\nIn this section we present some commonly used univariate (one-dimensional) continuous probability distributions.\n\n\n\\subsection{Gaussian (normal) distribution}\n\n% \\begin{table}\n% \\caption{Summary of Gaussian distribution}\n% \\centering\n% \\begin{tabular}{cccccc}\n% \\hline\\noalign{\\smallskip}\n% Name & Written as & $f(x)$ & $\\mathbb{E}[X]$ & mode & $\\text{var}[X]$ \\\\\n% \\noalign{\\smallskip}\\svhline\\noalign{\\smallskip}\n% Gaussian distribution & $X \\sim \\mathcal{N}(\\mu,\\sigma^2)$ & $\\dfrac{1}{\\sqrt{2\\pi}\\sigma}e^{-\\frac{1}{2\\sigma^2}\\left(x-\\mu\\right)^2}$ & $\\mu$ & $\\mu$ & $\\sigma^2$ \\\\\n% \\noalign{\\smallskip}\\hline\n% \\end{tabular}\n% \\end{table} \n\n\\begin{table}\n\\caption{Summary of Gaussian distribution.}\n\\centering\n\\begin{tabular}{cccccc}\n\\hline\\noalign{\\smallskip}\nWritten as & $f(x)$ & $\\mathbb{E}[X]$ & mode & $\\text{var}[X]$ \\\\\n\\noalign{\\smallskip}\\svhline\\noalign{\\smallskip}\n$X \\sim \\mathcal{N}(\\mu,\\sigma^2)$ & $\\dfrac{1}{\\sqrt{2\\pi}\\sigma}e^{-\\frac{1}{2\\sigma^2}\\left(x-\\mu\\right)^2}$ & $\\mu$ & $\\mu$ & $\\sigma^2$ \\\\\n\\noalign{\\smallskip}\\hline\n\\end{tabular}\n\\end{table} \n\nIf $X \\sim N(0,1)$,we say $X$ follows a \\textbf{standard normal} distribution.\n\nThe Gaussian distribution is the most widely used distribution in statistics. There are several reasons for this. \n\\begin{enumerate}\n\\item First, it has two parameters which are easy to interpret, and which capture some of the most basic properties of a distribution, namely its mean and variance. \n\\item Second,the central limit theorem (Section TODO) tells us that sums of independent random variables have an approximately Gaussian distribution, making it a good choice for modeling residual errors or “noise”. \n\\item Third, the Gaussian distribution makes the least number of assumptions (has maximum entropy), subject to the constraint of having a specified mean and variance, as we show in Section TODO; this makes it a good default choice in many cases. \n\\item Finally, it has a simple mathematical form, which results in easy to implement, but often highly effective, methods, as we will see. \n\\end{enumerate}\nSee (Jaynes 2003, ch 7) for a more extensive discussion of why Gaussians are so widely used.\n\n\n\\subsection{Student's t-distribution}\n\\begin{table}\n\\caption{Summary of Student's t-distribution.}\n\\centering\n\\begin{tabular}{cccccc}\n\\hline\\noalign{\\smallskip}\nWritten as & $f(x)$ & $\\mathbb{E}[X]$ & mode & $\\text{var}[X]$ \\\\\n\\noalign{\\smallskip}\\svhline\\noalign{\\smallskip}\n$X \\sim \\mathcal{T}(\\mu,\\sigma^2,\\nu)$ & $\\dfrac{\\Gamma(\\frac{\\nu+1}{2})}{\\sqrt{\\nu\\pi}\\Gamma(\\frac{\\nu}{2})}\\left[1+\\dfrac{1}{\\nu}\\left(\\dfrac{x-\\mu}{\\nu}\\right)^2\\right]$ & $\\mu$ & $\\mu$ & $\\dfrac{\\nu\\sigma^2}{\\nu-2}$ \\\\\n\\noalign{\\smallskip}\\hline\n\\end{tabular}\n\\end{table}\nwhere  $\\Gamma(x)$ is the gamma function:\n\\begin{equation}\n\\Gamma(x) \\triangleq \\int_0^\\infty t^{x-1}e^{-t}\\mathrm{d}t\n\\end{equation}\n$\\mu$ is the mean, $\\sigma^2>0$ is the scale parameter, and $\\nu>0$ is called the \\textbf{degrees of freedom}. See Figure \\ref{fig:pdfs-for-NTL} for some plots.\n\n\\begin{figure}[hbtp]\n\\centering\n\\subfloat[]{\\includegraphics[scale=.70]{pdfs-for-NTL-a.png}} \\\\\n\\subfloat[]{\\includegraphics[scale=.70]{pdfs-for-NTL-b.png}}\n\\caption{(a) The pdf’s for a $\\mathcal{N}(0,1)$, $\\mathcal{T}(0,1,1)$ and $Lap(0,1/\\sqrt{2})$. The mean is 0 and the variance is 1 for both the Gaussian and Laplace. The mean and variance of the Student is undefined when $\\nu=1$.(b) Log of these pdf’s. Note that the Student distribution is not log-concave for any parameter value, unlike the Laplace distribution, which is always log-concave (and log-convex...) Nevertheless, both are unimodal.}\n\\label{fig:pdfs-for-NTL} \n\\end{figure}\n\nThe variance is only defined if $\\nu>2$. The mean is only defined if $\\nu>1$.\n\nAs an illustration of the robustness of the Student distribution, consider Figure \\ref{fig:robustness}. We see that the Gaussian is affected a lot, whereas the Student distribution hardly changes. This is because the Student has heavier tails, at least for small $\\nu$(see Figure \\ref{fig:pdfs-for-NTL}).\n\n\\begin{figure}[hbtp]\n\\centering\n\\subfloat[]{\\includegraphics[scale=.70]{robustness-a.png}} \\\\\n\\subfloat[]{\\includegraphics[scale=.70]{robustness-b.png}}\n\\caption{Illustration of the effect of outliers on fitting Gaussian, Student and Laplace distributions. (a) No outliers (the Gaussian and Student curves are on top of each other). (b) With outliers. We see that the Gaussian is more affected by outliers than the Student and Laplace distributions.}\n\\label{fig:robustness} \n\\end{figure}\n\nIf $\\nu=1$, this distribution is known as the \\textbf{Cauchy} or \\textbf{Lorentz} distribution. This is notable for having such heavy tails that the integral that defines the mean does not converge.\n\nTo ensure finite variance, we require $\\nu>2$. It is common to use $\\nu=4$, which gives good performance in a range of problems (Lange et al. 1989). For $\\nu \\gg 5$, the Student distribution rapidly approaches a Gaussian distribution and loses its robustness properties.\n\n\n\\subsection{The Laplace distribution}\n\\begin{table}\n\\caption{Summary of Laplace distribution.}\n\\centering\n\\begin{tabular}{cccccc}\n\\hline\\noalign{\\smallskip}\nWritten as & $f(x)$ & $\\mathbb{E}[X]$ & mode & $\\text{var}[X]$ \\\\\n\\noalign{\\smallskip}\\svhline\\noalign{\\smallskip}\n$X \\sim \\text{Lap}(\\mu,b)$ & $\\dfrac{1}{2b}\\exp\\left(-\\dfrac{|x-\\mu|}{b}\\right)$ & $\\mu$ & $\\mu$ & $2b^2$ \\\\\n\\noalign{\\smallskip}\\hline\n\\end{tabular}\n\\end{table}\n\nHere $\\mu$ is a location parameter and $b>0$ is a scale parameter. See Figure \\ref{fig:pdfs-for-NTL} for a plot.\n\nIts robustness to outliers is illustrated in Figure \\ref{fig:robustness}. It also put mores probability density at 0 than the Gaussian. This property is a useful way to encourage sparsity in a model, as we will see in Section TODO.\n\n\n\\subsection{The gamma distribution}\n\n\\begin{table}\n\\caption{Summary of gamma distribution}\n\\centering\n\\begin{tabular}{ccccccc}\n\\hline\\noalign{\\smallskip}\nWritten as & $X$ & $f(x)$ & $\\mathbb{E}[X]$ & mode & $\\text{var}[X]$ \\\\\n\\noalign{\\smallskip}\\svhline\\noalign{\\smallskip}\n$X \\sim \\text{Ga}(a,b)$ & $x \\in \\mathbb{R}^+$ & $\\dfrac{b^a}{\\Gamma(a)}x^{a-1}e^{-xb}$ & $\\dfrac{a}{b}$ & $\\dfrac{a-1}{b}$ & $\\dfrac{a}{b^2}$ \\\\\n\\noalign{\\smallskip}\\hline\n\\end{tabular}\n\\end{table} \n\nHere $a>0$ is called the shape parameter and $b>0$ is called the rate parameter. See Figure \\ref{fig:gamma-distribution} for some plots.\n\n\\begin{figure}[hbtp]\n\\centering\n\\subfloat[]{\\includegraphics[scale=.50]{gamma-distribution-a.png}} \\\\\n\\subfloat[]{\\includegraphics[scale=.50]{gamma-distribution-b.png}}\n\\caption{Some Ga$(a, b=1)$ distributions. If $a \\leq 1$, the mode is at 0, otherwise it is $>0$.As we increase the rate $b$, we reduce the horizontal scale, thus squeezing everything leftwards and upwards. (b) An empirical pdf of some rainfall data, with a fitted Gamma distribution superimposed.}\n\\label{fig:gamma-distribution} \n\\end{figure}\n\n\n\\subsection{The beta distribution}\n\n\\begin{table*}\n\\caption{Summary of Beta distribution}\\label{tab:beta-distribution}\n\\centering\n\\begin{tabular}{ccccccc}\n\\hline\\noalign{\\smallskip}\nName & Written as & $X$ & $f(x)$ & $\\mathbb{E}[X]$ & mode & $\\text{var}[X]$ \\\\\n\\noalign{\\smallskip}\\svhline\\noalign{\\smallskip}\nBeta distribution & $X \\sim \\text{Beta}(a,b)$ & $x \\in [0,1]$ & $\\dfrac{1}{B(a,b)}x^{a-1}(1-x)^{b-1}$ & $\\dfrac{a}{a+b}$ & $\\dfrac{a-1}{a+b-2}$ & $\\dfrac{ab}{(a+b)^2(a+b+1)}$ \\\\\n\\noalign{\\smallskip}\\hline\n\\end{tabular}\n\\end{table*} \n\nHere $B(a, b)$is the beta function,\n\\begin{equation}\nB(a,b) \\triangleq \\dfrac{\\Gamma(a)\\Gamma(b)}{\\Gamma(a+b)}\n\\end{equation}\n\nSee Figure \\ref{fig:beta-distribution} for plots of some beta distributions. We require  $a, b >0$ to ensure the distribution is integrable (i.e., to ensure $B(a, b)$ exists). If $a=b=1$, we get the uniform distirbution. If $a$ and $b$ are both less than 1, we get a bimodal distribution with “spikes” at 0 and 1; if $a$ and $b$ are both greater than 1, the distribution is unimodal.\n\n\\begin{figure}[hbtp]\n\\centering\n    \\includegraphics[scale=.60]{beta-distribution.png}\n\\caption{Some beta distributions.}\n\\label{fig:beta-distribution} \n\\end{figure}\n\n\n\\subsection{Pareto distribution}\n\n\\begin{table*}\n\\caption{Summary of Pareto distribution}\n\\centering\n\\begin{tabular}{ccccccc}\n\\hline\\noalign{\\smallskip}\nName & Written as & $X$ & $f(x)$ & $\\mathbb{E}[X]$ & mode & $\\text{var}[X]$ \\\\\n\\noalign{\\smallskip}\\svhline\\noalign{\\smallskip}\nPareto distribution & $X \\sim \\text{Pareto}(k,m)$ & $x \\geq m$ & $km^kx^{-(k+1)}\\mathbb{I}(x \\geq m)$ & $\\dfrac{km}{k-1} \\text{ if } k > 1$ & $m$ & $\\dfrac{m^2k}{(k-1)^2(k-2)} \\text{ if } k>2$ \\\\\n\\noalign{\\smallskip}\\hline\n\\end{tabular}\n\\end{table*} \n\nThe \\textbf{Pareto distribution} is used to model the distribution of quantities that exhibit \\textbf{long tails}, also called \\textbf{heavy tails}.\n\nAs $k \\rightarrow \\infty$, the distribution approaches $\\delta(x-m)$. See Figure \\ref{fig:Pareto-distribution}(a) for some plots. If we plot the distribution on a log-log scale, it forms a straight line, of the form $\\log p(x)=a\\log x+c$ for some constants $a$ and $c$. See Figure \\ref{fig:Pareto-distribution}(b) for an illustration (this is known as a \\textbf{power law}).\n\n\\begin{figure}[hbtp]\n\\centering\n\\subfloat[]{\\includegraphics[scale=.50]{pareto-distribution-a.png}} \\\\\n\\subfloat[]{\\includegraphics[scale=.50]{pareto-distribution-b.png}}\n\\caption{(a) The Pareto distribution Pareto$(x|m, k)$ for $m=1$. (b) The pdf on a log-log scale.}\n\\label{fig:Pareto-distribution} \n\\end{figure}\n\n\n\\section{Joint probability distributions}\nGiven a \\textbf{multivariate random variable} or \\textbf{random vector} \\footnote{\\url{http://en.wikipedia.org/wiki/Multivariate_random_variable}} $X \\in \\mathbb{R}^D$, the \\textbf{joint probability distribution}\\footnote{\\url{http://en.wikipedia.org/wiki/Joint_probability_distribution}} is a probability distribution that gives the probability that each of $X_1, X_2, \\cdots,X_D$ falls in any particular range or discrete set of values specified for that variable. In the case of only two random variables, this is called a \\textbf{bivariate distribution}, but the concept generalizes to any number of random variables, giving a \\textbf{multivariate distribution}.\n\nThe joint probability distribution can be expressed either in terms of a \\textbf{joint cumulative distribution function} or in terms of a \\textbf{joint probability density function} (in the case of continuous variables) or \\textbf{joint probability mass function} (in the case of discrete variables). \n\n\n\\subsection{Covariance and correlation}\n\\begin{definition}\nThe \\textbf{covariance} between two rv’s $X$ and $Y$ measures the degree to which $X$ and $Y$ are (linearly) related. Covariance is defined as\n\\begin{equation}\n\\begin{split}\n\\mathrm{cov}[X,Y] & \\triangleq \\mathbb{E}\\left[(X-\\mathbb{E}[X])(Y-\\mathbb{E}[Y])\\right] \\\\\n         & =\\mathbb{E}[XY]-\\mathbb{E}[X]\\mathbb{E}[Y]\n\\end{split}\n\\end{equation}\n\\end{definition}\n\n\\begin{definition}\nIf $X$ is a $D$-dimensional random vector, its \\textbf{covariance matrix} is defined to be the following symmetric, positive definite matrix:\n\\begin{align}\n\\mathrm{cov}[X] & \\triangleq \\mathbb{E}\\left[(X-\\mathbb{E}[X])(X-\\mathbb{E}[X])^T\\right] \\\\\n       &  = \\left( \\begin{array}{cccc}\n           \\text{var}[X_1] & \\text{Cov}[X_1,X_2] & \\cdots & \\text{Cov}[X_1,X_D] \\\\\n           \\text{Cov}[X_2,X_1] & \\text{var}[X_2] & \\cdots & \\text{Cov}[X_2,X_D] \\\\\n\t\t   \\vdots & \\vdots & \\ddots & \\vdots \\\\\n           \\text{Cov}[X_D,X_1] & \\text{Cov}[X_D,X_2] & \\cdots & \\text{var}[X_D] \\end{array} \\right)\n\\end{align}\n\\end{definition}\n\n\\begin{definition}\nThe (Pearson) \\textbf{correlation coefficient} between $X$ and $Y$ is defined as\n\\begin{equation}\n\\text{corr}[X,Y] \\triangleq \\dfrac{\\text{Cov}[X,Y]}{\\sqrt{\\text{var}[X],\\text{var}[Y]}}\n\\end{equation}\n\\end{definition}\n\nA \\textbf{correlation matrix} has the form\n\\begin{equation}\n\\mathbf{R} \\triangleq \\left( \\begin{array}{cccc}\n           \\text{corr}[X_1,X_1] & \\text{corr}[X_1,X_2] & \\cdots & \\text{corr}[X_1,X_D] \\\\\n           \\text{corr}[X_2,X_1] & \\text{corr}[X_2,X_2] & \\cdots & \\text{corr}[X_2,X_D] \\\\\n\t\t   \\vdots & \\vdots & \\ddots & \\vdots \\\\\n           \\text{corr}[X_D,X_1] & \\text{corr}[X_D,X_2] & \\cdots & \\text{corr}[X_D,X_D] \\end{array} \\right)\n\\end{equation}\n\nThe correlation coefficient can viewed as a degree of linearity between $X$ and $Y$, see Figure \\ref{fig:Correlation-examples}.\n\\begin{figure*}[hbtp]\n\\centering\n    \\includegraphics[scale=.80]{Correlation-examples.png}\n\\caption{Several sets of $(x, y)$ points, with the Pearson correlation coefficient of $x$ and $y$ for each set. Note that the correlation reflects the noisiness and direction of a linear relationship (top row), but not the slope of that relationship (middle), nor many aspects of nonlinear relationships (bottom). N.B.: the figure in the center has a slope of 0 but in that case the correlation coefficient is undefined because the variance of $Y$ is zero.Source:\\url{http://en.wikipedia.org/wiki/Correlation}}\n\\label{fig:Correlation-examples} \n\\end{figure*}\n\n\\textbf{Uncorrelated does not imply independent}. For example, let $X \\sim U(-1,1)$ and $Y =X^2$. Clearly $Y$ is dependent on $X$(in fact, $Y$ is uniquely determined by $X$), yet one can show that corr$[X, Y]=0$. Some striking examples of this fact are shown in Figure \\ref{fig:Correlation-examples}. This shows several data sets where there is clear dependence between $X$ and $Y$, and yet the correlation coefficient is 0. A more general measure of dependence between random variables is mutual information, see Section TODO.\n\n\n\\subsection{Multivariate Gaussian distribution}\n\\label{sec:MVN}\nThe \\textbf{multivariate Gaussian} or \\textbf{multivariate normal}(MVN) is the most widely used joint probability density function for continuous variables. We discuss MVNs in detail in Chapter 4; here we just give some definitions and plots.\n\nThe pdf of the MVN in $D$ dimensions is defined by the following:\n\\begin{equation}\n\\mathcal{N}(\\vec{x}|\\vec{\\mu},\\Sigma) \\triangleq \\dfrac{1}{(2\\pi)^{D/2}|\\Sigma|^{1/2}}\\exp\\left[-\\dfrac{1}{2}(\\vec{x}-\\vec{\\mu})^T\\Sigma^{-1}(\\vec{x}-\\vec{\\mu})\\right]\n\\end{equation}\nwhere $\\vec{\\mu}=\\mathbb{E}[X] \\in \\mathbb{R}^D$ is the mean vector, and $\\Sigma=\\text{Cov}[X]$ is the $D \\times D$ covariance matrix. The normalization constant $(2\\pi)^{D/2}|\\Sigma|^{1/2}$ just ensures that the pdf integrates to 1.\n\nFigure \\ref{fig:2d-Gaussions} plots some MVN densities in 2d for three different kinds of covariance matrices. A full covariance matrix has A $D(D+1)/2$ parameters (we divide by 2 since $\\Sigma$ is symmetric). A diagonal covariance matrix has $D$ parameters, and has 0s in the off-diagonal terms. A spherical or isotropic covariance,$\\Sigma=\\sigma^2\\vec{I}_D$, has one free parameter.\n\n\\begin{figure}[hbtp]\n\\centering\n\\subfloat[]{\\includegraphics[scale=.60]{2d-Gaussions-a.png}} \\\\\n\\subfloat[]{\\includegraphics[scale=.60]{2d-Gaussions-b.png}} \\\\\n\\subfloat[]{\\includegraphics[scale=.60]{2d-Gaussions-c.png}} \\\\\n\\subfloat[]{\\includegraphics[scale=.60]{2d-Gaussions-d.png}}\n\\caption{We show the level sets for 2d Gaussians. (a) A full covariance matrix has elliptical contours.(b) A diagonal covariance matrix is an axis aligned ellipse. (c) A spherical covariance matrix has a circular shape. (d) Surface plot for the spherical Gaussian in (c).}\n\\label{fig:2d-Gaussions} \n\\end{figure}\n\n\n\\subsection{Multivariate Student's t-distribution}\nA more robust alternative to the MVN is the multivariate Student's t-distribution, whose pdf is given by\n\\begin{align}\n& \\mathcal{T}(x|\\vec{\\mu},\\Sigma,\\nu) \\nonumber \\\\\n& \\triangleq \\dfrac{\\Gamma(\\frac{\\nu+D}{2})}{\\Gamma(\\frac{\\nu}{2})}\\dfrac{|\\Sigma|^{-\\frac{1}{2}}}{\\left(\\nu\\pi\\right)^{\\frac{D}{2}}}\\left[1+\\dfrac{1}{\\nu}\\left(\\vec{x}-\\vec{\\mu}\\right)^T\\Sigma^{-1}\\left(\\vec{x}-\\vec{\\mu}\\right)\\right]^{-\\frac{\\nu+D}{2}} \\\\\n&= \\dfrac{\\Gamma(\\frac{\\nu+D}{2})}{\\Gamma(\\frac{\\nu}{2})}\\dfrac{|\\Sigma|^{-\\frac{1}{2}}}{\\left(\\nu\\pi\\right)^{\\frac{D}{2}}}\\left[1+\\left(\\vec{x}-\\vec{\\mu}\\right)^T\\vec{V}^{-1}\\left(\\vec{x}-\\vec{\\mu}\\right)\\right]^{-\\frac{\\nu+D}{2}}\n\\end{align}\nwhere $\\Sigma$ is called the scale matrix (since it is not exactly the covariance matrix) and $\\vec{V}=\\nu\\Sigma$. This has fatter tails than a Gaussian. The smaller $\\nu$ is, the fatter the tails. As $\\nu \\rightarrow \\infty$, the distribution tends towards a Gaussian. The distribution has the following properties\n\\begin{equation}\n\\text{mean}=\\vec{\\mu} \\text{ , mode}=\\vec{\\mu} \\text{ , Cov}= \\dfrac{\\nu}{\\nu-2}\\Sigma\n\\end{equation}\n\n\n\\subsection{Dirichlet distribution}\nA multivariate generalization of the beta distribution is the \\textbf{Dirichlet distribution}, which has\nsupport over the probability simplex, defined by\n\\begin{equation}\nS_K=\\left\\{\\vec{x}:0 \\leq x_k \\leq 1,\\sum\\limits_{k=1}^K x_k=1\\right\\}\n\\end{equation}\n\nThe pdf is defined as follows:\n\\begin{equation}\n\\text{Dir}(\\vec{x}|\\vec{\\alpha}) \\triangleq \\dfrac{1}{B(\\vec{\\alpha})}\\prod\\limits_{k=1}^K x_k^{\\alpha_k-1}\\mathbb{I}(\\vec{x} \\in S_K)\n\\end{equation}\nwhere $B(\\alpha_1,\\alpha_2,\\cdots,\\alpha_K)$ is the natural generalization of the beta function to $K$ variables:\n\\begin{equation}\nB(\\alpha) \\triangleq \\dfrac{\\prod_{k=1}^K \\Gamma(\\alpha_k)}{\\Gamma(\\alpha_0)} \\text{ where } \\alpha_0 \\triangleq \\sum_{k=1}^K \\alpha_k\n\\end{equation}\n\nFigure \\ref{fig:3d-Dirichlet} shows some plots of the Dirichlet when $K=3$, and Figure \\ref{fig:5d-Dirichlet} for some sampled probability vectors. We see that $\\alpha_0$ controls the strength of the distribution (how peaked it is), and theαkcontrol where the peak occurs. For example, Dir$(1,1,1)$ is a uniform distribution, Dir$(2,2,2)$ is a broad distribution centered at $(1/3,1/3,1/3)$, and Dir$(20,20,20)$ is a narrow distribution centered at $(1/3,1/3,1/3)$.If $\\alpha_k < 1$ for all $k$, we get “spikes” at the corner of the simplex.\n\n\\begin{figure}[hbtp]\n\\centering\n\\subfloat[]{\\includegraphics[scale=.50]{3d-Dirichlet-a.png}} \\\\\n\\subfloat[]{\\includegraphics[scale=.60]{3d-Dirichlet-b.png}} \\\\\n\\subfloat[]{\\includegraphics[scale=.60]{3d-Dirichlet-c.png}} \\\\\n\\subfloat[]{\\includegraphics[scale=.60]{3d-Dirichlet-d.png}}\n\\caption{(a) The Dirichlet distribution when $K=3$ defines a distribution over the simplex, which can be represented by the triangular surface. Points on this surface satisfy $0 \\leq \\theta_k \\leq 1$ and $\\sum_{k=1}^K \\theta_k=1$. (b) Plot of the Dirichlet density when $\\vec{\\alpha}=(2,2,2)$. (c) $\\vec{\\alpha}=(20,2,2)$.}\n\\label{fig:3d-Dirichlet} \n\\end{figure}\n\n\\begin{figure}[hbtp]\n\\centering\n\\subfloat[$\\vec{\\alpha}=(0.1,\\cdots,0.1)$. This results in very sparse distributions, with many 0s.]{\\includegraphics[scale=.50]{5d-Dirichlet-a.png}} \\\\\n\\subfloat[$\\vec{\\alpha}=(1,\\cdots,1)$. This results in more uniform (and dense) distributions.]{\\includegraphics[scale=.50]{5d-Dirichlet-b.png}}\n\\caption{Samples from a 5-dimensional symmetric Dirichlet distribution for different parameter values.} \n\\label{fig:5d-Dirichlet} \n\\end{figure}\n\nFor future reference, the distribution has these properties\n\\begin{equation}\\label{eqn:Dirichlet-properties}\n\\mathbb{E}(x_k)=\\dfrac{\\alpha_k}{\\alpha_0} \\text{, mode}[x_k]=\\dfrac{\\alpha_k-1}{\\alpha_0-K} \\text{, var}[x_k]=\\dfrac{\\alpha_k(\\alpha_0-\\alpha_k)}{\\alpha_0^2(\\alpha_0+1)}\n\\end{equation}\n\n\n\\section{Transformations of random variables}\nIf $\\vec{x} \\sim P()$ is some random variable, and $\\vec{y}=f(\\vec{x})$, what is the distribution of $Y$? This is the question we address in this section.\n\n\n\\subsection{Linear transformations}\nSuppose $g()$ is a linear function: \n\\begin{equation}\ng(\\vec{x})=A\\vec{x}+b\n\\end{equation}\n\nFirst, for the mean, we have\n\\begin{equation}\n\\mathbb{E}[\\vec{y}]=\\mathbb{E}[A\\vec{x}+b]=A\\mathbb{E}[\\vec{x}]+b\n\\end{equation}\nthis is called the \\textbf{linearity of expectation}.\n\nFor the covariance, we have\n\\begin{equation}\n\\text{Cov}[\\vec{y}]=\\text{Cov}[A\\vec{x}+b]=A\\Sigma A^T\n\\end{equation}\n\n\n\\subsection{General transformations}\n\\label{sec:General-transformations}\nIf $X$ is a discrete rv, we can derive the pmf for $y$ by simply summing up the probability mass for all the $x$’s such that $f(x)=y$:\n\\begin{equation}\\label{eqn:transformation-discrete}\np_Y(y)=\\sum\\limits_{x:g(x)=y}p_X(x)\n\\end{equation}\n\nIf $X$ is continuous, we cannot use Equation \\ref{eqn:transformation-discrete} since $p_X(x)$ is a density, not a pmf, and we cannot sum up densities. Instead, we work with cdf’s, and write\n\\begin{equation}\nF_Y(y)=P(Y \\leq y)=P(g(X) \\leq y)=\\int\\limits_{g(X) \\leq y} f_X(x)\\mathrm{d}x\n\\end{equation}\n\nWe can derive the pdf of $Y$ by differentiating the cdf:\n\\begin{equation}\\label{eqn:General-transformations}\nf_Y(y)=f_X(x)|\\dfrac{dx}{dy}|\n\\end{equation}\n\nThis is called \\textbf{change of variables} formula. We leave the proof of this as an exercise. \n\nFor example, suppose $X \\sim U(−1,1)$, and $Y=X^2$. Then $p_Y(y)=\\dfrac{1}{2}y^{-\\frac{1}{2}}$.\n\n\n\\subsubsection{Multivariate change of variables *}\nLet $f$ be a function $f:\\mathbb{R}^n \\rightarrow \\mathbb{R}^n$, and let $\\vec{y}=f(\\vec{x})$. Then its Jacobian matrix $\\vec{J}$ is given by\n\\begin{equation}\n\\vec{J}_{\\vec{x} \\rightarrow \\vec{y}} \\triangleq \\frac{\\partial \\vec{y}}{\\partial \\vec{x}} \\triangleq \\left(\\begin{array}{ccc}\n\\frac{\\partial y_1}{\\partial x_1} & \\cdots & \\frac{\\partial y_1}{\\partial x_n} \\\\\n\\vdots & \\vdots & \\vdots \\\\\n\\frac{\\partial y_n}{\\partial x_1} & \\cdots & \\frac{\\partial y_n}{\\partial x_n}\n\\end{array}\\right)\n\\end{equation}\n$|\\mathrm{det}(\\vec{J})|$ measures how much a unit cube changes in volume when we apply $f$.\n\nIf $f$ is an invertible mapping, we can define the pdf of the transformed variables using the Jacobian of the inverse mapping $\\vec{y} \\rightarrow \\vec{x}$:\n\\begin{equation}\\label{eqn:Multivariate-transformation}\np_y(\\vec{y})=p_x(\\vec{x})|\\mathrm{det}(\\frac{\\partial \\vec{x}}{\\partial \\vec{y}})|=p_x(\\vec{x})|\\mathrm{det}(\\vec{J}_{\\vec{y} \\rightarrow \\vec{x}})|\n\\end{equation}\n\n\n\\subsection{Central limit theorem}\nGiven $N$ random variables $X_1,X_2,\\cdots,X_N$, each variable is \\textbf{independent and identically distributed}\\footnote{\\url{http://en.wikipedia.org/wiki/Independent_identically_distributed}}(\\textbf{iid} for short), and each has the same mean $\\mu$ and variance $\\sigma^2$, then\n\\begin{equation}\n\\dfrac{\\sum\\limits_{i=1}^n X_i-N\\mu}{\\sqrt{N}\\sigma} \\sim \\mathcal{N}(0,1)\n\\end{equation}\nthis can also be written as\n\\begin{equation}\n\\dfrac{\\bar{X}-\\mu}{\\sigma/\\sqrt{N}} \\sim \\mathcal{N}(0,1) \\quad \\text{, where } \\bar{X} \\triangleq \\dfrac{1}{N}\\sum\\limits_{i=1}^n X_i\n\\end{equation}\n\n\n\\section{Monte Carlo approximation}\n\\label{sec:Monte-Carlo-approximation}\nIn general, computing the distribution of a function of an rv using the change of variables formula can be difficult. One simple but powerful alternative is as follows. First we generate $S$ samples from the distribution, call them $x_1,\\cdots,x_S$. (There are many ways to generate such samples; one popular method, for high dimensional distributions, is called Markov chain Monte Carlo or MCMC; this will be explained in Chapter TODO.) Given the samples, we can approximate the distribution of $f(X)$ by using the empirical distribution of $\\left\\{f(x_s)\\right\\}_{s=1}^S$. This is called a \\textbf{Monte Carlo approximation}\\footnote{\\url{http://en.wikipedia.org/wiki/Monte_Carlo_method}}, named after a city in Europe known for its plush gambling casinos.\n\nWe can use Monte Carlo to approximate the expected value of any function of a random variable. We simply draw samples, and then compute the arithmetic mean of the function applied to the samples. This can be written as follows:\n\\begin{equation}\n\\mathbb{E}[g(X)]=\\int g(x)p(x)\\mathrm{d}x \\approx \\dfrac{1}{S}\\sum\\limits_{s=1}^S f(x_s)\n\\end{equation}\nwhere $x_s \\sim p(X)$.\n\nThis is called \\textbf{Monte Carlo integration}\\footnote{\\url{http://en.wikipedia.org/wiki/Monte_Carlo_integration}}, and has the advantage over numerical integration (which is based on evaluating the function at a fixed grid of points) that the function is only evaluated in places where there is non-negligible probability.\n\n\n\\section{Information theory}\n\n\\subsection{Entropy}\n\\label{sec:Entropy}\nThe entropy of a random variable $X$ with distribution $p$, denoted by $\\mathbb{H}(X)$ or sometimes $\\mathbb{H}(p)$, is a measure of its uncertainty. In particular, for a discrete variable with $K$ states, it is defined by\n\\begin{equation}\n\\mathbb{H}(X) \\triangleq -\\sum\\limits_{k=1}^{K}{p(X=k)\\log_2p(X=k)}\n\\end{equation}\n\nUsually we use log base 2, in which case the units are called \\textbf{bits}(short for binary digits). If we use log base $e$ , the units are called \\textbf{nats}. \n\nThe discrete distribution with maximum entropy is the uniform distribution (see Section XXX for a proof). Hence for a K-ary random variable, the entropy is maximized if $p(x = k)=1/K$; in this case, $\\mathbb{H}(X)=\\log_2K$. \n\nConversely, the distribution with minimum entropy (which is zero) is any \\textbf{delta-function} that puts all its mass on one state. Such a distribution has no uncertainty.\n\n\n\\subsection{KL divergence}\nOne way to measure the dissimilarity of two probability distributions, $p$ and $q$ , is known as the \\textbf{Kullback-Leibler divergence}(\\textbf{KL divergence})or \\textbf{relative entropy}. This is defined as follows:\n\\begin{equation}\n\\mathbb{KL}(P||Q) \\triangleq \n\\sum\\limits_{x}{p(x)\\log_2\\dfrac{p(x)}{q(x)}}\n\\end{equation}\nwhere the sum gets replaced by an integral for pdfs\\footnote{The KL divergence is not a distance, since it is asymmetric. One symmetric version of the KL divergence is the \\textbf{Jensen-Shannon divergence}, defined as $JS(p_1,p_2)=0.5\\mathbb{KL}(p_1||q)+0.5\\mathbb{KL}(p_2||q)$,where $q=0.5p_1+0.5p_2$}. The KL divergence is only defined if P and Q both sum to 1 and if $q(x)=0$ implies $p(x)=0$ for all $x$(absolute continuity). If the quantity  $0\\ln0$ appears in the formula, it is interpreted as zero because $\\lim\\limits_{x \\to 0}x\\ln x$. We can rewrite this as\n\\begin{equation}\\begin{split}\n\\mathbb{KL}(p||q) & \\triangleq \\sum\\limits_{x}{p(x)\\log_2p(x)}-\\sum\\limits_{k=1}^{K}{p(x)\\log_2q(x)} \\\\\n    & =\\mathbb{H}(p,q)-\\mathbb{H}(p)\n\\end{split}\\end{equation}\nwhere $\\mathbb{H}(p,q)$ is called the \\textbf{cross entropy},\n\\begin{equation}\\label{eqn:cross-entropy}\n\\mathbb{H}(p,q)=-\\sum\\limits_{x}{p(x)\\log_2q(x)}\n\\end{equation}\n\nOne can show (Cover and Thomas 2006) that the cross entropy is the average number of bits needed to encode data coming from a source with distribution $p$ when we use model $q$ to define our codebook. Hence the “regular” entropy $\\mathbb{H}(p)=\\mathbb{H}(p,p)$, defined in section \\S \\ref{sec:Entropy},is the expected number of bits if we use the true model, so the KL divergence is the diference between these. In other words, the KL divergence is the average number of \\emph{extra} bits needed to encode the data, due to the fact that we used distribution $q$ to encode the data instead of the true distribution $p$.\n\nThe “extra number of bits” interpretation should make it clear that $\\mathbb{KL}(p||q) \\geq 0$, and that the KL is only equal to zero if $q = p$. We now give a proof of this important result.\n\n\\begin{theorem}\n(\\textbf{Information inequality}) $\\mathbb{KL}(p||q) \\geq 0 \\text{ with equality iff } p=q$.\n\\end{theorem}\n\nOne important consequence of this result is that \\emph{the discrete distribution with the maximum\nentropy is the uniform distribution}.\n\n\n\\subsection{Mutual information}\n\\label{sec:Mutual-information}\n\\begin{definition}\n\\textbf{Mutual information} or \\textbf{MI}, is defined as follows:\n\\begin{equation}\\begin{split}\n\\mathbb{I}(X;Y) & \\triangleq \\mathbb{KL}(P(X,Y)||P(X)P(Y)) \\\\\n    & =\\sum\\limits_x\\sum\\limits_yp(x,y)\\log\\dfrac{p(x,y)}{p(x)p(y)}\n\\end{split}\\end{equation}\nWe have $\\mathbb{I}(X;Y) \\geq 0$ with equality if $P(X,Y)=P(X)P(Y)$. That is, the MI is zero if the variables are independent.\n\\end{definition}\n\nTo gain insight into the meaning of MI, it helps to re-express it in terms of joint and conditional entropies. One can show that the above expression is equivalent to the following:\n\\begin{eqnarray}\n\\mathbb{I}(X;Y)&=&\\mathbb{H}(X)-\\mathbb{H}(X|Y)\\\\\n               &=&\\mathbb{H}(Y)-\\mathbb{H}(Y|X)\\\\\n               &=&\\mathbb{H}(X)+\\mathbb{H}(Y)-\\mathbb{H}(X,Y)\\\\\n               &=&\\mathbb{H}(X,Y)-\\mathbb{H}(X|Y)-\\mathbb{H}(Y|X)\n\\end{eqnarray}\nwhere $\\mathbb{H}(X)$ and $\\mathbb{H}(Y)$ are the \\textbf{marginal entropies}, $\\mathbb{H}(X|Y)$ and $\\mathbb{H}(Y|X)$ are the \\textbf{conditional entropies}, and $\\mathbb{H}(X,Y)$ is the \\textbf{joint entropy} of $X$ and $Y$, see Fig. \\ref{fig:mi}\\footnote{\\url{http://en.wikipedia.org/wiki/Mutual_information}}.\n\n\\begin{figure}[hbtp]\n\\centering\n    \\includegraphics[scale=.25]{mutual-information.png}\n\\caption{Individual $\\mathbb{H}(X),\\mathbb{H}(Y)$, joint $\\mathbb{H}(X,Y)$, and conditional entropies for a pair of correlated subsystems $X,Y$ with mutual information $\\mathbb{I}(X;Y)$.}\n\\label{fig:mi} \n\\end{figure}\n\nIntuitively, we can interpret the MI between $X$ and $Y$ as the reduction in uncertainty about $X$ after observing $Y$, or, by symmetry, the reduction in uncertainty about $Y$ after observing $X$.\n\nA quantity which is closely related to MI is the \\textbf{pointwise mutual information} or \\textbf{PMI}. For two events (not random variables) $x$ and $y$, this is defined as\n\\begin{equation}\nPMI(x,y) \\triangleq \\log\\dfrac{p(x,y)}{p(x)p(y)}=\\log\\dfrac{p(x|y)}{p(x)}=\\log\\dfrac{p(y|x)}{p(y)}\n\\end{equation}\n\nThis measures the discrepancy between these events occuring together compared to what would be expected by chance. Clearly the MI of $X$ and $Y$ is just the expected value of the PMI. Interestingly, we can rewrite the PMI as follows:\n\\begin{equation}\nPMI(x,y)=\\log\\dfrac{p(x|y)}{p(x)}=\\log\\dfrac{p(y|x)}{p(y)}\n\\end{equation}\n\nThis is the amount we learn from updating the prior $p(x)$ into the posterior $p(x|y)$, or equivalently, updating the prior $p(y)$ into the posterior $p(y |x)$.\n"
  },
  {
    "path": "chapterSSM.tex",
    "content": "\\chapter{State space models}\n\n"
  },
  {
    "path": "chapterSparseLinearModels.tex",
    "content": "\\chapter{Sparse linear models}\n\n"
  },
  {
    "path": "chapterStructureLearning.tex",
    "content": "\\chapter{Graphical model structure learning}\n\n"
  },
  {
    "path": "chapterUGM.tex",
    "content": "\\chapter{Undirected graphical models (Markov random fields)}\n\n"
  },
  {
    "path": "chapterVariationalInference.tex",
    "content": "\\chapter{Variational inference}\n\n"
  },
  {
    "path": "dedic.tex",
    "content": "%%%%%%%%%%%%%%%%%%%%%%% dedic.tex %%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% sample dedication\n%\n% Use this file as a template for your own input.\n%\n%%%%%%%%%%%%%%%%%%%%%%%% Springer %%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{dedication}\nThis book is dedicated to my girl friend Jie Liu, thanks for her companion.\n\\end{dedication}\n\n\n\n"
  },
  {
    "path": "foreword.tex",
    "content": "%%%%%%%%%%%%%%%%%%%%%%foreword.tex%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% sample foreword\n%\n% Use this file as a template for your own input.\n%\n%%%%%%%%%%%%%%%%%%%%%%%% Springer %%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\foreword\n\nUse the template \\textit{foreword.tex} together with the Springer document class SVMono (monograph-type books) or SVMult (edited books) to style your foreword\\index{foreword} in the Springer layout. \n\nThe foreword covers introductory remarks preceding the text of a book that are written by a \\textit{person other than the author or editor} of the book. If applicable, the foreword precedes the preface which is written by the author or editor of the book.\n\n\n\\vspace{\\baselineskip}\n\\begin{flushright}\\noindent\nPlace, month year\\hfill {\\it Firstname  Surname}\\\\\n\\end{flushright}\n\n\n"
  },
  {
    "path": "glossary.tex",
    "content": "%%%%%%%%%%%%%%%%%%%%%%acronym.tex%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% sample list of acronyms\n%\n% Use this file as a template for your own input.\n%\n%%%%%%%%%%%%%%%%%%%%%%%% Springer %%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\Extrachap{Glossary}\n\n\\runinhead{feature vector} A feature vector to represent one data.\n\n\\runinhead{loss function} a function that maps an event onto a real number intuitively representing some \"cost\" associated with the event.\n\n\\runinhead{glossary term} Write here the description of the glossary term. Write here the description of the glossary term. Write here the description of the glossary term.\n"
  },
  {
    "path": "machine-learning-cheat-sheet.tex",
    "content": "%%%%%%%%%%%%%%%%%%%%%%%% editor.tex %%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% sample root file for the contributions of a \"contributed volume\"\n%\n% Use this file as a template for your own input.\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Springer %%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n% RECOMMENDED %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\documentclass[graybox, envcountchap, twocolumn]{styles/svmult}\n\n% general metadata:\n\\author{soulmachine@gmail.com}\n\\title{Machine Learning Cheat Sheet}\n\\subtitle{Classical equations, diagrams and tricks in machine learning}\n\n% choose options for [] as required from the list\n% in the Reference Guide\n\n\\usepackage{amssymb,amsmath,bm}\n\\DeclareMathAlphabet{\\mathcal}{OMS}{cmsy}{m}{n}\n\\usepackage{textcomp}\n\\newcommand\\abs[1]{\\left\\lvert#1\\right\\rvert}\n\\usepackage{longtable}\n\\usepackage{algorithm2e}\n\\usepackage{tocbibind}\n\\usepackage[toc]{multitoc}\n\\renewcommand{\\bibname}{References}\n\\usepackage{mathptmx}        % selects Times Roman as basic font\n\\usepackage{helvet}          % selects Helvetica as sans-serif font\n\\usepackage{courier}         % selects Courier as typewriter font\n%\\usepackage{type1cm}        % activate if the above 3 fonts are \n                             % not available on your system\n\n\\usepackage{makeidx}         % allows index generation\n\\usepackage{graphicx}        % standard LaTeX graphics tool\n                             % when including figure files\n\\usepackage[justification=centering]{caption}\n\\usepackage{subfig}\n\\usepackage{multicol}        % used for the two-column index\n\\usepackage{multirow}\n\\usepackage[bottom]{footmisc}% places footnotes at page bottom\n\\usepackage[bookmarksnumbered=true,\n            bookmarksopen=true,\n            colorlinks=true,\n            linkcolor=blue,\n            anchorcolor=blue,\n            citecolor=blue\n           ]{hyperref}\n\n\\graphicspath{{figures/}}\n\n% see the list of further useful packages in the Reference Guide\n\n\\makeindex             % used for the subject index\n                       % please use the style svind.ist with\n                       % your makeindex program\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{document}\n\n\\frontmatter%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\include{titlepage}\n%\\include{dedic}\n%\\include{foreword}\n\\include{preface}\n%\\include{acknow}\n\n\\tableofcontents\n\\include{cblist}\n%\\include{acronym}\n\\include{notation}\n\n\n\\mainmatter%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\\include{part}\n\\include{chapterIntroduction}\n\\include{chapterProbability}\n\\include{chapterGenerativeModels}\n\\include{chapterMVN}\n\\include{chapterBayesianStatistics}\n\\include{chapterFrequentistStatistics}\n\\include{chapterLinearRegression}\n\\include{chapterLogisticRegression}\n\\include{chapterGLM}\n\\include{chapterDGM}\n\\include{chapterEM}\n\\include{chapterLatentLinearModels}\n\\include{chapterSparseLinearModels}\n\\include{chapterKernels}\n\\include{chapterGP}\n\\include{chapterABM}\n\\include{chapterHMM}\n\\include{chapterSSM}\n\\include{chapterUGM}\n\\include{chapterExactInferenceForGraphicalModels}\n\\include{chapterVariationalInference}\n\\include{chapterMoreVariationalInference}\n\\include{chapterMonteCarloInference}\n\\include{chapterMCMC}\n\\include{chapterClustering}\n\\include{chapterStructureLearning}\n\\include{chapterLVM}\n\\include{chapterDeepLearning}\n%\n\n\\backmatter%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\appendix\n\\include{chapterOptimization}\n\\include{glossary}\n\\printindex\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\end{document}\n\n"
  },
  {
    "path": "notation.tex",
    "content": "\\Extrachap{Notation}\n\\label{sec:Notation}\n\n\\section*{Introduction}\nIt is very difficult to come up with a single, consistent notation to cover the wide variety of\ndata, models and algorithms that we discuss. Furthermore, conventions difer between machine\nlearning and statistics, and between different books and papers. Nevertheless, we have tried\nto be as consistent as possible. Below we summarize most of the notation used in this book,\nalthough individual sections may introduce new notation. Note also that the same symbol may\nhave different meanings depending on the context, although we try to avoid this where possible.\n\n\n\\section*{General math notation}\n\n\\begin{longtable}{ll}\n\\hline\\noalign{\\smallskip}\n\\textbf{Symbol} & \\textbf{Meaning} \\\\\n\\noalign{\\smallskip}\\hline\\noalign{\\smallskip}\n$\\lfloor x \\rfloor$ & Floor of $x$, i.e., round down to nearest integer\\\\\n$\\lceil x \\rceil$ & Ceiling of $x$, i.e., round up to nearest integer\\\\\n$\\vec{x} \\otimes \\vec{y}$ & Convolution of $\\vec{x}$ and $\\vec{y}$\\\\\n$\\vec{x} \\odot \\vec{y}$ & Hadamard (elementwise) product of $\\vec{x}$ and $\\vec{y}$\\\\\n$a \\wedge b$ & logical AND\\\\\n$a \\vee b$ & logical OR\\\\\n$\\neg a$ & logical NOT\\\\\n$\\mathbb{I}(x)$ & Indicator function, $\\mathbb{I}(x)=1$ if x is true, else $\\mathbb{I}(x)=0$\\\\\n$\\infty$ & Infinity\\\\\n$\\rightarrow$ & Tends towards, e.g., $n \\rightarrow \\infty$\\\\\n$\\propto$ &Proportional to, so $y = ax$ can be written as $y \\propto x$\\\\\n$\\abs{x}$ & Absolute value\\\\\n$\\abs{\\mathcal{S}}$ & Size (cardinality) of a set\\\\\n$n!$ & Factorial function\\\\\n$\\nabla$ & Vector of first derivatives\\\\\n$\\nabla^2$ & Hessian matrix of second derivatives\\\\\n$\\triangleq$ & Defined as\\\\\n$O(\\cdot)$ & Big-O: roughly means order of magnitude\\\\\n$\\mathbb{R}$ & The real numbers\\\\\n$1:n$ & Range (Matlab convention): $1:n = {1, 2,...,n}$\\\\\n$\\approx$ & Approximately equal to\\\\\n$\\arg\\max\\limits_x f(x)$ & Argmax: the value $x$ that maximizes $f$\\\\\n$B(a,b)$ & Beta function, $B(a,b)=\\dfrac{\\Gamma(a)\\Gamma(b)}{\\Gamma(a+b)}$\\\\\n$B(\\vec{\\alpha})$ & Multivariate beta function, $\\dfrac{\\prod\\limits_k \\Gamma(\\alpha_k)}{\\Gamma(\\sum\\limits_k \\alpha_k)}$\\\\\n$\\binom{n}{k}$ & $n$ choose $k$ , equal to $n!/(k!(n−k )!)$\\\\\n$\\delta(x)$ & Dirac delta function,$\\delta(x)=\\infty$ if $x=0$, else $\\delta(x)=0$\\\\\n$\\exp(x)$ & Exponential function $e^x$\\\\\n$\\Gamma(x)$ & Gamma function, $\\Gamma(x)=\\int_0^\\infty u^{x-1}e^{-u}\\mathrm{d}u$\\\\\n$\\Psi(x)$ &  Digamma function,$Psi(x)=\\dfrac{d}{dx}\\log\\Gamma(x)$\\\\\n$\\mathcal{X}$ & A set from which values are drawn (e.g.,$\\mathcal{X}=\\mathbb{R}^D$)\\\\\n\\noalign{\\smallskip}\\hline\\noalign{\\smallskip}\n\\end{longtable}\n\n\n\\section*{Linear algebra notation}\nWe use boldface lower-case to denote vectors, such as $\\vec{x}$, and boldface upper-case to denote matrices, such as $\\vec{X}$. We denote entries in a matrix by non-bold upper case letters, such as $X_{ij}$. \n\nVectors are assumed to be column vectors, unless noted otherwise. We use $(x_1,\\cdots,x_D)$ to denote a column vector created by stacking $D$ scalars. If we write $\\vec{X}=(\\vec{x}_1,\\cdots,\\vec{x}_n)$, where the left hand side is a matrix, we mean to stack the $\\vec{x}_i$ along the columns, creating a matrix. \n\n\\begin{longtable}{ll}\n\\hline\\noalign{\\smallskip}\n\\textbf{Symbol} & \\textbf{Meaning} \\\\\n\\noalign{\\smallskip}\\hline\\noalign{\\smallskip}\n$\\vec{X} \\succ 0$ & $\\vec{X}$ is a positive definite matrix\\\\\n$tr(\\vec{X})$ & Trace of a matrix\\\\\n$det(\\vec{X})$ & Determinant of matrix $\\vec{X}$\\\\\n$\\abs{\\vec{X}}$ & Determinant of matrix $\\vec{X}$\\\\\n$\\vec{X}^{-1}$ & Inverse of a matrix\\\\\n$\\vec{X}^{\\dagger}$ & Pseudo-inverse of a matrix\\\\\n$\\vec{X}^T$ & Transpose of a matrix\\\\\n$\\vec{x}^T$ & Transpose of a vector\\\\\n$\\mathrm{diag}(x)$ & Diagonal matrix made from vector $\\vec{x}$\\\\\n$\\mathrm{diag}(X)$ & Diagonal vector extracted from matrix $\\vec{X}$\\\\\n$\\vec{I}$ or $\\vec{I}_d$ & Identity matrix of size $d \\times d$ (ones on diagonal, zeros of)\\\\\n$\\vec{1}$ or $\\vec{1}_d$ & Vector of ones (of length $d$)\\\\\n$\\vec{0}$ or $\\vec{0}_d$ & Vector of zeros (of length $d$)\\\\\n$\\abs{\\abs{\\vec{x}}}=\\abs{\\abs{\\vec{x}}}_2$ & Euclidean or $\\ell_2$ norm $\\sqrt{\\sum\\limits_{j=1}^{d} x_j^2}$\\\\\n$\\abs{\\abs{\\vec{x}}}_1$ & $\\ell_1$ norm $\\sum\\limits_{j=1}^{d} \\abs{x_j}$\\\\\n$\\vec{X}_{:,j}$ & j'th column of matrix\\\\\n$\\vec{X}_{i,:}$ & transpose of $i$'th row of matrix (a column vector)\\\\\n$\\vec{X}_{i,j}$ & Element $(i,j)$ of matrix $\\vec{X}$ \\\\\n$\\vec{x} \\otimes \\vec{y}$ & Tensor product of $\\vec{x}$ and $\\vec{y}$\\\\\n\\noalign{\\smallskip}\\hline\\noalign{\\smallskip}\n\\end{longtable}\n\n\n\\section*{Probability notation}\nWe denote random and fixed scalars by lower case, random and fixed vectors by bold lower case, and random and fixed matrices by bold upper case. Occasionally we use non-bold upper case to denote scalar random variables. Also, we use $p()$ for both discrete and continuous random variables\n\n\\begin{longtable}{ll}\n\\hline\\noalign{\\smallskip}\n\\textbf{Symbol} & \\textbf{Meaning} \\\\\n\\noalign{\\smallskip}\\hline\\noalign{\\smallskip}\n$X,Y$ & Random variable\\\\\n$P()$ & Probability of a random event\\\\\n$F()$ & Cumulative distribution function(CDF), also called distribution function\\\\\n$p(x)$ & Probability mass function(PMF)\\\\\n$f(x)$ & probability density function(PDF) \\\\\n$F(x,y)$ & Joint CDF\\\\\n$p(x,y)$ & Joint PMF \\\\\n$f(x,y)$ & Joint PDF\\\\\n$p(X|Y)$ & Conditional PMF, also called conditional probability\\\\\n$f_{X|Y}(x|y)$ & Conditional PDF\\\\\n$X \\perp Y$ & X is independent of Y\\\\\n$X \\not\\perp Y$ & X is not independent of Y\\\\\n$X \\perp Y | Z $ & X is conditionally independent of Y given Z\\\\\n$X \\not\\perp Y | Z $ & X is not conditionally independent of Y given Z\\\\\n$X \\sim p$ & X is distributed according to distribution $p$\\\\\n$\\vec{\\alpha}$ & Parameters of a Beta or Dirichlet distribution\\\\\n$\\mathrm{cov}[X]$ & Covariance of X\\\\\n$\\mathbb{E}[X]$ & Expected value of X\\\\\n$\\mathbb{E}_q[X]$ & Expected value of X wrt distribution $q$\\\\\n$\\mathbb{H}(X)$ or $\\mathbb{H}(p)$ & Entropy of distribution $p(X)$\\\\\n$\\mathbb{I}(X;Y)$ & Mutual information between X and Y\\\\\n$\\mathbb{KL}(p||q)$ & KL divergence from distribution $p$ to $q$\\\\\n$\\ell(\\vec{\\theta})$ & Log-likelihood function\\\\\n$L(\\theta,a)$ & Loss function for taking action $a$ when true state of nature is $\\theta$\\\\\n$\\lambda$ & Precision (inverse variance) $\\lambda=1/\\sigma^2$\\\\\n$\\Lambda$ & Precision matrix $\\Lambda=\\Sigma^{-1}$\\\\\nmode$[\\vec X]$ & Most probable value of $\\vec X$\\\\\n$\\mu$ & Mean of a scalar distribution\\\\\n$\\vec{\\mu}$ & Mean of a multivariate distribution\\\\\n$\\Phi$ & cdf of standard normal\\\\\n$\\phi$ & pdf of standard normal\\\\\n$\\vec{\\pi}$ & multinomial parameter vector, Stationary distribution of Markov chain\\\\\n$\\rho$ & Correlation coefficient \\\\\nsigm($x$) & Sigmoid (logistic) function,$\\dfrac{1}{1+e^{-x}}$\\\\\n$\\sigma^2$ & Variance\\\\\n$\\Sigma$ & Covariance matrix\\\\\nvar[$x$] & Variance of $x$\\\\\n$\\nu$ & Degrees of freedom parameter\\\\\nZ & Normalization constant of a probability distribution\\\\\n\\noalign{\\smallskip}\\hline\\noalign{\\smallskip}\n\\end{longtable}\n\n\\section*{Machine learning/statistics notation}\nIn general, we use upper case letters to denote constants, such as $C, K, M, N, T$, etc. We use lower case letters as dummy indexes of the appropriate range, such as $c=1:C$ to index classes, $i=1:M$ to index data cases, $j=1:N$ to index input features, $k=1:K$ to index states or clusters, $t=1:T$ to index time, etc.\n\nWe use $x$ to represent an observed data vector. In a supervised problem, we use $y$ or $\\vec{y}$ to represent the desired output label. We use $\\vec{z}$ to represent a hidden variable. Sometimes we also use $q$ to represent a hidden discrete variable.\n\n\\begin{longtable}{ll}\n\\hline\\noalign{\\smallskip}\n\\textbf{Symbol} & \\textbf{Meaning} \\\\\n\\noalign{\\smallskip}\\hline\\noalign{\\smallskip}\n$C$ & Number of classes\\\\\n$D$ & Dimensionality of data vector (number of features)\\\\\n$N$ & Number of data cases\\\\\n$N_c$ & Number of examples of class $c$,$N_c=\\sum_{i=1}^{N}\\mathbb{I}(y_i=c)$\\\\\n$R$ & Number of outputs (response variables)\\\\\n$\\mathcal{D}$ & Training data $\\mathcal{D}=\\left\\{(\\vec{x}_i,y_i) | i=1:N\\right\\}$\\\\\n$\\mathcal{D}_{test}$ & Test data\\\\\n$\\mathcal{X}$ & Input space\\\\\n$\\mathcal{Y}$ & Output space\\\\\n$K$ & Number of states or dimensions of a variable (often latent)\\\\\n$k(x,y)$ & Kernel function\\\\\n$\\vec{K}$ & Kernel matrix\\\\\n$\\mathcal{H}$ & Hypothesis space\\\\\n$L$ & Loss function \\\\\n$J(\\vec{\\theta})$ & Cost function\\\\\n$f(\\vec{x})$ & Decision function\\\\\n$P(y|\\vec{x})$ & Conditional probability\\\\\n$\\lambda$ & Strength of $\\ell_2$ or $\\ell_1 regularizer$\\\\\n$\\phi(x)$ & Basis function expansion of feature vector $\\vec{x}$\\\\\n$\\Phi$ & Basis function expansion of design matrix $\\vec{X}$\\\\\n$q()$ & Approximate or proposal distribution\\\\\n$Q(\\vec{\\theta},\\vec{\\theta}_{old})$ & Auxiliary function in EM\\\\\n$T$ & Length of a sequence\\\\\n$T(\\mathcal{D})$ & Test statistic for data\\\\\n$\\vec{T}$ & Transition matrix of Markov chain\\\\\n$\\vec{\\theta}$ & Parameter vector\\\\\n$\\vec{\\theta}^{(s)}$ & $s$'th sample of parameter vector\\\\\n$\\hat{\\vec{\\theta}}$ & Estimate (usually MLE or MAP) of $\\vec{\\theta}$\\\\\n$\\hat{\\vec{\\theta}}_{MLE}$ & Maximum likelihood estimate of $\\vec{\\theta}$\\\\\n$\\hat{\\vec{\\theta}}_{MAP}$ & MAP estimate of $\\vec{\\theta}$\\\\\n$\\bar{\\vec{\\theta}}$ & Estimate (usually posterior mean) of  $\\vec{\\theta}$\\\\\n$\\vec{w}$ & Vector of regression weights (called $\\vec{\\beta}$ in statistics)\\\\\nb & intercept (called $\\varepsilon$ in statistics)\\\\\n$\\vec{W}$ & Matrix of regression weights\\\\\n$x_{ij}$ & Component (i.e., feature) $j$ of data case $i$ ,for $i=1:N ,j=1:D$\\\\\n$\\vec{x}_i$ & Training case, $i=1:N$\\\\\n$\\vec{X}$ & Design matrix of size $N \\times D$\\\\\n$\\bar{\\vec{x}}$ & Empirical mean $\\bar{\\vec{x}}=\\dfrac{1}{N}\\sum_{i=1}^{N} \\vec{x}_i$\\\\\n$\\tilde{\\vec{x}}$ & Future test case\\\\\n$\\vec{x}_*$ & Feature test case\\\\\n$\\vec{y}$ & Vector of all training labels $\\vec{y} =(y_1,...,y_N)$\\\\\n$z_{ij}$ & Latent component $j$ for case $i$\\\\\n\\noalign{\\smallskip}\\hline\\noalign{\\smallskip}\n\\end{longtable}\n\n\\twocolumn\n"
  },
  {
    "path": "part.tex",
    "content": "%%%%%%%%%%%%%%%%%%%%%part.tex%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% \n% sample part title\n%\n% Use this file as a template for your own input.\n%\n%%%%%%%%%%%%%%%%%%%%%%%% Springer %%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{partbacktext}\n\\part{Part Title}\n\\noindent Use the template \\emph{part.tex} together with the Springer document class SVMono (monograph-type books) or SVMult (edited books) to style your part title page and, if desired, a short introductory text (maximum one page) on its verso page in the Springer layout.\n\n\\end{partbacktext}"
  },
  {
    "path": "preface.tex",
    "content": "%%%%%%%%%%%%%%%%%%%%%%preface.tex%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% sample preface\n%\n% Use this file as a template for your own input.\n%\n%%%%%%%%%%%%%%%%%%%%%%%% Springer %%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\preface\n\nThis cheat sheet is a condensed version of machine learning manual, which contains many classical equations and diagrams on machine learning, and aims to help you quickly recall knowledge and ideas in machine learning.\n\nThis cheat sheet has two significant advantages:\n\\begin{enumerate}\n\\item Clearer symbols. Mathematical formulas use quite a lot of confusing symbols. For example, $X$ can be a set, a random variable, or a matrix. This is very confusing and makes it very difficult for readers to understand the meaning of math formulas. This cheat sheet tries to standardize the usage of symbols, and all symbols are clearly pre-defined, see section \\S \\ref{sec:Notation}.\n\\item Less thinking jumps. In many machine learning books, authors omit some intermediary steps of a mathematical proof process, which may save some space but causes difficulty for readers to understand this formula and readers get lost in the middle way of the derivation process. This cheat sheet tries to keep important intermediary steps as where as possible.\n\\end{enumerate}\n\n"
  },
  {
    "path": "referenc.tex",
    "content": "%%%%%%%%%%%%%%%%%%%%%%%% referenc.tex %%%%%%%%%%%%%%%%%%%%%\n% sample references\n% \n% Use this file as a template for your own input.\n%\n%%%%%%%%%%%%%%%%%%%%%%%% Springer%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% BibTeX users please use\n% \\bibliographystyle{}\n% \\bibliography{}\n%\n\\biblstarthook{References may be \\textit{cited} in the text either by number (preferred) or by author/year.\\footnote{Make sure that all references from the list are cited in the text. Those not cited should be moved to a separate \\textit{Further Reading} section or chapter.} The reference list should ideally be \\textit{sorted} in alphabetical order -- even if reference numbers are used for the their citation in the text. If there are several works by the same author, the following order should be used: \n\\begin{enumerate}\n\\item all works by the author alone, ordered chronologically by year of publication\n\\item all works by the author with a coauthor, ordered alphabetically by coauthor\n\\item all works by the author with several coauthors, ordered chronologically by year of publication.\n\\end{enumerate}\nThe \\textit{styling} of references\\footnote{Always use the standard abbreviation of a journal's name according to the ISSN \\textit{List of Title Word Abbreviations}, see \\url{http://www.issn.org/en/node/344}} depends on the subject of your book:\n\\begin{itemize}\n\\item The \\textit{two} recommended styles for references in books on \\textit{mathematical, physical, statistical and computer sciences} are depicted in ~\\cite{science-contrib, science-online, science-mono, science-journal, science-DOI} and ~\\cite{phys-online, phys-mono, phys-journal, phys-DOI, phys-contrib}.\n\\item Examples of the most commonly used reference style in books on \\textit{Psychology, Social Sciences} are~\\cite{psysoc-mono, psysoc-online,psysoc-journal, psysoc-contrib, psysoc-DOI}.\n\\item Examples for references in books on \\textit{Humanities, Linguistics, Philosophy} are~\\cite{humlinphil-journal, humlinphil-contrib, humlinphil-mono, humlinphil-online, humlinphil-DOI}.\n\\item Examples of the basic Springer style used in publications on a wide range of subjects such as \\textit{Computer Science, Economics, Engineering, Geosciences, Life Sciences, Medicine, Biomedicine} are ~\\cite{basic-contrib, basic-online, basic-journal, basic-DOI, basic-mono}. \n\\end{itemize}\n}\n\n\\begin{thebibliography}{99.}%\n% and use \\bibitem to create references.\n%\n% Use the following syntax and markup for your references if \n% the subject of your book is from the field \n% \"Mathematics, Physics, Statistics, Computer Science\"\n%\n% Contribution \n\\bibitem{science-contrib} Broy, M.: Software engineering --- from auxiliary to key technologies. In: Broy, M., Dener, E. (eds.) Software Pioneers, pp. 10-13. Springer, Heidelberg (2002)\n%\n% Online Document\n\\bibitem{science-online} Dod, J.: Effective substances. In: The Dictionary of Substances and Their Effects. Royal Society of Chemistry (1999) Available via DIALOG. \\\\\n\\url{http://www.rsc.org/dose/title of subordinate document. Cited 15 Jan 1999}\n%\n% Monograph\n\\bibitem{science-mono} Geddes, K.O., Czapor, S.R., Labahn, G.: Algorithms for Computer Algebra. Kluwer, Boston (1992) \n%\n% Journal article\n\\bibitem{science-journal} Hamburger, C.: Quasimonotonicity, regularity and duality for nonlinear systems of partial differential equations. Ann. Mat. Pura. Appl. \\textbf{169}, 321--354 (1995)\n%\n% Journal article by DOI\n\\bibitem{science-DOI} Slifka, M.K., Whitton, J.L.: Clinical implications of dysregulated cytokine production. J. Mol. Med. (2000) doi: 10.1007/s001090000086 \n%\n\\bigskip\n\n% Use the following (APS) syntax and markup for your references if \n% the subject of your book is from the field \n% \"Mathematics, Physics, Statistics, Computer Science\"\n%\n% Online Document\n\\bibitem{phys-online} J. Dod, in \\textit{The Dictionary of Substances and Their Effects}, Royal Society of Chemistry. (Available via DIALOG, 1999), \n\\url{http://www.rsc.org/dose/title of subordinate document. Cited 15 Jan 1999}\n%\n% Monograph\n\\bibitem{phys-mono} H. Ibach, H. L\\\"uth, \\textit{Solid-State Physics}, 2nd edn. (Springer, New York, 1996), pp. 45-56 \n%\n% Journal article\n\\bibitem{phys-journal} S. Preuss, A. Demchuk Jr., M. Stuke, Appl. Phys. A \\textbf{61}\n%\n% Journal article by DOI\n\\bibitem{phys-DOI} M.K. Slifka, J.L. Whitton, J. Mol. Med., doi: 10.1007/s001090000086\n%\n% Contribution \n\\bibitem{phys-contrib} S.E. Smith, in \\textit{Neuromuscular Junction}, ed. by E. Zaimis. Handbook of Experimental Pharmacology, vol 42 (Springer, Heidelberg, 1976), p. 593\n%\n\\bigskip\n%\n% Use the following syntax and markup for your references if \n% the subject of your book is from the field \n% \"Psychology, Social Sciences\"\n%\n%\n% Monograph\n\\bibitem{psysoc-mono} Calfee, R.~C., \\& Valencia, R.~R. (1991). \\textit{APA guide to preparing manuscripts for journal publication.} Washington, DC: American Psychological Association.\n%\n% Online Document\n\\bibitem{psysoc-online} Dod, J. (1999). Effective substances. In: The dictionary of substances and their effects. Royal Society of Chemistry. Available via DIALOG. \\\\\n\\url{http://www.rsc.org/dose/Effective substances.} Cited 15 Jan 1999.\n%\n% Journal article\n\\bibitem{psysoc-journal} Harris, M., Karper, E., Stacks, G., Hoffman, D., DeNiro, R., Cruz, P., et al. (2001). Writing labs and the Hollywood connection. \\textit{J Film} Writing, 44(3), 213--245.\n%\n% Contribution \n\\bibitem{psysoc-contrib} O'Neil, J.~M., \\& Egan, J. (1992). Men's and women's gender role journeys: Metaphor for healing, transition, and transformation. In B.~R. Wainrig (Ed.), \\textit{Gender issues across the life cycle} (pp. 107--123). New York: Springer.\n%\n% Journal article by DOI\n\\bibitem{psysoc-DOI}Kreger, M., Brindis, C.D., Manuel, D.M., Sassoubre, L. (2007). Lessons learned in systems change initiatives: benchmarks and indicators. \\textit{American Journal of Community Psychology}, doi: 10.1007/s10464-007-9108-14.\n%\n%\n% Use the following syntax and markup for your references if \n% the subject of your book is from the field \n% \"Humanities, Linguistics, Philosophy\"\n%\n\\bigskip\n%\n% Journal article\n\\bibitem{humlinphil-journal} Alber John, Daniel C. O'Connell, and Sabine Kowal. 2002. Personal perspective in TV interviews. \\textit{Pragmatics} 12:257--271\n%\n% Contribution \n\\bibitem{humlinphil-contrib} Cameron, Deborah. 1997. Theoretical debates in feminist linguistics: Questions of sex and gender. In \\textit{Gender and discourse}, ed. Ruth Wodak, 99--119. London: Sage Publications.\n%\n% Monograph\n\\bibitem{humlinphil-mono} Cameron, Deborah. 1985. \\textit{Feminism and linguistic theory.} New York: St. Martin's Press.\n%\n% Online Document\n\\bibitem{humlinphil-online} Dod, Jake. 1999. Effective substances. In: The dictionary of substances and their effects. Royal Society of Chemistry. Available via DIALOG. \\\\\nhttp://www.rsc.org/dose/title of subordinate document. Cited 15 Jan 1999\n%\n% Journal article by DOI\n\\bibitem{humlinphil-DOI} Suleiman, Camelia, Daniel C. OConnell, and Sabine Kowal. 2002. `If you and I, if we, in this later day, lose that sacred fire...': Perspective in political interviews. \\textit{Journal of Psycholinguistic Research}. doi: 10.1023/A:1015592129296.\n%\n%\n%\n\\bigskip\n%\n%\n% Use the following syntax and markup for your references if \n% the subject of your book is from the field \n% \"Computer Science, Economics, Engineering, Geosciences, Life Sciences\"\n%\n%\n% Contribution \n\\bibitem{basic-contrib} Brown B, Aaron M (2001) The politics of nature. In: Smith J (ed) The rise of modern genomics, 3rd edn. Wiley, New York \n%\n% Online Document\n\\bibitem{basic-online} Dod J (1999) Effective Substances. In: The dictionary of substances and their effects. Royal Society of Chemistry. Available via DIALOG. \\\\\n\\url{http://www.rsc.org/dose/title of subordinate document. Cited 15 Jan 1999}\n%\n% Journal article by DOI\n\\bibitem{basic-DOI} Slifka MK, Whitton JL (2000) Clinical implications of dysregulated cytokine production. J Mol Med, doi: 10.1007/s001090000086\n%\n% Journal article\n\\bibitem{basic-journal} Smith J, Jones M Jr, Houghton L et al (1999) Future of health insurance. N Engl J Med 965:325--329\n%\n% Monograph\n\\bibitem{basic-mono} South J, Blass B (2001) The future of modern genomics. Blackwell, London \n%\n\\end{thebibliography}\n"
  },
  {
    "path": "styles/spbasic.bst",
    "content": "%%\n%% This is file `spbasic.bst',\n%% generated with the docstrip utility.\n%%\n%% The original source files were:\n%%\n%% merlin.mbs  (with options: `ay,nat,seq-lab,vonx,nm-rvx,ed-rev,jnrlst,dt-beg,yr-par,yrp-x,yrpp-xsp,note-yr,jxper,jttl-rm,thtit-a,pgsep-c,num-xser,ser-vol,jnm-x,btit-rm,bt-rm,pre-pub,doi,edparxc,blk-tit,in-col,fin-bare,pp,ed,abr,mth-bare,ord,jabr,xand,eprint,url,url-blk,em-x,nfss,')\n%% ----------------------------------------\n%%\n%%********************************************************************************%%\n%%                                                                                %%\n%% For Springer medical, life sciences, chemistry, geology, engineering and       %%\n%%   computer science publications.                                               %%\n%% For use with the natbib package (see below). Default is author-year citations. %%\n%%   When citations are numbered, please use \\usepackage[numbers]{natbib}.        %%\n%% A lack of punctuation is the key feature. Springer-Verlag 2004/10/15           %%\n%% Report bugs and improvements to: Joylene Vette-Guillaume or Frank Holzwarth    %%\n%%                                                                                %%\n%%********************************************************************************%%\n%%\n%% Copyright 1994-2004 Patrick W Daly\n % ===============================================================\n % IMPORTANT NOTICE:\n % This bibliographic style (bst) file has been generated from one or\n % more master bibliographic style (mbs) files, listed above.\n %\n % This generated file can be redistributed and/or modified under the terms\n % of the LaTeX Project Public License Distributed from CTAN\n % archives in directory macros/latex/base/lppl.txt; either\n % version 1 of the License, or any later version.\n % ===============================================================\n % Name and version information of the main mbs file:\n % \\ProvidesFile{merlin.mbs}[2004/02/09 4.13 (PWD, AO, DPC)]\n %   For use with BibTeX version 0.99a or later\n %-------------------------------------------------------------------\n % This bibliography style file is intended for texts in ENGLISH\n % This is an author-year citation style bibliography. As such, it is\n % non-standard LaTeX, and requires a special package file to function properly.\n % Such a package is    natbib.sty   by Patrick W. Daly\n % The form of the \\bibitem entries is\n %   \\bibitem[Jones et al.(1990)]{key}...\n %   \\bibitem[Jones et al.(1990)Jones, Baker, and Smith]{key}...\n % The essential feature is that the label (the part in brackets) consists\n % of the author names, as they should appear in the citation, with the year\n % in parentheses following. There must be no space before the opening\n % parenthesis!\n % With natbib v5.3, a full list of authors may also follow the year.\n % In natbib.sty, it is possible to define the type of enclosures that is\n % really wanted (brackets or parentheses), but in either case, there must\n % be parentheses in the label.\n % The \\cite command functions as follows:\n %   \\citet{key} ==>>                Jones et al. (1990)\n %   \\citet*{key} ==>>               Jones, Baker, and Smith (1990)\n %   \\citep{key} ==>>                (Jones et al., 1990)\n %   \\citep*{key} ==>>               (Jones, Baker, and Smith, 1990)\n %   \\citep[chap. 2]{key} ==>>       (Jones et al., 1990, chap. 2)\n %   \\citep[e.g.][]{key} ==>>        (e.g. Jones et al., 1990)\n %   \\citep[e.g.][p. 32]{key} ==>>   (e.g. Jones et al., p. 32)\n %   \\citeauthor{key} ==>>           Jones et al.\n %   \\citeauthor*{key} ==>>          Jones, Baker, and Smith\n %   \\citeyear{key} ==>>             1990\n %---------------------------------------------------------------------\n\nENTRY\n  { address\n    archive\n    author\n    booktitle\n    chapter\n    doi\n    edition\n    editor\n    eid\n    eprint\n    howpublished\n    institution\n    journal\n    key\n    month\n    note\n    number\n    organization\n    pages\n    publisher\n    school\n    series\n    title\n    type\n    url\n    volume\n    year\n  }\n  {}\n  { label extra.label sort.label short.list }\nINTEGERS { output.state before.all mid.sentence after.sentence after.block }\nFUNCTION {init.state.consts}\n{ #0 'before.all :=\n  #1 'mid.sentence :=\n  #2 'after.sentence :=\n  #3 'after.block :=\n}\nSTRINGS { s t}\nFUNCTION {output.nonnull}\n{ 's :=\n  output.state mid.sentence =\n    { \", \" * write$ }\n    { output.state after.block =\n        { add.period$ write$\n          newline$\n          \"\\newblock \" write$\n        }\n        { output.state before.all =\n            'write$\n            { add.period$ \" \" * write$ }\n          if$\n        }\n      if$\n      mid.sentence 'output.state :=\n    }\n  if$\n  s\n}\nFUNCTION {output}\n{ duplicate$ empty$\n    'pop$\n    'output.nonnull\n  if$\n}\nFUNCTION {output.check}\n{ 't :=\n  duplicate$ empty$\n    { pop$ \"empty \" t * \" in \" * cite$ * warning$ }\n    'output.nonnull\n  if$\n}\nFUNCTION {fin.entry}\n{ duplicate$ empty$\n    'pop$\n    'write$\n  if$\n  newline$\n}\n\nFUNCTION {new.block}\n{ output.state before.all =\n    'skip$\n    { after.block 'output.state := }\n  if$\n}\nFUNCTION {new.sentence}\n{ output.state after.block =\n    'skip$\n    { output.state before.all =\n        'skip$\n        { after.sentence 'output.state := }\n      if$\n    }\n  if$\n}\nFUNCTION {add.blank}\n{  \" \" * before.all 'output.state :=\n}\n\nFUNCTION {no.blank.or.punct}\n{  \"\\hspace{0pt}\" * before.all 'output.state :=\n}\n\nFUNCTION {date.block}\n{\n    add.blank\n}\n\nFUNCTION {not}\n{   { #0 }\n    { #1 }\n  if$\n}\nFUNCTION {and}\n{   'skip$\n    { pop$ #0 }\n  if$\n}\nFUNCTION {or}\n{   { pop$ #1 }\n    'skip$\n  if$\n}\nSTRINGS {z}\nFUNCTION {remove.dots}\n{ 'z :=\n  \"\"\n  { z empty$ not }\n  { z #1 #1 substring$\n    z #2 global.max$ substring$ 'z :=\n    duplicate$ \".\" = 'pop$\n      { * }\n    if$\n  }\n  while$\n}\nFUNCTION {new.block.checkb}\n{ empty$\n  swap$ empty$\n  and\n    'skip$\n    'new.block\n  if$\n}\nFUNCTION {field.or.null}\n{ duplicate$ empty$\n    { pop$ \"\" }\n    'skip$\n  if$\n}\nFUNCTION {emphasize}\n{ skip$ }\nFUNCTION {tie.or.space.prefix}\n{ duplicate$ text.length$ #3 <\n    { \"~\" }\n    { \" \" }\n  if$\n  swap$\n}\n\nFUNCTION {capitalize}\n{ \"u\" change.case$ \"t\" change.case$ }\n\nFUNCTION {space.word}\n{ \" \" swap$ * \" \" * }\n % Here are the language-specific definitions for explicit words.\n % Each function has a name bbl.xxx where xxx is the English word.\n % The language selected here is ENGLISH\nFUNCTION {bbl.and}\n{ \"and\"}\n\nFUNCTION {bbl.etal}\n{ \"et~al\" }\n\nFUNCTION {bbl.editors}\n{ \"eds\" }\n\nFUNCTION {bbl.editor}\n{ \"ed\" }\n\nFUNCTION {bbl.edby}\n{ \"edited by\" }\n\nFUNCTION {bbl.edition}\n{ \"edn\" }\n\nFUNCTION {bbl.volume}\n{ \"vol\" }\n\nFUNCTION {bbl.of}\n{ \"of\" }\n\nFUNCTION {bbl.number}\n{ \"no.\" }\n\nFUNCTION {bbl.nr}\n{ \"no.\" }\n\nFUNCTION {bbl.in}\n{ \"in\" }\n\nFUNCTION {bbl.pages}\n{ \"pp\" }\n\nFUNCTION {bbl.page}\n{ \"p\" }\n\nFUNCTION {bbl.chapter}\n{ \"chap\" }\n\nFUNCTION {bbl.techrep}\n{ \"Tech. Rep.\" }\n\nFUNCTION {bbl.mthesis}\n{ \"Master's thesis\" }\n\nFUNCTION {bbl.phdthesis}\n{ \"PhD thesis\" }\n\nFUNCTION {bbl.first}\n{ \"1st\" }\n\nFUNCTION {bbl.second}\n{ \"2nd\" }\n\nFUNCTION {bbl.third}\n{ \"3rd\" }\n\nFUNCTION {bbl.fourth}\n{ \"4th\" }\n\nFUNCTION {bbl.fifth}\n{ \"5th\" }\n\nFUNCTION {bbl.st}\n{ \"st\" }\n\nFUNCTION {bbl.nd}\n{ \"nd\" }\n\nFUNCTION {bbl.rd}\n{ \"rd\" }\n\nFUNCTION {bbl.th}\n{ \"th\" }\n\nMACRO {jan} {\"Jan.\"}\n\nMACRO {feb} {\"Feb.\"}\n\nMACRO {mar} {\"Mar.\"}\n\nMACRO {apr} {\"Apr.\"}\n\nMACRO {may} {\"May\"}\n\nMACRO {jun} {\"Jun.\"}\n\nMACRO {jul} {\"Jul.\"}\n\nMACRO {aug} {\"Aug.\"}\n\nMACRO {sep} {\"Sep.\"}\n\nMACRO {oct} {\"Oct.\"}\n\nMACRO {nov} {\"Nov.\"}\n\nMACRO {dec} {\"Dec.\"}\n\nFUNCTION {eng.ord}\n{ duplicate$ \"1\" swap$ *\n  #-2 #1 substring$ \"1\" =\n     { bbl.th * }\n     { duplicate$ #-1 #1 substring$\n       duplicate$ \"1\" =\n         { pop$ bbl.st * }\n         { duplicate$ \"2\" =\n             { pop$ bbl.nd * }\n             { \"3\" =\n                 { bbl.rd * }\n                 { bbl.th * }\n               if$\n             }\n           if$\n          }\n       if$\n     }\n   if$\n}\n\nMACRO {acmcs} {\"ACM Comput Surv\"}\n\nMACRO {acta} {\"Acta Inf\"}\n\nMACRO {cacm} {\"Commun ACM\"}\n\nMACRO {ibmjrd} {\"IBM~J~Res Dev\"}\n\nMACRO {ibmsj} {\"IBM Syst~J\"}\n\nMACRO {ieeese} {\"IEEE Trans Softw Eng\"}\n\nMACRO {ieeetc} {\"IEEE Trans Comput\"}\n\nMACRO {ieeetcad}\n {\"IEEE Trans Comput Aid Des\"}\n\nMACRO {ipl} {\"Inf Process Lett\"}\n\nMACRO {jacm} {\"J~ACM\"}\n\nMACRO {jcss} {\"J~Comput Syst Sci\"}\n\nMACRO {scp} {\"Sci Comput Program\"}\n\nMACRO {sicomp} {\"SIAM J~Comput\"}\n\nMACRO {tocs} {\"ACM Trans Comput Syst\"}\n\nMACRO {tods} {\"ACM Trans Database Syst\"}\n\nMACRO {tog} {\"ACM Trans Graphic\"}\n\nMACRO {toms} {\"ACM Trans Math Softw\"}\n\nMACRO {toois} {\"ACM Trans Office Inf Syst\"}\n\nMACRO {toplas} {\"ACM Trans Program Lang Syst\"}\n\nMACRO {tcs} {\"Theor Comput Sci\"}\n\nFUNCTION {bibinfo.check}\n{ swap$\n  duplicate$ missing$\n    {\n      pop$ pop$\n      \"\"\n    }\n    { duplicate$ empty$\n        {\n          swap$ pop$\n        }\n        { swap$\n          pop$\n        }\n      if$\n    }\n  if$\n}\nFUNCTION {bibinfo.warn}\n{ swap$\n  duplicate$ missing$\n    {\n      swap$ \"missing \" swap$ * \" in \" * cite$ * warning$ pop$\n      \"\"\n    }\n    { duplicate$ empty$\n        {\n          swap$ \"empty \" swap$ * \" in \" * cite$ * warning$\n        }\n        { swap$\n          pop$\n        }\n      if$\n    }\n  if$\n}\nFUNCTION {format.eprint}\n{ eprint duplicate$ empty$\n    'skip$\n    { \"\\eprint\"\n      archive empty$\n        'skip$\n        { \"[\" * archive * \"]\" * }\n      if$\n      \"{\" * swap$ * \"}\" *\n    }\n  if$\n}\nFUNCTION {format.url}\n{ url empty$\n    { \"\" }\n    { \"\\urlprefix\\url{\" url * \"}\" * }\n  if$\n}\n\nSTRINGS  { bibinfo}\nINTEGERS { nameptr namesleft numnames }\n\nFUNCTION {format.names}\n{ 'bibinfo :=\n  duplicate$ empty$ 'skip$ {\n  's :=\n  \"\" 't :=\n  #1 'nameptr :=\n  s num.names$ 'numnames :=\n  numnames 'namesleft :=\n    { namesleft #0 > }\n    { s nameptr\n      \"{vv~}{ll}{ f{}}{ jj}\"\n      format.name$\n      remove.dots\n      bibinfo bibinfo.check\n      't :=\n      nameptr #1 >\n        {\n          namesleft #1 >\n            { \", \" * t * }\n            {\n              \",\" *\n              s nameptr \"{ll}\" format.name$ duplicate$ \"others\" =\n                { 't := }\n                { pop$ }\n              if$\n              t \"others\" =\n                {\n                  \" \" * bbl.etal *\n                }\n                { \" \" * t * }\n              if$\n            }\n          if$\n        }\n        't\n      if$\n      nameptr #1 + 'nameptr :=\n      namesleft #1 - 'namesleft :=\n    }\n  while$\n  } if$\n}\nFUNCTION {format.names.ed}\n{\n  format.names\n}\nFUNCTION {format.key}\n{ empty$\n    { key field.or.null }\n    { \"\" }\n  if$\n}\n\nFUNCTION {format.authors}\n{ author \"author\" format.names\n}\nFUNCTION {get.bbl.editor}\n{ editor num.names$ #1 > 'bbl.editors 'bbl.editor if$ }\n\nFUNCTION {format.editors}\n{ editor \"editor\" format.names duplicate$ empty$ 'skip$\n    {\n      \" \" *\n      get.bbl.editor\n   \"(\" swap$ * \")\" *\n      *\n    }\n  if$\n}\nFUNCTION {format.doi}\n{ doi \"doi\" bibinfo.check\n  duplicate$ empty$ 'skip$\n    {\n      \"\\doi{\" swap$ * \"}\" *\n    }\n  if$\n}\nFUNCTION {format.note}\n{\n note empty$\n    { \"\" }\n    { note #1 #1 substring$\n      duplicate$ \"{\" =\n        'skip$\n        { output.state mid.sentence =\n          { \"l\" }\n          { \"u\" }\n        if$\n        change.case$\n        }\n      if$\n      note #2 global.max$ substring$ * \"note\" bibinfo.check\n    }\n  if$\n}\n\nFUNCTION {format.title}\n{ title\n  duplicate$ empty$ 'skip$\n    { \"t\" change.case$ }\n  if$\n  \"title\" bibinfo.check\n}\nFUNCTION {format.full.names}\n{'s :=\n \"\" 't :=\n  #1 'nameptr :=\n  s num.names$ 'numnames :=\n  numnames 'namesleft :=\n    { namesleft #0 > }\n    { s nameptr\n      \"{vv~}{ll}\" format.name$\n      't :=\n      nameptr #1 >\n        {\n          namesleft #1 >\n            { \", \" * t * }\n            {\n              s nameptr \"{ll}\" format.name$ duplicate$ \"others\" =\n                { 't := }\n                { pop$ }\n              if$\n              t \"others\" =\n                {\n                  \" \" * bbl.etal *\n                }\n                {\n                  numnames #2 >\n                    { \",\" * }\n                    'skip$\n                  if$\n                  bbl.and\n                  space.word * t *\n                }\n              if$\n            }\n          if$\n        }\n        't\n      if$\n      nameptr #1 + 'nameptr :=\n      namesleft #1 - 'namesleft :=\n    }\n  while$\n}\n\nFUNCTION {author.editor.key.full}\n{ author empty$\n    { editor empty$\n        { key empty$\n            { cite$ #1 #3 substring$ }\n            'key\n          if$\n        }\n        { editor format.full.names }\n      if$\n    }\n    { author format.full.names }\n  if$\n}\n\nFUNCTION {author.key.full}\n{ author empty$\n    { key empty$\n         { cite$ #1 #3 substring$ }\n          'key\n      if$\n    }\n    { author format.full.names }\n  if$\n}\n\nFUNCTION {editor.key.full}\n{ editor empty$\n    { key empty$\n         { cite$ #1 #3 substring$ }\n          'key\n      if$\n    }\n    { editor format.full.names }\n  if$\n}\n\nFUNCTION {make.full.names}\n{ type$ \"book\" =\n  type$ \"inbook\" =\n  or\n    'author.editor.key.full\n    { type$ \"proceedings\" =\n        'editor.key.full\n        'author.key.full\n      if$\n    }\n  if$\n}\n\nFUNCTION {output.bibitem}\n{ newline$\n  \"\\bibitem[{\" write$\n  label write$\n  \")\" make.full.names duplicate$ short.list =\n     { pop$ }\n     { * }\n   if$\n  \"}]{\" * write$\n  cite$ write$\n  \"}\" write$\n  newline$\n  \"\"\n  before.all 'output.state :=\n}\n\nFUNCTION {add.period}\n{ duplicate$ empty$\n    'skip$\n    { \".\" * add.blank }\n  if$\n}\n\nFUNCTION {if.digit}\n{ duplicate$ \"0\" =\n  swap$ duplicate$ \"1\" =\n  swap$ duplicate$ \"2\" =\n  swap$ duplicate$ \"3\" =\n  swap$ duplicate$ \"4\" =\n  swap$ duplicate$ \"5\" =\n  swap$ duplicate$ \"6\" =\n  swap$ duplicate$ \"7\" =\n  swap$ duplicate$ \"8\" =\n  swap$ \"9\" = or or or or or or or or or\n}\nFUNCTION {n.separate}\n{ 't :=\n  \"\"\n  #0 'numnames :=\n  { t empty$ not }\n  { t #-1 #1 substring$ if.digit\n      { numnames #1 + 'numnames := }\n      { #0 'numnames := }\n    if$\n    t #-1 #1 substring$ swap$ *\n    t #-2 global.max$ substring$ 't :=\n    numnames #5 =\n      { duplicate$ #1 #2 substring$ swap$\n        #3 global.max$ substring$\n        \",\" swap$ * *\n      }\n      'skip$\n    if$\n  }\n  while$\n}\nFUNCTION {n.dashify}\n{\n  n.separate\n  't :=\n  \"\"\n    { t empty$ not }\n    { t #1 #1 substring$ \"-\" =\n        { t #1 #2 substring$ \"--\" = not\n            { \"--\" *\n              t #2 global.max$ substring$ 't :=\n            }\n            {   { t #1 #1 substring$ \"-\" = }\n                { \"-\" *\n                  t #2 global.max$ substring$ 't :=\n                }\n              while$\n            }\n          if$\n        }\n        { t #1 #1 substring$ *\n          t #2 global.max$ substring$ 't :=\n        }\n      if$\n    }\n  while$\n}\n\nFUNCTION {word.in}\n{ bbl.in capitalize\n  \":\" *\n  \" \" * }\n\nFUNCTION {format.date}\n{ year \"year\" bibinfo.check duplicate$ empty$\n    {\n      \"empty year in \" cite$ * \"; set to ????\" * warning$\n       pop$ \"????\"\n    }\n    'skip$\n  if$\n  extra.label *\n  before.all 'output.state :=\n  \" (\" swap$ * \")\" *\n}\nFUNCTION {format.btitle}\n{ title \"title\" bibinfo.check\n  duplicate$ empty$ 'skip$\n    {\n    }\n  if$\n}\nFUNCTION {either.or.check}\n{ empty$\n    'pop$\n    { \"can't use both \" swap$ * \" fields in \" * cite$ * warning$ }\n  if$\n}\nFUNCTION {format.bvolume}\n{ volume empty$\n    { \"\" }\n    { bbl.volume volume tie.or.space.prefix\n      \"volume\" bibinfo.check * *\n      series \"series\" bibinfo.check\n      duplicate$ empty$ 'pop$\n        { emphasize \", \" * swap$ * }\n      if$\n      \"volume and number\" number either.or.check\n    }\n  if$\n}\nFUNCTION {format.number.series}\n{ volume empty$\n    { number empty$\n        { series field.or.null }\n        { series empty$\n            { number \"number\" bibinfo.check }\n            { output.state mid.sentence =\n                { bbl.number }\n                { bbl.number capitalize }\n              if$\n              number tie.or.space.prefix \"number\" bibinfo.check * *\n              bbl.in space.word *\n              series \"series\" bibinfo.check *\n            }\n          if$\n        }\n      if$\n    }\n    { \"\" }\n  if$\n}\nFUNCTION {is.num}\n{ chr.to.int$\n  duplicate$ \"0\" chr.to.int$ < not\n  swap$ \"9\" chr.to.int$ > not and\n}\n\nFUNCTION {extract.num}\n{ duplicate$ 't :=\n  \"\" 's :=\n  { t empty$ not }\n  { t #1 #1 substring$\n    t #2 global.max$ substring$ 't :=\n    duplicate$ is.num\n      { s swap$ * 's := }\n      { pop$ \"\" 't := }\n    if$\n  }\n  while$\n  s empty$\n    'skip$\n    { pop$ s }\n  if$\n}\n\nFUNCTION {convert.edition}\n{ extract.num \"l\" change.case$ 's :=\n  s \"first\" = s \"1\" = or\n    { bbl.first 't := }\n    { s \"second\" = s \"2\" = or\n        { bbl.second 't := }\n        { s \"third\" = s \"3\" = or\n            { bbl.third 't := }\n            { s \"fourth\" = s \"4\" = or\n                { bbl.fourth 't := }\n                { s \"fifth\" = s \"5\" = or\n                    { bbl.fifth 't := }\n                    { s #1 #1 substring$ is.num\n                        { s eng.ord 't := }\n                        { edition 't := }\n                      if$\n                    }\n                  if$\n                }\n              if$\n            }\n          if$\n        }\n      if$\n    }\n  if$\n  t\n}\n\nFUNCTION {format.edition}\n{ edition duplicate$ empty$ 'skip$\n    {\n      convert.edition\n      output.state mid.sentence =\n        { \"l\" }\n        { \"t\" }\n      if$ change.case$\n      \"edition\" bibinfo.check\n      \" \" * bbl.edition *\n    }\n  if$\n}\nINTEGERS { multiresult }\nFUNCTION {multi.page.check}\n{ 't :=\n  #0 'multiresult :=\n    { multiresult not\n      t empty$ not\n      and\n    }\n    { t #1 #1 substring$\n      duplicate$ \"-\" =\n      swap$ duplicate$ \",\" =\n      swap$ \"+\" =\n      or or\n        { #1 'multiresult := }\n        { t #2 global.max$ substring$ 't := }\n      if$\n    }\n  while$\n  multiresult\n}\nFUNCTION {format.pages}\n{ pages duplicate$ empty$ 'skip$\n    { duplicate$ multi.page.check\n        {\n          bbl.pages swap$\n          n.dashify\n        }\n        {\n          bbl.page swap$\n        }\n      if$\n      tie.or.space.prefix\n      \"pages\" bibinfo.check\n      * *\n    }\n  if$\n}\nFUNCTION {format.journal.pages}\n{ pages duplicate$ empty$ 'pop$\n    { swap$ duplicate$ empty$\n        { pop$ pop$ format.pages }\n        {\n          \":\" *\n          swap$\n          n.dashify\n          \"pages\" bibinfo.check\n          *\n        }\n      if$\n    }\n  if$\n}\nFUNCTION {format.journal.eid}\n{ eid \"eid\" bibinfo.check\n  duplicate$ empty$ 'pop$\n    { swap$ duplicate$ empty$ 'skip$\n      {\n          \":\" *\n      }\n      if$\n      swap$ *\n    }\n  if$\n}\nFUNCTION {format.vol.num.pages}\n{ volume field.or.null\n  duplicate$ empty$ 'skip$\n    {\n      \"volume\" bibinfo.check\n    }\n  if$\n  number \"number\" bibinfo.check duplicate$ empty$ 'skip$\n    {\n      swap$ duplicate$ empty$\n        { \"there's a number but no volume in \" cite$ * warning$ }\n        'skip$\n      if$\n      swap$\n      \"(\" swap$ * \")\" *\n    }\n  if$ *\n  eid empty$\n    { format.journal.pages }\n    { format.journal.eid }\n  if$\n}\n\nFUNCTION {format.chapter.pages}\n{ chapter empty$\n    'format.pages\n    { type empty$\n        { bbl.chapter }\n        { type \"l\" change.case$\n          \"type\" bibinfo.check\n        }\n      if$\n      chapter tie.or.space.prefix\n      \"chapter\" bibinfo.check\n      * *\n      pages empty$\n        'skip$\n        { \", \" * format.pages * }\n      if$\n    }\n  if$\n}\n\nFUNCTION {format.booktitle}\n{\n  booktitle \"booktitle\" bibinfo.check\n}\nFUNCTION {format.in.ed.booktitle}\n{ format.booktitle duplicate$ empty$ 'skip$\n    {\n      editor \"editor\" format.names.ed duplicate$ empty$ 'pop$\n        {\n          \" \" *\n          get.bbl.editor\n          \"(\" swap$ * \") \" *\n          * swap$\n          * }\n      if$\n      word.in swap$ *\n    }\n  if$\n}\nFUNCTION {format.thesis.type}\n{ type duplicate$ empty$\n    'pop$\n    { swap$ pop$\n      \"t\" change.case$ \"type\" bibinfo.check\n    }\n  if$\n}\nFUNCTION {format.tr.number}\n{ number \"number\" bibinfo.check\n  type duplicate$ empty$\n    { pop$ bbl.techrep }\n    'skip$\n  if$\n  \"type\" bibinfo.check\n  swap$ duplicate$ empty$\n    { pop$ \"t\" change.case$ }\n    { tie.or.space.prefix * * }\n  if$\n}\nFUNCTION {format.article.crossref}\n{\n  word.in\n  \" \\cite{\" * crossref * \"}\" *\n}\nFUNCTION {format.book.crossref}\n{ volume duplicate$ empty$\n    { \"empty volume in \" cite$ * \"'s crossref of \" * crossref * warning$\n      pop$ word.in\n    }\n    { bbl.volume\n      capitalize\n      swap$ tie.or.space.prefix \"volume\" bibinfo.check * * bbl.of space.word *\n    }\n  if$\n  \" \\cite{\" * crossref * \"}\" *\n}\nFUNCTION {format.incoll.inproc.crossref}\n{\n  word.in\n  \" \\cite{\" * crossref * \"}\" *\n}\nFUNCTION {format.org.or.pub}\n{ 't :=\n  \"\"\n  address empty$ t empty$ and\n    'skip$\n    {\n      t empty$\n        { address \"address\" bibinfo.check *\n        }\n        { t *\n          address empty$\n            'skip$\n            { \", \" * address \"address\" bibinfo.check * }\n          if$\n        }\n      if$\n    }\n  if$\n}\nFUNCTION {format.publisher.address}\n{ publisher \"publisher\" bibinfo.warn format.org.or.pub\n}\n\nFUNCTION {format.organization.address}\n{ organization \"organization\" bibinfo.check format.org.or.pub\n}\n\nFUNCTION {article}\n{ output.bibitem\n  format.authors \"author\" output.check\n  author format.key output\n  format.date \"year\" output.check\n  date.block\n  format.title \"title\" output.check\n  new.sentence\n  crossref missing$\n    {\n      journal\n      remove.dots\n      \"journal\" bibinfo.check\n      \"journal\" output.check\n      add.blank\n      format.vol.num.pages output\n    }\n    { format.article.crossref output.nonnull\n      format.pages output\n    }\n  if$\n  format.doi output\n  format.url output\n  format.note output\n  format.eprint output\n  fin.entry\n}\nFUNCTION {book}\n{ output.bibitem\n  author empty$\n    { format.editors \"author and editor\" output.check\n      editor format.key output\n      add.blank\n    }\n    { format.authors output.nonnull\n      crossref missing$\n        { \"author and editor\" editor either.or.check }\n        'skip$\n      if$\n    }\n  if$\n  format.date \"year\" output.check\n  date.block\n  format.btitle \"title\" output.check\n  crossref missing$\n    { format.bvolume output\n      format.edition output\n  new.sentence\n      format.number.series output\n      format.publisher.address output\n    }\n    {\n  new.sentence\n      format.book.crossref output.nonnull\n    }\n  if$\n  format.doi output\n  format.url output\n  format.note output\n  format.eprint output\n  fin.entry\n}\nFUNCTION {booklet}\n{ output.bibitem\n  format.authors output\n  author format.key output\n  format.date \"year\" output.check\n  date.block\n  format.title \"title\" output.check\n  new.sentence\n  howpublished \"howpublished\" bibinfo.check output\n  address \"address\" bibinfo.check output\n  format.doi output\n  format.url output\n  format.note output\n  format.eprint output\n  fin.entry\n}\n\nFUNCTION {inbook}\n{ output.bibitem\n  author empty$\n    { format.editors \"author and editor\" output.check\n      editor format.key output\n    }\n    { format.authors output.nonnull\n      crossref missing$\n        { \"author and editor\" editor either.or.check }\n        'skip$\n      if$\n    }\n  if$\n  format.date \"year\" output.check\n  date.block\n  format.btitle \"title\" output.check\n  crossref missing$\n    {\n      format.bvolume output\n      format.edition output\n      format.publisher.address output\n      format.chapter.pages \"chapter and pages\" output.check\n  new.sentence\n      format.number.series output\n    }\n    {\n      format.chapter.pages \"chapter and pages\" output.check\n  new.sentence\n      format.book.crossref output.nonnull\n    }\n  if$\n  format.doi output\n  format.url output\n  format.note output\n  format.eprint output\n  fin.entry\n}\n\nFUNCTION {incollection}\n{ output.bibitem\n  format.authors \"author\" output.check\n  author format.key output\n  format.date \"year\" output.check\n  date.block\n  format.title \"title\" output.check\n  new.sentence\n  crossref missing$\n    { format.in.ed.booktitle \"booktitle\" output.check\n      format.bvolume output\n      format.edition output\n      format.number.series output\n      format.publisher.address output\n      format.chapter.pages output\n    }\n    { format.incoll.inproc.crossref output.nonnull\n      format.chapter.pages output\n    }\n  if$\n  format.doi output\n  format.url output\n  format.note output\n  format.eprint output\n  fin.entry\n}\nFUNCTION {inproceedings}\n{ output.bibitem\n  format.authors \"author\" output.check\n  author format.key output\n  format.date \"year\" output.check\n  date.block\n  format.title \"title\" output.check\n  new.sentence\n  crossref missing$\n    { format.in.ed.booktitle \"booktitle\" output.check\n      publisher empty$\n        { format.organization.address output }\n        { organization \"organization\" bibinfo.check output\n          format.publisher.address output\n        }\n      if$\n      format.bvolume output\n      format.number.series output\n      format.pages output\n    }\n    { format.incoll.inproc.crossref output.nonnull\n      format.pages output\n    }\n  if$\n  format.doi output\n  format.url output\n  format.note output\n  format.eprint output\n  fin.entry\n}\nFUNCTION {conference} { inproceedings }\nFUNCTION {manual}\n{ output.bibitem\n  format.authors output\n  author format.key output\n  format.date \"year\" output.check\n  date.block\n  format.btitle \"title\" output.check\n  new.sentence\n  organization \"organization\" bibinfo.check output\n  address \"address\" bibinfo.check output\n  format.edition output\n  format.doi output\n  format.url output\n  format.note output\n  format.eprint output\n  fin.entry\n}\n\nFUNCTION {mastersthesis}\n{ output.bibitem\n  format.authors \"author\" output.check\n  author format.key output\n  format.date \"year\" output.check\n  date.block\n  format.title\n  \"title\" output.check\n  new.sentence\n  bbl.mthesis format.thesis.type output.nonnull\n  school \"school\" bibinfo.warn output\n  address \"address\" bibinfo.check output\n  format.doi output\n  format.url output\n  format.note output\n  format.eprint output\n  fin.entry\n}\n\nFUNCTION {misc}\n{ output.bibitem\n  format.authors output\n  author format.key output\n  format.date \"year\" output.check\n  date.block\n  format.title output\n  new.sentence\n  howpublished \"howpublished\" bibinfo.check output\n  format.doi output\n  format.url output\n  format.note output\n  format.eprint output\n  fin.entry\n}\nFUNCTION {phdthesis}\n{ output.bibitem\n  format.authors \"author\" output.check\n  author format.key output\n  format.date \"year\" output.check\n  date.block\n  format.title\n  \"title\" output.check\n  new.sentence\n  bbl.phdthesis format.thesis.type output.nonnull\n  school \"school\" bibinfo.warn output\n  address \"address\" bibinfo.check output\n  format.doi output\n  format.url output\n  format.note output\n  format.eprint output\n  fin.entry\n}\n\nFUNCTION {proceedings}\n{ output.bibitem\n  format.editors output\n  editor format.key output\n  format.date \"year\" output.check\n  date.block\n  format.btitle \"title\" output.check\n  format.bvolume output\n  format.number.series output\n  publisher empty$\n    { format.organization.address output }\n    { organization \"organization\" bibinfo.check output\n      format.publisher.address output\n    }\n  if$\n  format.doi output\n  format.url output\n  format.note output\n  format.eprint output\n  fin.entry\n}\n\nFUNCTION {techreport}\n{ output.bibitem\n  format.authors \"author\" output.check\n  author format.key output\n  format.date \"year\" output.check\n  date.block\n  format.title\n  \"title\" output.check\n  new.sentence\n  format.tr.number output.nonnull\n  institution \"institution\" bibinfo.warn output\n  address \"address\" bibinfo.check output\n  format.doi output\n  format.url output\n  format.note output\n  format.eprint output\n  fin.entry\n}\n\nFUNCTION {unpublished}\n{ output.bibitem\n  format.authors \"author\" output.check\n  author format.key output\n  format.date \"year\" output.check\n  date.block\n  format.title \"title\" output.check\n  format.doi output\n  format.url output\n  format.note \"note\" output.check\n  format.eprint output\n  fin.entry\n}\n\nFUNCTION {default.type} { misc }\nREAD\nFUNCTION {sortify}\n{ purify$\n  \"l\" change.case$\n}\nINTEGERS { len }\nFUNCTION {chop.word}\n{ 's :=\n  'len :=\n  s #1 len substring$ =\n    { s len #1 + global.max$ substring$ }\n    's\n  if$\n}\nFUNCTION {format.lab.names}\n{ 's :=\n  \"\" 't :=\n  s #1 \"{vv~}{ll}\" format.name$\n  s num.names$ duplicate$\n  #2 >\n    { pop$\n      \" \" * bbl.etal *\n    }\n    { #2 <\n        'skip$\n        { s #2 \"{ff }{vv }{ll}{ jj}\" format.name$ \"others\" =\n            {\n              \" \" * bbl.etal *\n            }\n            { bbl.and space.word * s #2 \"{vv~}{ll}\" format.name$\n              * }\n          if$\n        }\n      if$\n    }\n  if$\n}\n\nFUNCTION {author.key.label}\n{ author empty$\n    { key empty$\n        { cite$ #1 #3 substring$ }\n        'key\n      if$\n    }\n    { author format.lab.names }\n  if$\n}\n\nFUNCTION {author.editor.key.label}\n{ author empty$\n    { editor empty$\n        { key empty$\n            { cite$ #1 #3 substring$ }\n            'key\n          if$\n        }\n        { editor format.lab.names }\n      if$\n    }\n    { author format.lab.names }\n  if$\n}\n\nFUNCTION {editor.key.label}\n{ editor empty$\n    { key empty$\n        { cite$ #1 #3 substring$ }\n        'key\n      if$\n    }\n    { editor format.lab.names }\n  if$\n}\n\nFUNCTION {calc.short.authors}\n{ type$ \"book\" =\n  type$ \"inbook\" =\n  or\n    'author.editor.key.label\n    { type$ \"proceedings\" =\n        'editor.key.label\n        'author.key.label\n      if$\n    }\n  if$\n  'short.list :=\n}\n\nFUNCTION {calc.label}\n{ calc.short.authors\n  short.list\n  \"(\"\n  *\n  year duplicate$ empty$\n     { pop$ \"????\" }\n     'skip$\n  if$\n  *\n  'label :=\n}\n\nFUNCTION {sort.format.names}\n{ 's :=\n  #1 'nameptr :=\n  \"\"\n  s num.names$ 'numnames :=\n  numnames 'namesleft :=\n    { namesleft #0 > }\n    { s nameptr\n      \"{ll{ }}{  f{ }}{  jj{ }}\"\n      format.name$ 't :=\n      nameptr #1 >\n        {\n          \"   \"  *\n          namesleft #1 = t \"others\" = and\n            { \"zzzzz\" * }\n            { numnames #2 > nameptr #2 = and\n                { \"zz\" * year field.or.null * \"   \" * }\n                'skip$\n              if$\n              t sortify *\n            }\n          if$\n        }\n        { t sortify * }\n      if$\n      nameptr #1 + 'nameptr :=\n      namesleft #1 - 'namesleft :=\n    }\n  while$\n}\n\nFUNCTION {sort.format.title}\n{ 't :=\n  \"A \" #2\n    \"An \" #3\n      \"The \" #4 t chop.word\n    chop.word\n  chop.word\n  sortify\n  #1 global.max$ substring$\n}\nFUNCTION {author.sort}\n{ author empty$\n    { key empty$\n        { \"to sort, need author or key in \" cite$ * warning$\n          \"\"\n        }\n        { key sortify }\n      if$\n    }\n    { author sort.format.names }\n  if$\n}\nFUNCTION {author.editor.sort}\n{ author empty$\n    { editor empty$\n        { key empty$\n            { \"to sort, need author, editor, or key in \" cite$ * warning$\n              \"\"\n            }\n            { key sortify }\n          if$\n        }\n        { editor sort.format.names }\n      if$\n    }\n    { author sort.format.names }\n  if$\n}\nFUNCTION {editor.sort}\n{ editor empty$\n    { key empty$\n        { \"to sort, need editor or key in \" cite$ * warning$\n          \"\"\n        }\n        { key sortify }\n      if$\n    }\n    { editor sort.format.names }\n  if$\n}\nFUNCTION {presort}\n{ calc.label\n  label sortify\n  \"    \"\n  *\n  type$ \"book\" =\n  type$ \"inbook\" =\n  or\n    'author.editor.sort\n    { type$ \"proceedings\" =\n        'editor.sort\n        'author.sort\n      if$\n    }\n  if$\n  #1 entry.max$ substring$\n  'sort.label :=\n  sort.label\n  *\n  \"    \"\n  *\n  title field.or.null\n  sort.format.title\n  *\n  #1 entry.max$ substring$\n  'sort.key$ :=\n}\n\nITERATE {presort}\nSORT\nSTRINGS { last.label next.extra }\nINTEGERS { last.extra.num number.label }\nFUNCTION {initialize.extra.label.stuff}\n{ #0 int.to.chr$ 'last.label :=\n  \"\" 'next.extra :=\n  #0 'last.extra.num :=\n  #0 'number.label :=\n}\nFUNCTION {forward.pass}\n{ last.label label =\n    { last.extra.num #1 + 'last.extra.num :=\n      last.extra.num int.to.chr$ 'extra.label :=\n    }\n    { \"a\" chr.to.int$ 'last.extra.num :=\n      \"\" 'extra.label :=\n      label 'last.label :=\n    }\n  if$\n  number.label #1 + 'number.label :=\n}\nFUNCTION {reverse.pass}\n{ next.extra \"b\" =\n    { \"a\" 'extra.label := }\n    'skip$\n  if$\n  extra.label 'next.extra :=\n  extra.label\n  duplicate$ empty$\n    'skip$\n    { \"{\\natexlab{\" swap$ * \"}}\" * }\n  if$\n  'extra.label :=\n  label extra.label * 'label :=\n}\nEXECUTE {initialize.extra.label.stuff}\nITERATE {forward.pass}\nREVERSE {reverse.pass}\nFUNCTION {bib.sort.order}\n{ sort.label\n  \"    \"\n  *\n  year field.or.null sortify\n  *\n  \"    \"\n  *\n  title field.or.null\n  sort.format.title\n  *\n  #1 entry.max$ substring$\n  'sort.key$ :=\n}\nITERATE {bib.sort.order}\nSORT\nFUNCTION {begin.bib}\n{ preamble$ empty$\n    'skip$\n    { preamble$ write$ newline$ }\n  if$\n  \"\\begin{thebibliography}{\" number.label int.to.str$ * \"}\" *\n  write$ newline$\n  \"\\providecommand{\\natexlab}[1]{#1}\"\n  write$ newline$\n  \"\\providecommand{\\url}[1]{{#1}}\"\n  write$ newline$\n  \"\\providecommand{\\urlprefix}{URL }\"\n  write$ newline$\n  \"\\expandafter\\ifx\\csname urlstyle\\endcsname\\relax\"\n  write$ newline$\n  \"  \\providecommand{\\doi}[1]{DOI~\\discretionary{}{}{}#1}\\else\"\n  write$ newline$\n  \"  \\providecommand{\\doi}{DOI~\\discretionary{}{}{}\\begingroup \\urlstyle{rm}\\Url}\\fi\"\n  write$ newline$\n  \"\\providecommand{\\eprint}[2][]{\\url{#2}}\"\n  write$ newline$\n}\nEXECUTE {begin.bib}\nEXECUTE {init.state.consts}\nITERATE {call.type$}\nFUNCTION {end.bib}\n{ newline$\n  \"\\end{thebibliography}\" write$ newline$\n}\nEXECUTE {end.bib}\n%% End of customized bst file\n%%\n%% End of file `spbasic.bst'.\n\n"
  },
  {
    "path": "styles/spmpsci.bst",
    "content": "%%\n%% This is file `spmpsci.bst',\n%% generated with the docstrip utility.\n%%\n%% The original source files were:\n%%\n%% merlin.mbs  (with options: `vonx,nm-rvv,yr-par,xmth,jttl-rm,thtit-a,vol-bf,volp-com,pgsep-c,num-xser,ser-vol,ser-ed,jnm-x,btit-rm,bt-rm,doi,edparxc,au-col,in-col,fin-bare,pp,ed,abr,xedn,jabr,xand,url,url-blk,nfss,')\n%% ----------------------------------------\n%%********************************************************************************%%\n%%                                                                                %%\n%% For Springer mathematics, computer science, and physical sciences journals     %%\n%%   publications.                                                                %%\n%% Report bugs and improvements to: Joylene Vette-Guillaume or Frank Holzwarth    %%\n%%                                              Springer-Verlag 2004/10/15        %%\n%%                                                                                %%\n%%********************************************************************************%%\n%%\n%% Copyright 1994-2004 Patrick W Daly\n % ===============================================================\n % IMPORTANT NOTICE:\n % This bibliographic style (bst) file has been generated from one or\n % more master bibliographic style (mbs) files, listed above.\n %\n % This generated file can be redistributed and/or modified under the terms\n % of the LaTeX Project Public License Distributed from CTAN\n % archives in directory macros/latex/base/lppl.txt; either\n % version 1 of the License, or any later version.\n % ===============================================================\n % Name and version information of the main mbs file:\n % \\ProvidesFile{merlin.mbs}[2004/02/09 4.13 (PWD, AO, DPC)]\n %   For use with BibTeX version 0.99a or later\n %-------------------------------------------------------------------\n % This bibliography style file is intended for texts in ENGLISH\n % This is a numerical citation style, and as such is standard LaTeX.\n % It requires no extra package to interface to the main text.\n % The form of the \\bibitem entries is\n %   \\bibitem{key}...\n % Usage of \\cite is as follows:\n %   \\cite{key} ==>>          [#]\n %   \\cite[chap. 2]{key} ==>> [#, chap. 2]\n % where # is a number determined by the ordering in the reference list.\n % The order in the reference list is alphabetical by authors.\n %---------------------------------------------------------------------\n\nENTRY\n  { address\n    author\n    booktitle\n    chapter\n    doi\n    edition\n    editor\n    eid\n    howpublished\n    institution\n    journal\n    key\n    month\n    note\n    number\n    organization\n    pages\n    publisher\n    school\n    series\n    title\n    type\n    url\n    volume\n    year\n  }\n  {}\n  { label }\nINTEGERS { output.state before.all mid.sentence after.sentence after.block }\nFUNCTION {init.state.consts}\n{ #0 'before.all :=\n  #1 'mid.sentence :=\n  #2 'after.sentence :=\n  #3 'after.block :=\n}\nSTRINGS { s t}\nFUNCTION {output.nonnull}\n{ 's :=\n  output.state mid.sentence =\n    { \", \" * write$ }\n    { output.state after.block =\n        { add.period$ write$\n          newline$\n          \"\\newblock \" write$\n        }\n        { output.state before.all =\n            'write$\n            { add.period$ \" \" * write$ }\n          if$\n        }\n      if$\n      mid.sentence 'output.state :=\n    }\n  if$\n  s\n}\nFUNCTION {output}\n{ duplicate$ empty$\n    'pop$\n    'output.nonnull\n  if$\n}\nFUNCTION {output.check}\n{ 't :=\n  duplicate$ empty$\n    { pop$ \"empty \" t * \" in \" * cite$ * warning$ }\n    'output.nonnull\n  if$\n}\nFUNCTION {fin.entry}\n{ duplicate$ empty$\n    'pop$\n    'write$\n  if$\n  newline$\n}\n\nFUNCTION {new.block}\n{ output.state before.all =\n    'skip$\n    { after.block 'output.state := }\n  if$\n}\nFUNCTION {new.sentence}\n{ output.state after.block =\n    'skip$\n    { output.state before.all =\n        'skip$\n        { after.sentence 'output.state := }\n      if$\n    }\n  if$\n}\nFUNCTION {add.blank}\n{  \" \" * before.all 'output.state :=\n}\n\nFUNCTION {add.colon}\n{ duplicate$ empty$\n    'skip$\n    { \":\" * add.blank }\n  if$\n}\n\nFUNCTION {date.block}\n{\n  new.block\n}\n\nFUNCTION {not}\n{   { #0 }\n    { #1 }\n  if$\n}\nFUNCTION {and}\n{   'skip$\n    { pop$ #0 }\n  if$\n}\nFUNCTION {or}\n{   { pop$ #1 }\n    'skip$\n  if$\n}\nFUNCTION {new.block.checka}\n{ empty$\n    'skip$\n    'new.block\n  if$\n}\nFUNCTION {new.block.checkb}\n{ empty$\n  swap$ empty$\n  and\n    'skip$\n    'new.block\n  if$\n}\nFUNCTION {new.sentence.checka}\n{ empty$\n    'skip$\n    'new.sentence\n  if$\n}\nFUNCTION {new.sentence.checkb}\n{ empty$\n  swap$ empty$\n  and\n    'skip$\n    'new.sentence\n  if$\n}\nFUNCTION {field.or.null}\n{ duplicate$ empty$\n    { pop$ \"\" }\n    'skip$\n  if$\n}\nFUNCTION {emphasize}\n{ duplicate$ empty$\n    { pop$ \"\" }\n    { \"\\emph{\" swap$ * \"}\" * }\n  if$\n}\nFUNCTION {bolden}\n{ duplicate$ empty$\n    { pop$ \"\" }\n    { \"\\textbf{\" swap$ * \"}\" * }\n  if$\n}\nFUNCTION {tie.or.space.prefix}\n{ duplicate$ text.length$ #3 <\n    { \"~\" }\n    { \" \" }\n  if$\n  swap$\n}\n\nFUNCTION {capitalize}\n{ \"u\" change.case$ \"t\" change.case$ }\n\nFUNCTION {space.word}\n{ \" \" swap$ * \" \" * }\n % Here are the language-specific definitions for explicit words.\n % Each function has a name bbl.xxx where xxx is the English word.\n % The language selected here is ENGLISH\nFUNCTION {bbl.and}\n{ \"and\"}\n\nFUNCTION {bbl.etal}\n{ \"et~al.\" }\n\nFUNCTION {bbl.editors}\n{ \"eds.\" }\n\nFUNCTION {bbl.editor}\n{ \"ed.\" }\n\nFUNCTION {bbl.edby}\n{ \"edited by\" }\n\nFUNCTION {bbl.edition}\n{ \"edn.\" }\n\nFUNCTION {bbl.volume}\n{ \"vol.\" }\n\nFUNCTION {bbl.of}\n{ \"of\" }\n\nFUNCTION {bbl.number}\n{ \"no.\" }\n\nFUNCTION {bbl.nr}\n{ \"no.\" }\n\nFUNCTION {bbl.in}\n{ \"in\" }\n\nFUNCTION {bbl.pages}\n{ \"pp.\" }\n\nFUNCTION {bbl.page}\n{ \"p.\" }\n\nFUNCTION {bbl.chapter}\n{ \"chap.\" }\n\nFUNCTION {bbl.techrep}\n{ \"Tech. Rep.\" }\n\nFUNCTION {bbl.mthesis}\n{ \"Master's thesis\" }\n\nFUNCTION {bbl.phdthesis}\n{ \"Ph.D. thesis\" }\n\nMACRO {jan} {\"Jan.\"}\n\nMACRO {feb} {\"Feb.\"}\n\nMACRO {mar} {\"Mar.\"}\n\nMACRO {apr} {\"Apr.\"}\n\nMACRO {may} {\"May\"}\n\nMACRO {jun} {\"Jun.\"}\n\nMACRO {jul} {\"Jul.\"}\n\nMACRO {aug} {\"Aug.\"}\n\nMACRO {sep} {\"Sep.\"}\n\nMACRO {oct} {\"Oct.\"}\n\nMACRO {nov} {\"Nov.\"}\n\nMACRO {dec} {\"Dec.\"}\n\nMACRO {acmcs} {\"ACM Comput. Surv.\"}\n\nMACRO {acta} {\"Acta Inf.\"}\n\nMACRO {cacm} {\"Commun. ACM\"}\n\nMACRO {ibmjrd} {\"IBM J. Res. Dev.\"}\n\nMACRO {ibmsj} {\"IBM Syst.~J.\"}\n\nMACRO {ieeese} {\"IEEE Trans. Software Eng.\"}\n\nMACRO {ieeetc} {\"IEEE Trans. Comput.\"}\n\nMACRO {ieeetcad}\n {\"IEEE Trans. Comput. Aid. Des.\"}\n\nMACRO {ipl} {\"Inf. Process. Lett.\"}\n\nMACRO {jacm} {\"J.~ACM\"}\n\nMACRO {jcss} {\"J.~Comput. Syst. Sci.\"}\n\nMACRO {scp} {\"Sci. Comput. Program.\"}\n\nMACRO {sicomp} {\"SIAM J. Comput.\"}\n\nMACRO {tocs} {\"ACM Trans. Comput. Syst.\"}\n\nMACRO {tods} {\"ACM Trans. Database Syst.\"}\n\nMACRO {tog} {\"ACM Trans. Graphic.\"}\n\nMACRO {toms} {\"ACM Trans. Math. Software\"}\n\nMACRO {toois} {\"ACM Trans. Office Inf. Syst.\"}\n\nMACRO {toplas} {\"ACM Trans. Progr. Lang. Syst.\"}\n\nMACRO {tcs} {\"Theor. Comput. Sci.\"}\n\nFUNCTION {bibinfo.check}\n{ swap$\n  duplicate$ missing$\n    {\n      pop$ pop$\n      \"\"\n    }\n    { duplicate$ empty$\n        {\n          swap$ pop$\n        }\n        { swap$\n          pop$\n        }\n      if$\n    }\n  if$\n}\nFUNCTION {bibinfo.warn}\n{ swap$\n  duplicate$ missing$\n    {\n      swap$ \"missing \" swap$ * \" in \" * cite$ * warning$ pop$\n      \"\"\n    }\n    { duplicate$ empty$\n        {\n          swap$ \"empty \" swap$ * \" in \" * cite$ * warning$\n        }\n        { swap$\n          pop$\n        }\n      if$\n    }\n  if$\n}\nFUNCTION {format.url}\n{ url empty$\n    { \"\" }\n    { \"\\urlprefix\\url{\" url * \"}\" * }\n  if$\n}\n\nSTRINGS  { bibinfo}\nINTEGERS { nameptr namesleft numnames }\n\nFUNCTION {format.names}\n{ 'bibinfo :=\n  duplicate$ empty$ 'skip$ {\n  's :=\n  \"\" 't :=\n  #1 'nameptr :=\n  s num.names$ 'numnames :=\n  numnames 'namesleft :=\n    { namesleft #0 > }\n    { s nameptr\n      \"{vv~}{ll}{ jj}{, f{.}.}\"\n      format.name$\n      bibinfo bibinfo.check\n      't :=\n      nameptr #1 >\n        {\n          namesleft #1 >\n            { \", \" * t * }\n            {\n              \",\" *\n              s nameptr \"{ll}\" format.name$ duplicate$ \"others\" =\n                { 't := }\n                { pop$ }\n              if$\n              t \"others\" =\n                {\n                  \" \" * bbl.etal *\n                }\n                { \" \" * t * }\n              if$\n            }\n          if$\n        }\n        't\n      if$\n      nameptr #1 + 'nameptr :=\n      namesleft #1 - 'namesleft :=\n    }\n  while$\n  } if$\n}\nFUNCTION {format.names.ed}\n{\n  'bibinfo :=\n  duplicate$ empty$ 'skip$ {\n  's :=\n  \"\" 't :=\n  #1 'nameptr :=\n  s num.names$ 'numnames :=\n  numnames 'namesleft :=\n    { namesleft #0 > }\n    { s nameptr\n      \"{f{.}.~}{vv~}{ll}{ jj}\"\n      format.name$\n      bibinfo bibinfo.check\n      't :=\n      nameptr #1 >\n        {\n          namesleft #1 >\n            { \", \" * t * }\n            {\n              \",\" *\n              s nameptr \"{ll}\" format.name$ duplicate$ \"others\" =\n                { 't := }\n                { pop$ }\n              if$\n              t \"others\" =\n                {\n\n                  \" \" * bbl.etal *\n                }\n                { \" \" * t * }\n              if$\n            }\n          if$\n        }\n        't\n      if$\n      nameptr #1 + 'nameptr :=\n      namesleft #1 - 'namesleft :=\n    }\n  while$\n  } if$\n}\nFUNCTION {format.authors}\n{ author \"author\" format.names\n}\nFUNCTION {get.bbl.editor}\n{ editor num.names$ #1 > 'bbl.editors 'bbl.editor if$ }\n\nFUNCTION {format.editors}\n{ editor \"editor\" format.names duplicate$ empty$ 'skip$\n    {\n      \" \" *\n      get.bbl.editor\n   \"(\" swap$ * \")\" *\n      *\n    }\n  if$\n}\nFUNCTION {format.doi}\n{ doi \"doi\" bibinfo.check\n  duplicate$ empty$ 'skip$\n    {\n      new.block\n      \"\\doi{\" swap$ * \"}\" *\n    }\n  if$\n}\nFUNCTION {format.note}\n{\n note empty$\n    { \"\" }\n    { note #1 #1 substring$\n      duplicate$ \"{\" =\n        'skip$\n        { output.state mid.sentence =\n          { \"l\" }\n          { \"u\" }\n        if$\n        change.case$\n        }\n      if$\n      note #2 global.max$ substring$ * \"note\" bibinfo.check\n    }\n  if$\n}\n\nFUNCTION {format.title}\n{ title\n  duplicate$ empty$ 'skip$\n    { \"t\" change.case$ }\n  if$\n  \"title\" bibinfo.check\n}\nFUNCTION {output.bibitem}\n{ newline$\n  \"\\bibitem{\" write$\n  cite$ write$\n  \"}\" write$\n  newline$\n  \"\"\n  before.all 'output.state :=\n}\n\nFUNCTION {if.digit}\n{ duplicate$ \"0\" =\n  swap$ duplicate$ \"1\" =\n  swap$ duplicate$ \"2\" =\n  swap$ duplicate$ \"3\" =\n  swap$ duplicate$ \"4\" =\n  swap$ duplicate$ \"5\" =\n  swap$ duplicate$ \"6\" =\n  swap$ duplicate$ \"7\" =\n  swap$ duplicate$ \"8\" =\n  swap$ \"9\" = or or or or or or or or or\n}\nFUNCTION {n.separate}\n{ 't :=\n  \"\"\n  #0 'numnames :=\n  { t empty$ not }\n  { t #-1 #1 substring$ if.digit\n      { numnames #1 + 'numnames := }\n      { #0 'numnames := }\n    if$\n    t #-1 #1 substring$ swap$ *\n    t #-2 global.max$ substring$ 't :=\n    numnames #5 =\n      { duplicate$ #1 #2 substring$ swap$\n        #3 global.max$ substring$\n        \",\" swap$ * *\n      }\n      'skip$\n    if$\n  }\n  while$\n}\nFUNCTION {n.dashify}\n{\n  n.separate\n  't :=\n  \"\"\n    { t empty$ not }\n    { t #1 #1 substring$ \"-\" =\n        { t #1 #2 substring$ \"--\" = not\n            { \"--\" *\n              t #2 global.max$ substring$ 't :=\n            }\n            {   { t #1 #1 substring$ \"-\" = }\n                { \"-\" *\n                  t #2 global.max$ substring$ 't :=\n                }\n              while$\n            }\n          if$\n        }\n        { t #1 #1 substring$ *\n          t #2 global.max$ substring$ 't :=\n        }\n      if$\n    }\n  while$\n}\n\nFUNCTION {word.in}\n{ bbl.in capitalize\n  \":\" *\n  \" \" * }\n\nFUNCTION {format.date}\n{\n  \"\"\n  duplicate$ empty$\n  year  \"year\"  bibinfo.check duplicate$ empty$\n    { swap$ 'skip$\n        { \"there's a month but no year in \" cite$ * warning$ }\n      if$\n      *\n    }\n    { swap$ 'skip$\n        {\n          swap$\n          \" \" * swap$\n        }\n      if$\n      *\n    }\n  if$\n  duplicate$ empty$\n    'skip$\n    {\n      before.all 'output.state :=\n    \" (\" swap$ * \")\" *\n    }\n  if$\n}\nFUNCTION {format.btitle}\n{ title \"title\" bibinfo.check\n  duplicate$ empty$ 'skip$\n    {\n    }\n  if$\n}\nFUNCTION {either.or.check}\n{ empty$\n    'pop$\n    { \"can't use both \" swap$ * \" fields in \" * cite$ * warning$ }\n  if$\n}\nFUNCTION {format.bvolume}\n{ volume empty$\n    { \"\" }\n    { bbl.volume volume tie.or.space.prefix\n      \"volume\" bibinfo.check * *\n      series \"series\" bibinfo.check\n      duplicate$ empty$ 'pop$\n        { emphasize \", \" * swap$ * }\n      if$\n      \"volume and number\" number either.or.check\n    }\n  if$\n}\nFUNCTION {format.number.series}\n{ volume empty$\n    { number empty$\n        { series field.or.null }\n        { series empty$\n            { number \"number\" bibinfo.check }\n            { output.state mid.sentence =\n                { bbl.number }\n                { bbl.number capitalize }\n              if$\n              number tie.or.space.prefix \"number\" bibinfo.check * *\n              bbl.in space.word *\n              series \"series\" bibinfo.check *\n            }\n          if$\n        }\n      if$\n    }\n    { \"\" }\n  if$\n}\n\nFUNCTION {format.edition}\n{ edition duplicate$ empty$ 'skip$\n    {\n      output.state mid.sentence =\n        { \"l\" }\n        { \"t\" }\n      if$ change.case$\n      \"edition\" bibinfo.check\n      \" \" * bbl.edition *\n    }\n  if$\n}\nINTEGERS { multiresult }\nFUNCTION {multi.page.check}\n{ 't :=\n  #0 'multiresult :=\n    { multiresult not\n      t empty$ not\n      and\n    }\n    { t #1 #1 substring$\n      duplicate$ \"-\" =\n      swap$ duplicate$ \",\" =\n      swap$ \"+\" =\n      or or\n        { #1 'multiresult := }\n        { t #2 global.max$ substring$ 't := }\n      if$\n    }\n  while$\n  multiresult\n}\nFUNCTION {format.pages}\n{ pages duplicate$ empty$ 'skip$\n    { duplicate$ multi.page.check\n        {\n          bbl.pages swap$\n          n.dashify\n        }\n        {\n          bbl.page swap$\n        }\n      if$\n      tie.or.space.prefix\n      \"pages\" bibinfo.check\n      * *\n    }\n  if$\n}\nFUNCTION {format.journal.pages}\n{ pages duplicate$ empty$ 'pop$\n    { swap$ duplicate$ empty$\n        { pop$ pop$ format.pages }\n        {\n          \", \" *\n          swap$\n          n.dashify\n          \"pages\" bibinfo.check\n          *\n        }\n      if$\n    }\n  if$\n}\nFUNCTION {format.journal.eid}\n{ eid \"eid\" bibinfo.check\n  duplicate$ empty$ 'pop$\n    { swap$ duplicate$ empty$ 'skip$\n      {\n          \", \" *\n      }\n      if$\n      swap$ *\n    }\n  if$\n}\nFUNCTION {format.vol.num.pages}\n{ volume field.or.null\n  duplicate$ empty$ 'skip$\n    {\n      \"volume\" bibinfo.check\n    }\n  if$\n  bolden\n  number \"number\" bibinfo.check duplicate$ empty$ 'skip$\n    {\n      swap$ duplicate$ empty$\n        { \"there's a number but no volume in \" cite$ * warning$ }\n        'skip$\n      if$\n      swap$\n      \"(\" swap$ * \")\" *\n    }\n  if$ *\n  eid empty$\n    { format.journal.pages }\n    { format.journal.eid }\n  if$\n}\n\nFUNCTION {format.chapter.pages}\n{ chapter empty$\n    'format.pages\n    { type empty$\n        { bbl.chapter }\n        { type \"l\" change.case$\n          \"type\" bibinfo.check\n        }\n      if$\n      chapter tie.or.space.prefix\n      \"chapter\" bibinfo.check\n      * *\n      pages empty$\n        'skip$\n        { \", \" * format.pages * }\n      if$\n    }\n  if$\n}\n\nFUNCTION {format.booktitle}\n{\n  booktitle \"booktitle\" bibinfo.check\n}\nFUNCTION {format.in.ed.booktitle}\n{ format.booktitle duplicate$ empty$ 'skip$\n    {\n      format.bvolume duplicate$ empty$ 'pop$\n        { \", \" swap$ * * }\n      if$\n      editor \"editor\" format.names.ed duplicate$ empty$ 'pop$\n        {\n          \" \" *\n          get.bbl.editor\n          \"(\" swap$ * \") \" *\n          * swap$\n          * }\n      if$\n      word.in swap$ *\n    }\n  if$\n}\nFUNCTION {empty.misc.check}\n{ author empty$ title empty$ howpublished empty$\n  month empty$ year empty$ note empty$\n  and and and and and\n  key empty$ not and\n    { \"all relevant fields are empty in \" cite$ * warning$ }\n    'skip$\n  if$\n}\nFUNCTION {format.thesis.type}\n{ type duplicate$ empty$\n    'pop$\n    { swap$ pop$\n      \"t\" change.case$ \"type\" bibinfo.check\n    }\n  if$\n}\nFUNCTION {format.tr.number}\n{ number \"number\" bibinfo.check\n  type duplicate$ empty$\n    { pop$ bbl.techrep }\n    'skip$\n  if$\n  \"type\" bibinfo.check\n  swap$ duplicate$ empty$\n    { pop$ \"t\" change.case$ }\n    { tie.or.space.prefix * * }\n  if$\n}\nFUNCTION {format.article.crossref}\n{\n  key duplicate$ empty$\n    { pop$\n      journal duplicate$ empty$\n        { \"need key or journal for \" cite$ * \" to crossref \" * crossref * warning$ }\n        { \"journal\" bibinfo.check emphasize word.in swap$ * }\n      if$\n    }\n    { word.in swap$ * \" \" *}\n  if$\n  \" \\cite{\" * crossref * \"}\" *\n}\nFUNCTION {format.crossref.editor}\n{ editor #1 \"{vv~}{ll}\" format.name$\n  \"editor\" bibinfo.check\n  editor num.names$ duplicate$\n  #2 >\n    { pop$\n      \"editor\" bibinfo.check\n      \" \" * bbl.etal\n      *\n    }\n    { #2 <\n        'skip$\n        { editor #2 \"{ff }{vv }{ll}{ jj}\" format.name$ \"others\" =\n            {\n              \"editor\" bibinfo.check\n              \" \" * bbl.etal\n              *\n            }\n            {\n             bbl.and space.word\n              * editor #2 \"{vv~}{ll}\" format.name$\n              \"editor\" bibinfo.check\n              *\n            }\n          if$\n        }\n      if$\n    }\n  if$\n}\nFUNCTION {format.book.crossref}\n{ volume duplicate$ empty$\n    { \"empty volume in \" cite$ * \"'s crossref of \" * crossref * warning$\n      pop$ word.in\n    }\n    { bbl.volume\n      capitalize\n      swap$ tie.or.space.prefix \"volume\" bibinfo.check * * bbl.of space.word *\n    }\n  if$\n  editor empty$\n  editor field.or.null author field.or.null =\n  or\n    { key empty$\n        { series empty$\n            { \"need editor, key, or series for \" cite$ * \" to crossref \" *\n              crossref * warning$\n              \"\" *\n            }\n            { series emphasize * }\n          if$\n        }\n        { key * }\n      if$\n    }\n    { format.crossref.editor * }\n  if$\n  \" \\cite{\" * crossref * \"}\" *\n}\nFUNCTION {format.incoll.inproc.crossref}\n{\n  editor empty$\n  editor field.or.null author field.or.null =\n  or\n    { key empty$\n        { format.booktitle duplicate$ empty$\n            { \"need editor, key, or booktitle for \" cite$ * \" to crossref \" *\n              crossref * warning$\n            }\n            { word.in swap$ * }\n          if$\n        }\n        { word.in key * \" \" *}\n      if$\n    }\n    { word.in format.crossref.editor * \" \" *}\n  if$\n  \" \\cite{\" * crossref * \"}\" *\n}\nFUNCTION {format.org.or.pub}\n{ 't :=\n  \"\"\n  address empty$ t empty$ and\n    'skip$\n    {\n      t empty$\n        { address \"address\" bibinfo.check *\n        }\n        { t *\n          address empty$\n            'skip$\n            { \", \" * address \"address\" bibinfo.check * }\n          if$\n        }\n      if$\n    }\n  if$\n}\nFUNCTION {format.publisher.address}\n{ publisher \"publisher\" bibinfo.warn format.org.or.pub\n}\n\nFUNCTION {format.organization.address}\n{ organization \"organization\" bibinfo.check format.org.or.pub\n}\n\nFUNCTION {article}\n{ output.bibitem\n  format.authors \"author\" output.check\n  add.colon\n  new.block\n  format.title \"title\" output.check\n  new.block\n  crossref missing$\n    {\n      journal\n      \"journal\" bibinfo.check\n      \"journal\" output.check\n      add.blank\n      format.vol.num.pages output\n      format.date \"year\" output.check\n    }\n    { format.article.crossref output.nonnull\n      format.pages output\n    }\n  if$\n  format.doi output\n  new.block\n  format.url output\n  new.block\n  format.note output\n  fin.entry\n}\nFUNCTION {book}\n{ output.bibitem\n  author empty$\n    { format.editors \"author and editor\" output.check\n      add.colon\n    }\n    { format.authors output.nonnull\n      add.colon\n      crossref missing$\n        { \"author and editor\" editor either.or.check }\n        'skip$\n      if$\n    }\n  if$\n  new.block\n  format.btitle \"title\" output.check\n  crossref missing$\n    { format.bvolume output\n      format.edition output\n      new.block\n      format.number.series output\n      new.sentence\n      format.publisher.address output\n    }\n    {\n      new.block\n      format.book.crossref output.nonnull\n    }\n  if$\n  format.date \"year\" output.check\n  format.doi output\n  new.block\n  format.url output\n  new.block\n  format.note output\n  fin.entry\n}\nFUNCTION {booklet}\n{ output.bibitem\n  format.authors output\n  add.colon\n  new.block\n  format.title \"title\" output.check\n  new.block\n  howpublished \"howpublished\" bibinfo.check output\n  address \"address\" bibinfo.check output\n  format.date output\n  format.doi output\n  new.block\n  format.url output\n  new.block\n  format.note output\n  fin.entry\n}\n\nFUNCTION {inbook}\n{ output.bibitem\n  author empty$\n    { format.editors \"author and editor\" output.check\n      add.colon\n    }\n    { format.authors output.nonnull\n      add.colon\n      crossref missing$\n        { \"author and editor\" editor either.or.check }\n        'skip$\n      if$\n    }\n  if$\n  new.block\n  format.btitle \"title\" output.check\n  crossref missing$\n    {\n      format.bvolume output\n      format.edition output\n      format.chapter.pages \"chapter and pages\" output.check\n      new.block\n      format.number.series output\n      new.sentence\n      format.publisher.address output\n    }\n    {\n      format.chapter.pages \"chapter and pages\" output.check\n      new.block\n      format.book.crossref output.nonnull\n    }\n  if$\n  format.date \"year\" output.check\n  format.doi output\n  new.block\n  format.url output\n  new.block\n  format.note output\n  fin.entry\n}\n\nFUNCTION {incollection}\n{ output.bibitem\n  format.authors \"author\" output.check\n  add.colon\n  new.block\n  format.title \"title\" output.check\n  new.block\n  crossref missing$\n    { format.in.ed.booktitle \"booktitle\" output.check\n      format.number.series output\n      format.edition output\n      format.chapter.pages output\n      new.sentence\n      format.publisher.address output\n      format.date \"year\" output.check\n    }\n    { format.incoll.inproc.crossref output.nonnull\n      format.chapter.pages output\n    }\n  if$\n  format.doi output\n  new.block\n  format.url output\n  new.block\n  format.note output\n  fin.entry\n}\nFUNCTION {inproceedings}\n{ output.bibitem\n  format.authors \"author\" output.check\n  add.colon\n  new.block\n  format.title \"title\" output.check\n  new.block\n  crossref missing$\n    { format.in.ed.booktitle \"booktitle\" output.check\n      format.number.series output\n      format.pages output\n      new.sentence\n      publisher empty$\n        { format.organization.address output }\n        { organization \"organization\" bibinfo.check output\n          format.publisher.address output\n        }\n      if$\n      format.date \"year\" output.check\n    }\n    { format.incoll.inproc.crossref output.nonnull\n      format.pages output\n    }\n  if$\n  format.doi output\n  new.block\n  format.url output\n  new.block\n  format.note output\n  fin.entry\n}\nFUNCTION {conference} { inproceedings }\nFUNCTION {manual}\n{ output.bibitem\n  author empty$\n    { organization \"organization\" bibinfo.check\n      duplicate$ empty$ 'pop$\n        { output\n          address \"address\" bibinfo.check output\n        }\n      if$\n    }\n    { format.authors output.nonnull }\n  if$\n  add.colon\n  new.block\n  format.btitle \"title\" output.check\n  author empty$\n    { organization empty$\n        {\n          address new.block.checka\n          address \"address\" bibinfo.check output\n        }\n        'skip$\n      if$\n    }\n    {\n      organization address new.block.checkb\n      organization \"organization\" bibinfo.check output\n      address \"address\" bibinfo.check output\n    }\n  if$\n  format.edition output\n  format.date output\n  format.doi output\n  new.block\n  format.url output\n  new.block\n  format.note output\n  fin.entry\n}\n\nFUNCTION {mastersthesis}\n{ output.bibitem\n  format.authors \"author\" output.check\n  add.colon\n  new.block\n  format.title\n  \"title\" output.check\n  new.block\n  bbl.mthesis format.thesis.type output.nonnull\n  school \"school\" bibinfo.warn output\n  address \"address\" bibinfo.check output\n  format.date \"year\" output.check\n  format.doi output\n  new.block\n  format.url output\n  new.block\n  format.note output\n  fin.entry\n}\n\nFUNCTION {misc}\n{ output.bibitem\n  format.authors output\n  add.colon\n  title howpublished new.block.checkb\n  format.title output\n  howpublished new.block.checka\n  howpublished \"howpublished\" bibinfo.check output\n  format.date output\n  format.doi output\n  new.block\n  format.url output\n  new.block\n  format.note output\n  fin.entry\n  empty.misc.check\n}\nFUNCTION {phdthesis}\n{ output.bibitem\n  format.authors \"author\" output.check\n  add.colon\n  new.block\n  format.title\n  \"title\" output.check\n  new.block\n  bbl.phdthesis format.thesis.type output.nonnull\n  school \"school\" bibinfo.warn output\n  address \"address\" bibinfo.check output\n  format.date \"year\" output.check\n  format.doi output\n  new.block\n  format.url output\n  new.block\n  format.note output\n  fin.entry\n}\n\nFUNCTION {proceedings}\n{ output.bibitem\n  editor empty$\n    { organization \"organization\" bibinfo.check output\n    }\n    { format.editors output.nonnull }\n  if$\n  add.colon\n  new.block\n  format.btitle \"title\" output.check\n  format.bvolume output\n  format.number.series output\n  editor empty$\n    { publisher empty$\n        'skip$\n        {\n          new.sentence\n          format.publisher.address output\n        }\n      if$\n    }\n    { publisher empty$\n        {\n          new.sentence\n          format.organization.address output }\n        {\n          new.sentence\n          organization \"organization\" bibinfo.check output\n          format.publisher.address output\n        }\n      if$\n     }\n  if$\n      format.date \"year\" output.check\n  format.doi output\n  new.block\n  format.url output\n  new.block\n  format.note output\n  fin.entry\n}\n\nFUNCTION {techreport}\n{ output.bibitem\n  format.authors \"author\" output.check\n  add.colon\n  new.block\n  format.title\n  \"title\" output.check\n  new.block\n  format.tr.number output.nonnull\n  institution \"institution\" bibinfo.warn output\n  address \"address\" bibinfo.check output\n  format.date \"year\" output.check\n  format.doi output\n  new.block\n  format.url output\n  new.block\n  format.note output\n  fin.entry\n}\n\nFUNCTION {unpublished}\n{ output.bibitem\n  format.authors \"author\" output.check\n  add.colon\n  new.block\n  format.title \"title\" output.check\n  format.date output\n  format.doi output\n  new.block\n  format.url output\n  new.block\n  format.note \"note\" output.check\n  fin.entry\n}\n\nFUNCTION {default.type} { misc }\nREAD\nFUNCTION {sortify}\n{ purify$\n  \"l\" change.case$\n}\nINTEGERS { len }\nFUNCTION {chop.word}\n{ 's :=\n  'len :=\n  s #1 len substring$ =\n    { s len #1 + global.max$ substring$ }\n    's\n  if$\n}\nFUNCTION {sort.format.names}\n{ 's :=\n  #1 'nameptr :=\n  \"\"\n  s num.names$ 'numnames :=\n  numnames 'namesleft :=\n    { namesleft #0 > }\n    { s nameptr\n      \"{ll{ }}{  f{ }}{  jj{ }}\"\n      format.name$ 't :=\n      nameptr #1 >\n        {\n          \"   \"  *\n          namesleft #1 = t \"others\" = and\n            { \"zzzzz\" * }\n            { t sortify * }\n          if$\n        }\n        { t sortify * }\n      if$\n      nameptr #1 + 'nameptr :=\n      namesleft #1 - 'namesleft :=\n    }\n  while$\n}\n\nFUNCTION {sort.format.title}\n{ 't :=\n  \"A \" #2\n    \"An \" #3\n      \"The \" #4 t chop.word\n    chop.word\n  chop.word\n  sortify\n  #1 global.max$ substring$\n}\nFUNCTION {author.sort}\n{ author empty$\n    { key empty$\n        { \"to sort, need author or key in \" cite$ * warning$\n          \"\"\n        }\n        { key sortify }\n      if$\n    }\n    { author sort.format.names }\n  if$\n}\nFUNCTION {author.editor.sort}\n{ author empty$\n    { editor empty$\n        { key empty$\n            { \"to sort, need author, editor, or key in \" cite$ * warning$\n              \"\"\n            }\n            { key sortify }\n          if$\n        }\n        { editor sort.format.names }\n      if$\n    }\n    { author sort.format.names }\n  if$\n}\nFUNCTION {author.organization.sort}\n{ author empty$\n    { organization empty$\n        { key empty$\n            { \"to sort, need author, organization, or key in \" cite$ * warning$\n              \"\"\n            }\n            { key sortify }\n          if$\n        }\n        { \"The \" #4 organization chop.word sortify }\n      if$\n    }\n    { author sort.format.names }\n  if$\n}\nFUNCTION {editor.organization.sort}\n{ editor empty$\n    { organization empty$\n        { key empty$\n            { \"to sort, need editor, organization, or key in \" cite$ * warning$\n              \"\"\n            }\n            { key sortify }\n          if$\n        }\n        { \"The \" #4 organization chop.word sortify }\n      if$\n    }\n    { editor sort.format.names }\n  if$\n}\nFUNCTION {presort}\n{ type$ \"book\" =\n  type$ \"inbook\" =\n  or\n    'author.editor.sort\n    { type$ \"proceedings\" =\n        'editor.organization.sort\n        { type$ \"manual\" =\n            'author.organization.sort\n            'author.sort\n          if$\n        }\n      if$\n    }\n  if$\n  \"    \"\n  *\n  year field.or.null sortify\n  *\n  \"    \"\n  *\n  title field.or.null\n  sort.format.title\n  *\n  #1 entry.max$ substring$\n  'sort.key$ :=\n}\nITERATE {presort}\nSORT\nSTRINGS { longest.label }\nINTEGERS { number.label longest.label.width }\nFUNCTION {initialize.longest.label}\n{ \"\" 'longest.label :=\n  #1 'number.label :=\n  #0 'longest.label.width :=\n}\nFUNCTION {longest.label.pass}\n{ number.label int.to.str$ 'label :=\n  number.label #1 + 'number.label :=\n  label width$ longest.label.width >\n    { label 'longest.label :=\n      label width$ 'longest.label.width :=\n    }\n    'skip$\n  if$\n}\nEXECUTE {initialize.longest.label}\nITERATE {longest.label.pass}\nFUNCTION {begin.bib}\n{ preamble$ empty$\n    'skip$\n    { preamble$ write$ newline$ }\n  if$\n  \"\\begin{thebibliography}{\"  longest.label  * \"}\" *\n  write$ newline$\n  \"\\providecommand{\\url}[1]{{#1}}\"\n  write$ newline$\n  \"\\providecommand{\\urlprefix}{URL }\"\n  write$ newline$\n  \"\\expandafter\\ifx\\csname urlstyle\\endcsname\\relax\"\n  write$ newline$\n  \"  \\providecommand{\\doi}[1]{DOI~\\discretionary{}{}{}#1}\\else\"\n  write$ newline$\n  \"  \\providecommand{\\doi}{DOI~\\discretionary{}{}{}\\begingroup \\urlstyle{rm}\\Url}\\fi\"\n  write$ newline$\n}\nEXECUTE {begin.bib}\nEXECUTE {init.state.consts}\nITERATE {call.type$}\nFUNCTION {end.bib}\n{ newline$\n  \"\\end{thebibliography}\" write$ newline$\n}\nEXECUTE {end.bib}\n%% End of customized bst file\n%%\n%% End of file `spmpsci.bst'.\n\n"
  },
  {
    "path": "styles/spphys.bst",
    "content": "%%\n%% This is file `spphys.bst',\n%% generated with the docstrip utility.\n%%\n%% The original source files were:\n%%\n%% merlin.mbs  (with options: `seq-no,vonx,nm-init,ed-au,yr-par,xmth,jtit-x,jttl-rm,thtit-a,vol-bf,volp-com,jpg-1,pgsep-c,num-xser,ser-vol,ser-ed,jnm-x,pub-date,pre-pub,doi,edpar,edby,fin-bare,pp,ed,abr,ord,jabr,xand,url,url-blk,nfss,')\n%% ----------------------------------------\n%%********************************************************************************%%\n%%                                                                                %%\n%% For Springer physics publications. Based on the APS reference style.           %%\n%% Report bugs and improvements to: Joylene Vette-Guillaume or Frank Holzwarth    %%\n%%                                              Springer-Verlag 2004/10/15        %%\n%%                                                                                %%\n%%********************************************************************************%%\n%%\n%% Copyright 1994-2004 Patrick W Daly\n % ===============================================================\n % IMPORTANT NOTICE:\n % This bibliographic style (bst) file has been generated from one or\n % more master bibliographic style (mbs) files, listed above.\n %\n % This generated file can be redistributed and/or modified under the terms\n % of the LaTeX Project Public License Distributed from CTAN\n % archives in directory macros/latex/base/lppl.txt; either\n % version 1 of the License, or any later version.\n % ===============================================================\n % Name and version information of the main mbs file:\n % \\ProvidesFile{merlin.mbs}[2004/02/09 4.13 (PWD, AO, DPC)]\n %   For use with BibTeX version 0.99a or later\n %-------------------------------------------------------------------\n % This bibliography style file is intended for texts in ENGLISH\n % This is a numerical citation style, and as such is standard LaTeX.\n % It requires no extra package to interface to the main text.\n % The form of the \\bibitem entries is\n %   \\bibitem{key}...\n % Usage of \\cite is as follows:\n %   \\cite{key} ==>>          [#]\n %   \\cite[chap. 2]{key} ==>> [#, chap. 2]\n % where # is a number determined by the ordering in the reference list.\n % The order in the reference list is that by which the works were originally\n %   cited in the text, or that in the database.\n %---------------------------------------------------------------------\n\nENTRY\n  { address\n    author\n    booktitle\n    chapter\n    doi\n    edition\n    editor\n    eid\n    howpublished\n    institution\n    journal\n    key\n    month\n    note\n    number\n    organization\n    pages\n    publisher\n    school\n    series\n    title\n    type\n    url\n    volume\n    year\n  }\n  {}\n  { label }\nINTEGERS { output.state before.all mid.sentence after.sentence after.block }\nFUNCTION {init.state.consts}\n{ #0 'before.all :=\n  #1 'mid.sentence :=\n  #2 'after.sentence :=\n  #3 'after.block :=\n}\nSTRINGS { s t}\nFUNCTION {output.nonnull}\n{ 's :=\n  output.state mid.sentence =\n    { \", \" * write$ }\n    { output.state after.block =\n        { add.period$ write$\n          newline$\n          \"\\newblock \" write$\n        }\n        { output.state before.all =\n            'write$\n            { add.period$ \" \" * write$ }\n          if$\n        }\n      if$\n      mid.sentence 'output.state :=\n    }\n  if$\n  s\n}\nFUNCTION {output}\n{ duplicate$ empty$\n    'pop$\n    'output.nonnull\n  if$\n}\nFUNCTION {output.check}\n{ 't :=\n  duplicate$ empty$\n    { pop$ \"empty \" t * \" in \" * cite$ * warning$ }\n    'output.nonnull\n  if$\n}\nFUNCTION {fin.entry}\n{ duplicate$ empty$\n    'pop$\n    'write$\n  if$\n  newline$\n}\n\nFUNCTION {new.block}\n{ output.state before.all =\n    'skip$\n    { after.block 'output.state := }\n  if$\n}\nFUNCTION {new.sentence}\n{ output.state after.block =\n    'skip$\n    { output.state before.all =\n        'skip$\n        { after.sentence 'output.state := }\n      if$\n    }\n  if$\n}\nFUNCTION {add.blank}\n{  \" \" * before.all 'output.state :=\n}\n\nFUNCTION {add.comma}\n{ duplicate$ empty$\n    'skip$\n    { \",\" * add.blank }\n  if$\n}\n\nFUNCTION {date.block}\n{\n  new.block\n}\n\nFUNCTION {not}\n{   { #0 }\n    { #1 }\n  if$\n}\nFUNCTION {and}\n{   'skip$\n    { pop$ #0 }\n  if$\n}\nFUNCTION {or}\n{   { pop$ #1 }\n    'skip$\n  if$\n}\nFUNCTION {new.block.checka}\n{ empty$\n    'skip$\n    'new.block\n  if$\n}\nFUNCTION {new.block.checkb}\n{ empty$\n  swap$ empty$\n  and\n    'skip$\n    'new.block\n  if$\n}\nFUNCTION {new.sentence.checka}\n{ empty$\n    'skip$\n    'new.sentence\n  if$\n}\nFUNCTION {new.sentence.checkb}\n{ empty$\n  swap$ empty$\n  and\n    'skip$\n    'new.sentence\n  if$\n}\nFUNCTION {field.or.null}\n{ duplicate$ empty$\n    { pop$ \"\" }\n    'skip$\n  if$\n}\nFUNCTION {emphasize}\n{ duplicate$ empty$\n    { pop$ \"\" }\n    { \"\\emph{\" swap$ * \"}\" * }\n  if$\n}\nFUNCTION {bolden}\n{ duplicate$ empty$\n    { pop$ \"\" }\n    { \"\\textbf{\" swap$ * \"}\" * }\n  if$\n}\nFUNCTION {tie.or.space.prefix}\n{ duplicate$ text.length$ #3 <\n    { \"~\" }\n    { \" \" }\n  if$\n  swap$\n}\n\nFUNCTION {capitalize}\n{ \"u\" change.case$ \"t\" change.case$ }\n\nFUNCTION {space.word}\n{ \" \" swap$ * \" \" * }\n % Here are the language-specific definitions for explicit words.\n % Each function has a name bbl.xxx where xxx is the English word.\n % The language selected here is ENGLISH\nFUNCTION {bbl.and}\n{ \"and\"}\n\nFUNCTION {bbl.etal}\n{ \"et~al.\" }\n\nFUNCTION {bbl.editors}\n{ \"eds.\" }\n\nFUNCTION {bbl.editor}\n{ \"ed.\" }\n\nFUNCTION {bbl.edby}\n{ \"ed. by\" }\n\nFUNCTION {bbl.edition}\n{ \"edn.\" }\n\nFUNCTION {bbl.volume}\n{ \"vol.\" }\n\nFUNCTION {bbl.of}\n{ \"of\" }\n\nFUNCTION {bbl.number}\n{ \"no.\" }\n\nFUNCTION {bbl.nr}\n{ \"no.\" }\n\nFUNCTION {bbl.in}\n{ \"in\" }\n\nFUNCTION {bbl.pages}\n{ \"pp.\" }\n\nFUNCTION {bbl.page}\n{ \"p.\" }\n\nFUNCTION {bbl.chapter}\n{ \"chap.\" }\n\nFUNCTION {bbl.techrep}\n{ \"Tech. Rep.\" }\n\nFUNCTION {bbl.mthesis}\n{ \"Master's thesis\" }\n\nFUNCTION {bbl.phdthesis}\n{ \"Ph.D. thesis\" }\n\nFUNCTION {bbl.first}\n{ \"1st\" }\n\nFUNCTION {bbl.second}\n{ \"2nd\" }\n\nFUNCTION {bbl.third}\n{ \"3rd\" }\n\nFUNCTION {bbl.fourth}\n{ \"4th\" }\n\nFUNCTION {bbl.fifth}\n{ \"5th\" }\n\nFUNCTION {bbl.st}\n{ \"st\" }\n\nFUNCTION {bbl.nd}\n{ \"nd\" }\n\nFUNCTION {bbl.rd}\n{ \"rd\" }\n\nFUNCTION {bbl.th}\n{ \"th\" }\n\nMACRO {jan} {\"Jan.\"}\n\nMACRO {feb} {\"Feb.\"}\n\nMACRO {mar} {\"Mar.\"}\n\nMACRO {apr} {\"Apr.\"}\n\nMACRO {may} {\"May\"}\n\nMACRO {jun} {\"Jun.\"}\n\nMACRO {jul} {\"Jul.\"}\n\nMACRO {aug} {\"Aug.\"}\n\nMACRO {sep} {\"Sep.\"}\n\nMACRO {oct} {\"Oct.\"}\n\nMACRO {nov} {\"Nov.\"}\n\nMACRO {dec} {\"Dec.\"}\n\nFUNCTION {eng.ord}\n{ duplicate$ \"1\" swap$ *\n  #-2 #1 substring$ \"1\" =\n     { bbl.th * }\n     { duplicate$ #-1 #1 substring$\n       duplicate$ \"1\" =\n         { pop$ bbl.st * }\n         { duplicate$ \"2\" =\n             { pop$ bbl.nd * }\n             { \"3\" =\n                 { bbl.rd * }\n                 { bbl.th * }\n               if$\n             }\n           if$\n          }\n       if$\n     }\n   if$\n}\n\nMACRO {acmcs} {\"ACM Comput. Surv.\"}\n\nMACRO {acta} {\"Acta Inf.\"}\n\nMACRO {cacm} {\"Commun. ACM\"}\n\nMACRO {ibmjrd} {\"IBM J. Res. Dev.\"}\n\nMACRO {ibmsj} {\"IBM Syst.~J.\"}\n\nMACRO {ieeese} {\"IEEE Trans. Software Eng.\"}\n\nMACRO {ieeetc} {\"IEEE Trans. Comput.\"}\n\nMACRO {ieeetcad}\n {\"IEEE Trans. Comput. Aid. Des.\"}\n\nMACRO {ipl} {\"Inf. Process. Lett.\"}\n\nMACRO {jacm} {\"J.~ACM\"}\n\nMACRO {jcss} {\"J.~Comput. Syst. Sci.\"}\n\nMACRO {scp} {\"Sci. Comput. Program.\"}\n\nMACRO {sicomp} {\"SIAM J. Comput.\"}\n\nMACRO {tocs} {\"ACM Trans. Comput. Syst.\"}\n\nMACRO {tods} {\"ACM Trans. Database Syst.\"}\n\nMACRO {tog} {\"ACM Trans. Graphic.\"}\n\nMACRO {toms} {\"ACM Trans. Math. Software\"}\n\nMACRO {toois} {\"ACM Trans. Office Inf. Syst.\"}\n\nMACRO {toplas} {\"ACM Trans. Progr. Lang. Syst.\"}\n\nMACRO {tcs} {\"Theor. Comput. Sci.\"}\n\nFUNCTION {bibinfo.check}\n{ swap$\n  duplicate$ missing$\n    {\n      pop$ pop$\n      \"\"\n    }\n    { duplicate$ empty$\n        {\n          swap$ pop$\n        }\n        { swap$\n          pop$\n        }\n      if$\n    }\n  if$\n}\nFUNCTION {bibinfo.warn}\n{ swap$\n  duplicate$ missing$\n    {\n      swap$ \"missing \" swap$ * \" in \" * cite$ * warning$ pop$\n      \"\"\n    }\n    { duplicate$ empty$\n        {\n          swap$ \"empty \" swap$ * \" in \" * cite$ * warning$\n        }\n        { swap$\n          pop$\n        }\n      if$\n    }\n  if$\n}\nFUNCTION {format.url}\n{ url empty$\n    { \"\" }\n    { \"\\urlprefix\\url{\" url * \"}\" * }\n  if$\n}\n\nSTRINGS  { bibinfo}\nINTEGERS { nameptr namesleft numnames }\n\nFUNCTION {format.names}\n{ 'bibinfo :=\n  duplicate$ empty$ 'skip$ {\n  's :=\n  \"\" 't :=\n  #1 'nameptr :=\n  s num.names$ 'numnames :=\n  numnames 'namesleft :=\n    { namesleft #0 > }\n    { s nameptr\n      \"{f{.}.~}{vv~}{ll}{, jj}\"\n      format.name$\n      bibinfo bibinfo.check\n      't :=\n      nameptr #1 >\n        {\n          namesleft #1 >\n            { \", \" * t * }\n            {\n              \",\" *\n              s nameptr \"{ll}\" format.name$ duplicate$ \"others\" =\n                { 't := }\n                { pop$ }\n              if$\n              t \"others\" =\n                {\n                  \" \" * bbl.etal *\n                }\n                { \" \" * t * }\n              if$\n            }\n          if$\n        }\n        't\n      if$\n      nameptr #1 + 'nameptr :=\n      namesleft #1 - 'namesleft :=\n    }\n  while$\n  } if$\n}\nFUNCTION {format.names.ed}\n{\n  format.names\n}\nFUNCTION {format.authors}\n{ author \"author\" format.names\n}\nFUNCTION {get.bbl.editor}\n{ editor num.names$ #1 > 'bbl.editors 'bbl.editor if$ }\n\nFUNCTION {format.editors}\n{ editor \"editor\" format.names duplicate$ empty$ 'skip$\n    {\n      \" \" *\n      get.bbl.editor\n   \"(\" swap$ * \")\" *\n      *\n    }\n  if$\n}\nFUNCTION {format.doi}\n{ doi \"doi\" bibinfo.check\n  duplicate$ empty$ 'skip$\n    {\n      new.block\n      \"\\doi{\" swap$ * \"}\" *\n    }\n  if$\n}\nFUNCTION {format.note}\n{\n note empty$\n    { \"\" }\n    { note #1 #1 substring$\n      duplicate$ \"{\" =\n        'skip$\n        { output.state mid.sentence =\n          { \"l\" }\n          { \"u\" }\n        if$\n        change.case$\n        }\n      if$\n      note #2 global.max$ substring$ * \"note\" bibinfo.check\n    }\n  if$\n}\n\nFUNCTION {format.title}\n{ title\n  duplicate$ empty$ 'skip$\n    { \"t\" change.case$ }\n  if$\n  \"title\" bibinfo.check\n}\nFUNCTION {output.bibitem}\n{ newline$\n  \"\\bibitem{\" write$\n  cite$ write$\n  \"}\" write$\n  newline$\n  \"\"\n  before.all 'output.state :=\n}\n\nFUNCTION {if.digit}\n{ duplicate$ \"0\" =\n  swap$ duplicate$ \"1\" =\n  swap$ duplicate$ \"2\" =\n  swap$ duplicate$ \"3\" =\n  swap$ duplicate$ \"4\" =\n  swap$ duplicate$ \"5\" =\n  swap$ duplicate$ \"6\" =\n  swap$ duplicate$ \"7\" =\n  swap$ duplicate$ \"8\" =\n  swap$ \"9\" = or or or or or or or or or\n}\nFUNCTION {n.separate}\n{ 't :=\n  \"\"\n  #0 'numnames :=\n  { t empty$ not }\n  { t #-1 #1 substring$ if.digit\n      { numnames #1 + 'numnames := }\n      { #0 'numnames := }\n    if$\n    t #-1 #1 substring$ swap$ *\n    t #-2 global.max$ substring$ 't :=\n    numnames #5 =\n      { duplicate$ #1 #2 substring$ swap$\n        #3 global.max$ substring$\n        \",\" swap$ * *\n      }\n      'skip$\n    if$\n  }\n  while$\n}\nFUNCTION {n.dashify}\n{\n  n.separate\n  't :=\n  \"\"\n    { t empty$ not }\n    { t #1 #1 substring$ \"-\" =\n        { t #1 #2 substring$ \"--\" = not\n            { \"--\" *\n              t #2 global.max$ substring$ 't :=\n            }\n            {   { t #1 #1 substring$ \"-\" = }\n                { \"-\" *\n                  t #2 global.max$ substring$ 't :=\n                }\n              while$\n            }\n          if$\n        }\n        { t #1 #1 substring$ *\n          t #2 global.max$ substring$ 't :=\n        }\n      if$\n    }\n  while$\n}\n\nFUNCTION {word.in}\n{ bbl.in\n  \" \" * }\n\nFUNCTION {format.date}\n{\n  \"\"\n  duplicate$ empty$\n  year  \"year\"  bibinfo.check duplicate$ empty$\n    { swap$ 'skip$\n        { \"there's a month but no year in \" cite$ * warning$ }\n      if$\n      *\n    }\n    { swap$ 'skip$\n        {\n          swap$\n          \" \" * swap$\n        }\n      if$\n      *\n    }\n  if$\n  duplicate$ empty$\n    'skip$\n    {\n      before.all 'output.state :=\n    \" (\" swap$ * \")\" *\n    }\n  if$\n}\nFUNCTION {format.btitle}\n{ title \"title\" bibinfo.check\n  duplicate$ empty$ 'skip$\n    {\n      emphasize\n    }\n  if$\n}\nFUNCTION {either.or.check}\n{ empty$\n    'pop$\n    { \"can't use both \" swap$ * \" fields in \" * cite$ * warning$ }\n  if$\n}\nFUNCTION {format.bvolume}\n{ volume empty$\n    { \"\" }\n    { bbl.volume volume tie.or.space.prefix\n      \"volume\" bibinfo.check * *\n      series \"series\" bibinfo.check\n      duplicate$ empty$ 'pop$\n        { emphasize \", \" * swap$ * }\n      if$\n      \"volume and number\" number either.or.check\n    }\n  if$\n}\nFUNCTION {format.number.series}\n{ volume empty$\n    { number empty$\n        { series field.or.null }\n        { series empty$\n            { number \"number\" bibinfo.check }\n            { output.state mid.sentence =\n                { bbl.number }\n                { bbl.number capitalize }\n              if$\n              number tie.or.space.prefix \"number\" bibinfo.check * *\n              bbl.in space.word *\n              series \"series\" bibinfo.check *\n            }\n          if$\n        }\n      if$\n    }\n    { \"\" }\n  if$\n}\nFUNCTION {is.num}\n{ chr.to.int$\n  duplicate$ \"0\" chr.to.int$ < not\n  swap$ \"9\" chr.to.int$ > not and\n}\n\nFUNCTION {extract.num}\n{ duplicate$ 't :=\n  \"\" 's :=\n  { t empty$ not }\n  { t #1 #1 substring$\n    t #2 global.max$ substring$ 't :=\n    duplicate$ is.num\n      { s swap$ * 's := }\n      { pop$ \"\" 't := }\n    if$\n  }\n  while$\n  s empty$\n    'skip$\n    { pop$ s }\n  if$\n}\n\nFUNCTION {convert.edition}\n{ extract.num \"l\" change.case$ 's :=\n  s \"first\" = s \"1\" = or\n    { bbl.first 't := }\n    { s \"second\" = s \"2\" = or\n        { bbl.second 't := }\n        { s \"third\" = s \"3\" = or\n            { bbl.third 't := }\n            { s \"fourth\" = s \"4\" = or\n                { bbl.fourth 't := }\n                { s \"fifth\" = s \"5\" = or\n                    { bbl.fifth 't := }\n                    { s #1 #1 substring$ is.num\n                        { s eng.ord 't := }\n                        { edition 't := }\n                      if$\n                    }\n                  if$\n                }\n              if$\n            }\n          if$\n        }\n      if$\n    }\n  if$\n  t\n}\n\nFUNCTION {format.edition}\n{ edition duplicate$ empty$ 'skip$\n    {\n      convert.edition\n      output.state mid.sentence =\n        { \"l\" }\n        { \"t\" }\n      if$ change.case$\n      \"edition\" bibinfo.check\n      \" \" * bbl.edition *\n    }\n  if$\n}\nINTEGERS { multiresult }\nFUNCTION {multi.page.check}\n{ 't :=\n  #0 'multiresult :=\n    { multiresult not\n      t empty$ not\n      and\n    }\n    { t #1 #1 substring$\n      duplicate$ \"-\" =\n      swap$ duplicate$ \",\" =\n      swap$ \"+\" =\n      or or\n        { #1 'multiresult := }\n        { t #2 global.max$ substring$ 't := }\n      if$\n    }\n  while$\n  multiresult\n}\nFUNCTION {format.pages}\n{ pages duplicate$ empty$ 'skip$\n    { duplicate$ multi.page.check\n        {\n          bbl.pages swap$\n          n.dashify\n        }\n        {\n          bbl.page swap$\n        }\n      if$\n      tie.or.space.prefix\n      \"pages\" bibinfo.check\n      * *\n    }\n  if$\n}\nFUNCTION {first.page}\n{ 't :=\n  \"\"\n    {  t empty$ not t #1 #1 substring$ \"-\" = not and }\n    { t #1 #1 substring$ *\n      t #2 global.max$ substring$ 't :=\n    }\n  while$\n}\n\nFUNCTION {format.journal.pages}\n{ pages duplicate$ empty$ 'pop$\n    { swap$ duplicate$ empty$\n        { pop$ pop$ format.pages }\n        {\n          \", \" *\n          swap$\n          first.page\n          \"pages\" bibinfo.check\n          *\n        }\n      if$\n    }\n  if$\n}\nFUNCTION {format.journal.eid}\n{ eid \"eid\" bibinfo.check\n  duplicate$ empty$ 'pop$\n    { swap$ duplicate$ empty$ 'skip$\n      {\n          \", \" *\n      }\n      if$\n      swap$ *\n    }\n  if$\n}\nFUNCTION {format.vol.num.pages}\n{ volume field.or.null\n  duplicate$ empty$ 'skip$\n    {\n      \"volume\" bibinfo.check\n    }\n  if$\n  bolden\n  number \"number\" bibinfo.check duplicate$ empty$ 'skip$\n    {\n      swap$ duplicate$ empty$\n        { \"there's a number but no volume in \" cite$ * warning$ }\n        'skip$\n      if$\n      swap$\n      \"(\" swap$ * \")\" *\n    }\n  if$ *\n  eid empty$\n    { format.journal.pages }\n    { format.journal.eid }\n  if$\n}\n\nFUNCTION {format.chapter.pages}\n{ chapter empty$\n    'format.pages\n    { type empty$\n        { bbl.chapter }\n        { type \"l\" change.case$\n          \"type\" bibinfo.check\n        }\n      if$\n      chapter tie.or.space.prefix\n      \"chapter\" bibinfo.check\n      * *\n      pages empty$\n        'skip$\n        { \", \" * format.pages * }\n      if$\n    }\n  if$\n}\n\nFUNCTION {format.booktitle}\n{\n  booktitle \"booktitle\" bibinfo.check\n  emphasize\n}\nFUNCTION {format.in.ed.booktitle}\n{ format.booktitle duplicate$ empty$ 'skip$\n    {\n      format.bvolume duplicate$ empty$ 'pop$\n        { \", \" swap$ * * }\n      if$\n      editor \"editor\" format.names.ed duplicate$ empty$ 'pop$\n        {\n          bbl.edby\n          \" \" * swap$ *\n          swap$\n          \",\" *\n          \" \" * swap$\n          * }\n      if$\n      word.in swap$ *\n    }\n  if$\n}\nFUNCTION {empty.misc.check}\n{ author empty$ title empty$ howpublished empty$\n  month empty$ year empty$ note empty$\n  and and and and and\n    { \"all relevant fields are empty in \" cite$ * warning$ }\n    'skip$\n  if$\n}\nFUNCTION {format.thesis.type}\n{ type duplicate$ empty$\n    'pop$\n    { swap$ pop$\n      \"t\" change.case$ \"type\" bibinfo.check\n    }\n  if$\n}\nFUNCTION {format.tr.number}\n{ number \"number\" bibinfo.check\n  type duplicate$ empty$\n    { pop$ bbl.techrep }\n    'skip$\n  if$\n  \"type\" bibinfo.check\n  swap$ duplicate$ empty$\n    { pop$ \"t\" change.case$ }\n    { tie.or.space.prefix * * }\n  if$\n}\nFUNCTION {format.article.crossref}\n{\n  key duplicate$ empty$\n    { pop$\n      journal duplicate$ empty$\n        { \"need key or journal for \" cite$ * \" to crossref \" * crossref * warning$ }\n        { \"journal\" bibinfo.check emphasize word.in swap$ * }\n      if$\n    }\n    { word.in swap$ * \" \" *}\n  if$\n  \" \\cite{\" * crossref * \"}\" *\n}\nFUNCTION {format.crossref.editor}\n{ editor #1 \"{vv~}{ll}\" format.name$\n  \"editor\" bibinfo.check\n  editor num.names$ duplicate$\n  #2 >\n    { pop$\n      \"editor\" bibinfo.check\n      \" \" * bbl.etal\n      *\n    }\n    { #2 <\n        'skip$\n        { editor #2 \"{ff }{vv }{ll}{ jj}\" format.name$ \"others\" =\n            {\n              \"editor\" bibinfo.check\n              \" \" * bbl.etal\n              *\n            }\n            {\n             bbl.and space.word\n              * editor #2 \"{vv~}{ll}\" format.name$\n              \"editor\" bibinfo.check\n              *\n            }\n          if$\n        }\n      if$\n    }\n  if$\n}\nFUNCTION {format.book.crossref}\n{ volume duplicate$ empty$\n    { \"empty volume in \" cite$ * \"'s crossref of \" * crossref * warning$\n      pop$ word.in\n    }\n    { bbl.volume\n      capitalize\n      swap$ tie.or.space.prefix \"volume\" bibinfo.check * * bbl.of space.word *\n    }\n  if$\n  editor empty$\n  editor field.or.null author field.or.null =\n  or\n    { key empty$\n        { series empty$\n            { \"need editor, key, or series for \" cite$ * \" to crossref \" *\n              crossref * warning$\n              \"\" *\n            }\n            { series emphasize * }\n          if$\n        }\n        { key * }\n      if$\n    }\n    { format.crossref.editor * }\n  if$\n  \" \\cite{\" * crossref * \"}\" *\n}\nFUNCTION {format.incoll.inproc.crossref}\n{\n  editor empty$\n  editor field.or.null author field.or.null =\n  or\n    { key empty$\n        { format.booktitle duplicate$ empty$\n            { \"need editor, key, or booktitle for \" cite$ * \" to crossref \" *\n              crossref * warning$\n            }\n            { word.in swap$ * }\n          if$\n        }\n        { word.in key * \" \" *}\n      if$\n    }\n    { word.in format.crossref.editor * \" \" *}\n  if$\n  \" \\cite{\" * crossref * \"}\" *\n}\nFUNCTION {format.org.or.pub}\n{ 't :=\n  \"\"\n  year empty$\n    { \"empty year in \" cite$ * warning$ }\n    'skip$\n  if$\n  address empty$ t empty$ and\n  year empty$ and\n    'skip$\n    {\n      add.blank \"(\" *\n      t empty$\n        { address \"address\" bibinfo.check *\n        }\n        { t *\n          address empty$\n            'skip$\n            { \", \" * address \"address\" bibinfo.check * }\n          if$\n        }\n      if$\n      year empty$\n        'skip$\n        { t empty$ address empty$ and\n            'skip$\n            { \", \" * }\n          if$\n          year \"year\" bibinfo.check\n          *\n        }\n      if$\n      \")\" *\n    }\n  if$\n}\nFUNCTION {format.publisher.address}\n{ publisher \"publisher\" bibinfo.warn format.org.or.pub\n}\n\nFUNCTION {format.organization.address}\n{ organization \"organization\" bibinfo.check format.org.or.pub\n}\n\nFUNCTION {article}\n{ output.bibitem\n  format.authors \"author\" output.check\n  add.comma\n  crossref missing$\n    {\n      journal\n      \"journal\" bibinfo.check\n      \"journal\" output.check\n      add.blank\n      format.vol.num.pages output\n      format.date \"year\" output.check\n    }\n    { format.article.crossref output.nonnull\n      format.pages output\n    }\n  if$\n  format.doi output\n  new.block\n  format.url output\n  new.block\n  format.note output\n  fin.entry\n}\nFUNCTION {book}\n{ output.bibitem\n  author empty$\n    { format.editors \"author and editor\" output.check\n    }\n    { format.authors output.nonnull\n      crossref missing$\n        { \"author and editor\" editor either.or.check }\n        'skip$\n      if$\n    }\n  if$\n  add.comma\n  format.btitle \"title\" output.check\n  crossref missing$\n    { format.bvolume output\n      format.edition output\n      new.block\n      format.number.series output\n      new.sentence\n      format.publisher.address output\n    }\n    {\n      new.block\n      format.book.crossref output.nonnull\n      format.date \"year\" output.check\n    }\n  if$\n  format.doi output\n  new.block\n  format.url output\n  new.block\n  format.note output\n  fin.entry\n}\nFUNCTION {booklet}\n{ output.bibitem\n  format.authors output\n  add.comma\n  format.title \"title\" output.check\n  new.block\n  howpublished \"howpublished\" bibinfo.check output\n  address \"address\" bibinfo.check output\n  format.date output\n  format.doi output\n  new.block\n  format.url output\n  new.block\n  format.note output\n  fin.entry\n}\n\nFUNCTION {inbook}\n{ output.bibitem\n  author empty$\n    { format.editors \"author and editor\" output.check\n    }\n    { format.authors output.nonnull\n      crossref missing$\n        { \"author and editor\" editor either.or.check }\n        'skip$\n      if$\n    }\n  if$\n  add.comma\n  format.btitle \"title\" output.check\n  crossref missing$\n    {\n      format.publisher.address output\n      format.bvolume output\n      format.edition output\n      format.chapter.pages \"chapter and pages\" output.check\n      new.block\n      format.number.series output\n      new.sentence\n    }\n    {\n      format.chapter.pages \"chapter and pages\" output.check\n      new.block\n      format.book.crossref output.nonnull\n      format.date \"year\" output.check\n    }\n  if$\n  format.doi output\n  new.block\n  format.url output\n  new.block\n  format.note output\n  fin.entry\n}\n\nFUNCTION {incollection}\n{ output.bibitem\n  format.authors \"author\" output.check\n  add.comma\n  crossref missing$\n    { format.in.ed.booktitle \"booktitle\" output.check\n      format.edition output\n      format.number.series output\n      format.publisher.address output\n      format.chapter.pages output\n      new.sentence\n    }\n    { format.incoll.inproc.crossref output.nonnull\n      format.chapter.pages output\n    }\n  if$\n  format.doi output\n  new.block\n  format.url output\n  new.block\n  format.note output\n  fin.entry\n}\nFUNCTION {inproceedings}\n{ output.bibitem\n  format.authors \"author\" output.check\n  add.comma\n  crossref missing$\n    { format.in.ed.booktitle \"booktitle\" output.check\n      new.sentence\n      publisher empty$\n        { format.organization.address output }\n        { organization \"organization\" bibinfo.check output\n          format.publisher.address output\n        }\n      if$\n      format.bvolume output\n      format.number.series output\n      format.pages output\n    }\n    { format.incoll.inproc.crossref output.nonnull\n      format.pages output\n    }\n  if$\n  format.doi output\n  new.block\n  format.url output\n  new.block\n  format.note output\n  fin.entry\n}\nFUNCTION {conference} { inproceedings }\nFUNCTION {manual}\n{ output.bibitem\n  author empty$\n    { organization \"organization\" bibinfo.check\n      duplicate$ empty$ 'pop$\n        { output\n          address \"address\" bibinfo.check output\n        }\n      if$\n    }\n    { format.authors output.nonnull }\n  if$\n  add.comma\n  format.btitle \"title\" output.check\n  author empty$\n    { organization empty$\n        {\n          address new.block.checka\n          address \"address\" bibinfo.check output\n        }\n        'skip$\n      if$\n    }\n    {\n      organization address new.block.checkb\n      organization \"organization\" bibinfo.check output\n      address \"address\" bibinfo.check output\n    }\n  if$\n  format.edition output\n  format.date output\n  format.doi output\n  new.block\n  format.url output\n  new.block\n  format.note output\n  fin.entry\n}\n\nFUNCTION {mastersthesis}\n{ output.bibitem\n  format.authors \"author\" output.check\n  add.comma\n  format.title\n  \"title\" output.check\n  new.block\n  bbl.mthesis format.thesis.type output.nonnull\n  school \"school\" bibinfo.warn output\n  address \"address\" bibinfo.check output\n  format.date \"year\" output.check\n  format.doi output\n  new.block\n  format.url output\n  new.block\n  format.note output\n  fin.entry\n}\n\nFUNCTION {misc}\n{ output.bibitem\n  format.authors output\n  title howpublished new.block.checkb\n  format.title output\n  howpublished new.block.checka\n  howpublished \"howpublished\" bibinfo.check output\n  format.date output\n  format.doi output\n  new.block\n  format.url output\n  new.block\n  format.note output\n  fin.entry\n  empty.misc.check\n}\nFUNCTION {phdthesis}\n{ output.bibitem\n  format.authors \"author\" output.check\n  add.comma\n  format.title\n  \"title\" output.check\n  new.block\n  bbl.phdthesis format.thesis.type output.nonnull\n  school \"school\" bibinfo.warn output\n  address \"address\" bibinfo.check output\n  format.date \"year\" output.check\n  format.doi output\n  new.block\n  format.url output\n  new.block\n  format.note output\n  fin.entry\n}\n\nFUNCTION {proceedings}\n{ output.bibitem\n  editor empty$\n    { organization \"organization\" bibinfo.check output\n    }\n    { format.editors output.nonnull }\n  if$\n  new.block\n  format.btitle \"title\" output.check\n  format.bvolume output\n  format.number.series output\n  editor empty$\n    { publisher empty$\n        'skip$\n        {\n          new.sentence\n          format.publisher.address output\n        }\n      if$\n    }\n    { publisher empty$\n        {\n          new.sentence\n          format.organization.address output }\n        {\n          new.sentence\n          organization \"organization\" bibinfo.check output\n          format.publisher.address output\n        }\n      if$\n     }\n  if$\n  format.doi output\n  new.block\n  format.url output\n  new.block\n  format.note output\n  fin.entry\n}\n\nFUNCTION {techreport}\n{ output.bibitem\n  format.authors \"author\" output.check\n  add.comma\n  format.title\n  \"title\" output.check\n  new.block\n  format.tr.number output.nonnull\n  institution \"institution\" bibinfo.warn output\n  address \"address\" bibinfo.check output\n  format.date \"year\" output.check\n  format.doi output\n  new.block\n  format.url output\n  new.block\n  format.note output\n  fin.entry\n}\n\nFUNCTION {unpublished}\n{ output.bibitem\n  format.authors \"author\" output.check\n  add.comma\n  format.title \"title\" output.check\n  format.date output\n  format.doi output\n  new.block\n  format.url output\n  new.block\n  format.note \"note\" output.check\n  fin.entry\n}\n\nFUNCTION {default.type} { misc }\nREAD\nSTRINGS { longest.label }\nINTEGERS { number.label longest.label.width }\nFUNCTION {initialize.longest.label}\n{ \"\" 'longest.label :=\n  #1 'number.label :=\n  #0 'longest.label.width :=\n}\nFUNCTION {longest.label.pass}\n{ number.label int.to.str$ 'label :=\n  number.label #1 + 'number.label :=\n  label width$ longest.label.width >\n    { label 'longest.label :=\n      label width$ 'longest.label.width :=\n    }\n    'skip$\n  if$\n}\nEXECUTE {initialize.longest.label}\nITERATE {longest.label.pass}\nFUNCTION {begin.bib}\n{ preamble$ empty$\n    'skip$\n    { preamble$ write$ newline$ }\n  if$\n  \"\\begin{thebibliography}{\"  longest.label  * \"}\" *\n  write$ newline$\n  \"\\providecommand{\\url}[1]{{#1}}\"\n  write$ newline$\n  \"\\providecommand{\\urlprefix}{URL }\"\n  write$ newline$\n  \"\\expandafter\\ifx\\csname urlstyle\\endcsname\\relax\"\n  write$ newline$\n  \"  \\providecommand{\\doi}[1]{DOI \\discretionary{}{}{}#1}\\else\"\n  write$ newline$\n  \"  \\providecommand{\\doi}{DOI \\discretionary{}{}{}\\begingroup \\urlstyle{rm}\\Url}\\fi\"\n  write$ newline$\n}\nEXECUTE {begin.bib}\nEXECUTE {init.state.consts}\nITERATE {call.type$}\nFUNCTION {end.bib}\n{ newline$\n  \"\\end{thebibliography}\" write$ newline$\n}\nEXECUTE {end.bib}\n%% End of customized bst file\n%%\n%% End of file `spphys.bst'.\n\n"
  },
  {
    "path": "styles/svind.ist",
    "content": "headings_flag 1\nheading_prefix \"{\\\\bf \"\nheading_suffix \"}\\\\nopagebreak%\\n \\\\indexspace\\\\nopagebreak%\"\ndelim_0 \"\\\\idxquad \"\ndelim_1 \"\\\\idxquad \"\ndelim_2 \"\\\\idxquad \"\ndelim_n \",\\\\,\"\n"
  },
  {
    "path": "styles/svindd.ist",
    "content": "quote '+'\nheadings_flag 1\nheading_prefix \"{\\\\bf \"\nheading_suffix \"}\\\\nopagebreak%\\n \\\\indexspace\\\\nopagebreak%\"\ndelim_0 \"\\\\idxquad \"\ndelim_1 \"\\\\idxquad \"\ndelim_2 \"\\\\idxquad \"\ndelim_n \",\\\\,\"\n"
  },
  {
    "path": "styles/svmult.cls",
    "content": "% SVMULT DOCUMENT CLASS -- version 5.4 (25-Jun-07)\n% Springer Verlag global LaTeX2e support for multi authored books\n%%\n%%\n%% \\CharacterTable\n%%  {Upper-case    \\A\\B\\C\\D\\E\\F\\G\\H\\I\\J\\K\\L\\M\\N\\O\\P\\Q\\R\\S\\T\\U\\V\\W\\X\\Y\\Z\n%%   Lower-case    \\a\\b\\c\\d\\e\\f\\g\\h\\i\\j\\k\\l\\m\\n\\o\\p\\q\\r\\s\\t\\u\\v\\w\\x\\y\\z\n%%   Digits        \\0\\1\\2\\3\\4\\5\\6\\7\\8\\9\n%%   Exclamation   \\!     Double quote  \\\"     Hash (number) \\#\n%%   Dollar        \\$     Percent       \\%     Ampersand     \\&\n%%   Acute accent  \\'     Left paren    \\(     Right paren   \\)\n%%   Asterisk      \\*     Plus          \\+     Comma         \\,\n%%   Minus         \\-     Point         \\.     Solidus       \\/\n%%   Colon         \\:     Semicolon     \\;     Less than     \\<\n%%   Equals        \\=     Greater than  \\>     Question mark \\?\n%%   Commercial at \\@     Left bracket  \\[     Backslash     \\\\\n%%   Right bracket \\]     Circumflex    \\^     Underscore    \\_\n%%   Grave accent  \\`     Left brace    \\{     Vertical bar  \\|\n%%   Right brace   \\}     Tilde         \\~}\n%%\n\\NeedsTeXFormat{LaTeX2e}[1995/12/01]\n\\ProvidesClass{svmult}[2007/06/25 v5.4\n^^JSpringer Verlag global LaTeX document class for multi authored books]\n% Options\n% citations\n\\DeclareOption{natbib}{\\ExecuteOptions{oribibl}%\n\\AtEndOfClass{% Loading package 'NATBIB'\n\\RequirePackage{natbib}\n% Changing some parameters of NATBIB\n\\setlength{\\bibhang}{\\parindent}\n%\\setlength{\\bibsep}{0mm}\n\\let\\bibfont=\\small\n\\def\\@biblabel#1{#1.}\n\\newcommand{\\etal}{\\textit{et al}.}\n%\\bibpunct[,]{(}{)}{;}{a}{}{,}}}\n}}\n% Springer environment\n\\let\\if@spthms\\iftrue\n\\DeclareOption{nospthms}{\\let\\if@spthms\\iffalse}\n%\n\\let\\envankh\\@empty   % no anchor for \"theorems\"\n%\n\\let\\if@envcntreset\\iffalse % environment counter is not reset\n\\let\\if@envcntresetsect=\\iffalse % reset each section\n\\DeclareOption{envcountresetchap}{\\let\\if@envcntreset\\iftrue}\n\\DeclareOption{envcountresetsect}{\\let\\if@envcntreset\\iftrue\n\\let\\if@envcntresetsect=\\iftrue}\n%\n\\let\\if@envcntsame\\iffalse  % NOT all environments work like \"Theorem\",\n                            % each using its own counter\n\\DeclareOption{envcountsame}{\\let\\if@envcntsame\\iftrue}\n%\n\\let\\if@envcntshowhiercnt=\\iffalse % do not show hierarchy counter at all\n%\n% enhance theorem counter\n\\DeclareOption{envcountchap}{\\def\\envankh{chapter}% show \\thechapter along with theorem number\n\\let\\if@envcntshowhiercnt=\\iftrue}\n%\n\\DeclareOption{envcountsect}{\\def\\envankh{section}% show \\thesection along with theorem number\n\\let\\if@envcntshowhiercnt=\\iftrue\n\\ExecuteOptions{envcountresetsect}}\n% reset environment counters every new contribution by default\n\\ExecuteOptions{envcountresetchap}\n%\n% languages\n\\let\\switcht@@therlang\\relax\n\\let\\svlanginfo\\relax\n\\def\\ds@deutsch{\\def\\switcht@@therlang{\\switcht@deutsch}%\n\\gdef\\svlanginfo{\\typeout{Man spricht deutsch.}\\global\\let\\svlanginfo\\relax}}\n\\def\\ds@francais{\\def\\switcht@@therlang{\\switcht@francais}%\n\\gdef\\svlanginfo{\\typeout{On parle francais.}\\global\\let\\svlanginfo\\relax}}\n%\n\\AtBeginDocument{\\@ifundefined{url}{\\def\\url#1{#1}}{}%\n\\@ifpackageloaded{babel}{%\n\\@ifundefined{extrasamerican}{}{\\addto\\extrasamerican{\\switcht@albion}}%\n\\@ifundefined{extrasaustralian}{}{\\addto\\extrasaustralian{\\switcht@albion}}%\n\\@ifundefined{extrasbritish}{}{\\addto\\extrasbritish{\\switcht@albion}}%\n\\@ifundefined{extrascanadian}{}{\\addto\\extrascanadian{\\switcht@albion}}%\n\\@ifundefined{extrasenglish}{}{\\addto\\extrasenglish{\\switcht@albion}}%\n\\@ifundefined{extrasnewzealand}{}{\\addto\\extrasnewzealand{\\switcht@albion}}%\n\\@ifundefined{extrasUKenglish}{}{\\addto\\extrasUKenglish{\\switcht@albion}}%\n\\@ifundefined{extrasUSenglish}{}{\\addto\\extrasUSenglish{\\switcht@albion}}%\n\\@ifundefined{captionsfrench}{}{\\addto\\captionsfrench{\\switcht@francais}}%\n\\@ifundefined{extrasgerman}{}{\\addto\\extrasgerman{\\switcht@deutsch}}%\n\\@ifundefined{extrasngerman}{}{\\addto\\extrasngerman{\\switcht@deutsch}}%\n}{\\switcht@@therlang}%\n}\n% numbering style of floats, equations\n% \\newif\\if@numart   \\@numartfalse\n% \\DeclareOption{numart}{\\@numarttrue}\n% numbering of headings\n\\let\\if@chapnum=\\iftrue\n\\def\\nixchapnum{\\let\\if@chapnum\\iffalse}\n\\def\\numstyle{0}\n\\DeclareOption{nosecnum}{\\def\\numstyle{1}}%\n% \\DeclareOption{nochapnum}{\\def\\numstyle{2}}%\n% \\DeclareOption{nonum}{\\def\\numstyle{3}}%\n\\def\\set@numbering{\\ifcase\\numstyle %\\if@numart\\else\\num@book\\fi %default\n\\or % 1-case - no \\section-numbers\n\\setcounter{secnumdepth}{0}% \\if@numart\\else\\num@book\\fi\n% \\or % 2-case\n% % chapter not numbered, but \\sections are\n% \\def\\thesection{\\@arabic\\c@section}%\n% \\nixchapnum\n% \\or % 3-case\n% % neither chapter nor sections numbered + \"numart\"\n% \\nixchapnum\n% \\setcounter{secnumdepth}{0}%\n\\else\\fi}\n\\AtEndOfClass{\\set@numbering}\n% style for vectors\n\\DeclareOption{vecphys}{\\def\\vec@style{phys}}\n\\DeclareOption{vecarrow}{\\def\\vec@style{arrow}}\n% running heads\n\\let\\if@runhead\\iftrue\n\\DeclareOption{norunningheads}{\\let\\if@runhead\\iffalse}\n% referee option\n\\let\\if@referee\\iffalse\n\\def\\makereferee{\\def\\baselinestretch{2}\\selectfont\n\\newbox\\refereebox\n\\setbox\\refereebox=\\vbox to\\z@{\\vskip0.5cm%\n  \\hbox to\\textwidth{\\normalsize\\tt\\hrulefill\\lower0.5ex\n        \\hbox{\\kern5\\p@ referee's copy\\kern5\\p@}\\hrulefill}\\vss}%\n\\def\\@oddfoot{\\copy\\refereebox}\\let\\@evenfoot=\\@oddfoot}\n\\DeclareOption{referee}{\\let\\if@referee\\iftrue\n\\AtBeginDocument{\\makereferee\\small\\normalsize}}\n% modification of thebibliography\n\\let\\if@openbib\\iffalse\n\\DeclareOption{openbib}{\\let\\if@openbib\\iftrue}\n% LaTeX standard, sectionwise references\n\\DeclareOption{oribibl}{\\let\\oribibl=Y}\n\\DeclareOption{chaprefs}{\\let\\chpbibl=Y}\n%\n% footinfo option (provides an informatory line on every page)\n\\def\\SpringerMacroPackageNameA{svmult.cls}\n% \\thetime, \\thedate and \\timstamp are macros to include\n% time, date (or both) of the TeX run in the document\n\\def\\maketimestamp{\\count255=\\time\n\\divide\\count255 by 60\\relax\n\\edef\\thetime{\\the\\count255:}%\n\\multiply\\count255 by-60\\relax\n\\advance\\count255 by\\time\n\\edef\\thetime{\\thetime\\ifnum\\count255<10 0\\fi\\the\\count255}\n\\edef\\thedate{\\number\\day-\\ifcase\\month\\or Jan\\or Feb\\or Mar\\or\n             Apr\\or May\\or Jun\\or Jul\\or Aug\\or Sep\\or Oct\\or\n             Nov\\or Dec\\fi-\\number\\year}\n\\def\\timstamp{\\hbox to\\hsize{\\tt\\hfil\\thedate\\hfil\\thetime\\hfil}}}\n\\maketimestamp\n%\n% \\footinfo generates a info footline on every page containing\n% pagenumber, jobname, macroname, and timestamp\n\\DeclareOption{footinfo}{\\AtBeginDocument{\\maketimestamp\n   \\def\\ps@empty{\\let\\@mkboth\\@gobbletwo\n   \\let\\@oddhead\\@empty\\let\\@evenhead\\@empty}%\n   \\def\\@oddfoot{\\scriptsize\\tt Page:\\,\\thepage\\space\\hfil\n                 job:\\,\\jobname\\space\\hfil\n                 macro:\\,\\SpringerMacroPackageNameA\\space\\hfil\n                 date/time:\\,\\thedate/\\thetime}%\n   \\let\\@evenfoot=\\@oddfoot}}\n%\n% start new chapter on any page\n\\newif\\if@openright \\@openrighttrue\n\\DeclareOption{openany}{\\@openrightfalse}\n%\n% no size changing allowed\n\\DeclareOption{11pt}{\\OptionNotUsed}\n\\DeclareOption{12pt}{\\OptionNotUsed}\n% options for the article class\n\\def\\@rticle@options{10pt,twoside}\n% fleqn\n\\DeclareOption{fleqn}{\\def\\@rticle@options{10pt,twoside,fleqn}%\n\\AtEndOfClass{\\let\\leftlegendglue\\relax}%\n\\AtBeginDocument{\\mathindent\\parindent}}\n% hanging sectioning titles\n\\let\\if@sechang\\iftrue\n\\DeclareOption{nosechang}{\\let\\if@sechang\\iffalse}\n% hanging sectioning titles\n\\def\\ClassInfoNoLine#1#2{%\n   \\ClassInfo{#1}{#2\\@gobble}%\n}\n%\n\\DeclareOption{graybox}{%\n\\AtEndOfClass{% Loading color package\n\\RequirePackage{color}%\n% defining values of gray\n\\definecolor{shadecolor}{gray}{.85}%\n\\definecolor{tintedcolor}{gray}{.80}%\n\\RequirePackage{framed}%\n%\n\\newenvironment{tinted}{%\n  \\def\\FrameCommand{\\colorbox{tintedcolor}}%\n  \\MakeFramed {\\FrameRestore}}%\n {\\endMakeFramed}%\n%\n\\renewenvironment{svgraybox}%\n       {\\fboxsep=12pt\\relax\n        \\begin{shaded}%\n        \\list{}{\\leftmargin=12pt\\rightmargin=2\\leftmargin\\leftmargin=\\z@\\topsep=\\z@\\relax}%\n        \\expandafter\\item\\parindent=\\svparindent\n        \\hskip-\\listparindent}%\n       {\\endlist\\end{shaded}}%\n%\n\\renewenvironment{svtintedbox}%\n       {\\fboxsep=12pt\\relax\n        \\begin{tinted}%\n        \\list{}{\\leftmargin=12pt\\rightmargin=2\\leftmargin\\leftmargin=\\z@\\topsep=\\z@\\relax}%\n        \\expandafter\\item\\parindent=\\svparindent\n        \\relax}%\n       {\\endlist\\end{tinted}}%\n%\n}}\n%\n\\let\\SVMultOpt\\@empty\n\\DeclareOption*{\\InputIfFileExists{sv\\CurrentOption.clo}{%\n\\global\\let\\SVMultOpt\\CurrentOption}{%\n\\ClassWarning{Springer-SVMult}{Specified option or subpackage\n\"\\CurrentOption\" \\MessageBreak not found -\npassing it to article class \\MessageBreak\n-}\\PassOptionsToClass{\\CurrentOption}{article}%\n}}\n\\ProcessOptions\\relax\n\\ifx\\SVMultOpt\\@empty\\relax\n\\ClassInfoNoLine{Springer-SVMult}{extra/valid Springer sub-package\n\\MessageBreak not found in option list - using \"global\" style}{}\n\\fi\n\\LoadClass[\\@rticle@options]{article}\n\\raggedbottom\n\n% various sizes and settings for contributed works\n\n\\setlength{\\textwidth}{6.5in}\n\\setlength{\\topmargin}{0in}\n\\setlength{\\headheight}{0in}\n\\setlength{\\headsep}{5mm}\n%\\setlength{\\topsep}{0in}\n\\setlength{\\textheight}{9in}\n\\setlength{\\oddsidemargin}{0in}\n\\setlength{\\evensidemargin}{0in}\n\n\\newdimen\\svparindent\n\\setlength{\\svparindent}{12\\p@}\n\\parindent\\svparindent\n\n\\newdimen\\bibindent\n\\setlength\\bibindent{\\parindent}\n\n\\setlength{\\parskip}{\\z@ \\@plus \\p@}\n\\setlength{\\hfuzz}{2\\p@}\n\\setlength{\\arraycolsep}{1.5\\p@}\n\n\\frenchspacing\n\n\\tolerance=500\n\n\\predisplaypenalty=0\n\\clubpenalty=10000\n\\widowpenalty=10000\n\n\\setlength\\footnotesep{7.7\\p@}\n\n\\newdimen\\betweenumberspace          % dimension for space between\n\\betweenumberspace=5\\p@              % number and text of titles\n\\newdimen\\headlineindent             % dimension for space of\n\\headlineindent=2.5cc                % number and gap of running heads\n\n% fonts, sizes, and the like\n\\renewcommand\\normalsize{%\n   \\@setfontsize\\normalsize\\@xpt\\@xiipt\n   \\abovedisplayskip 10\\p@ % \\@plus2\\p@ \\@minus5\\p@\n   \\abovedisplayshortskip \\z@ % \\@plus3\\p@\n   \\belowdisplayshortskip 6\\p@ %\\@plus3\\p@ \\@minus3\\p@\n   \\belowdisplayskip \\abovedisplayskip\n   \\let\\@listi\\@listI}\n\\normalsize\n\\renewcommand\\small{%\n   \\@setfontsize\\small{8.5}{10}%\n   \\abovedisplayskip 8.5\\p@ % \\@plus3\\p@ \\@minus4\\p@\n   \\abovedisplayshortskip \\z@ %\\@plus2\\p@\n   \\belowdisplayshortskip 4\\p@ %\\@plus2\\p@ \\@minus2\\p@\n   \\def\\@listi{\\leftmargin\\leftmargini\n               \\parsep \\z@ \\@plus\\p@ \\@minus\\p@\n               \\topsep 6\\p@ \\@plus2\\p@ \\@minus4\\p@\n               \\itemsep\\z@}%\n   \\belowdisplayskip \\abovedisplayskip\n}\n%\n\\let\\footnotesize=\\small\n%\n\\renewcommand\\Large{\\@setfontsize\\large{14}{16}}\n\\newcommand\\LArge{\\@setfontsize\\Large{16}{18}}\n\\renewcommand\\LARGE{\\@setfontsize\\LARGE{18}{20}}\n%\n\\newenvironment{petit}{\\par\\addvspace{6\\p@}\\small}{\\par\\addvspace{6\\p@}}\n%\n\n% modification of automatic positioning of floating objects\n\\setlength\\@fptop{\\z@ }\n\\setlength\\@fpsep{12\\p@ }\n\\setlength\\@fpbot{\\z@ \\@plus 1fil }\n\\def\\textfraction{.01}\n\\def\\floatpagefraction{.8}\n\\setlength{\\intextsep}{20\\p@ \\@plus 2\\p@ \\@minus 2\\p@}\n\\setlength\\textfloatsep{24\\p@ \\@plus 2\\p@ \\@minus 4\\p@}\n\\setcounter{topnumber}{4}\n\\def\\topfraction{.9}\n\\setcounter{bottomnumber}{2}\n\\def\\bottomfraction{.7}\n\\setcounter{totalnumber}{6}\n%\n% size and style of headings\n\\newcommand{\\partnumsize}{\\LArge}\n\\newcommand{\\partnumstyle}{\\bfseries\\boldmath}\n\\newcommand{\\partsize}{\\LARGE}\n\\newcommand{\\partstyle}{\\bfseries\\boldmath}\n\\newcommand{\\chapnumsize}{\\Large}\n\\newcommand{\\chapnumstyle}{\\bfseries\\boldmath}\n\\newcommand{\\chapsize}{\\LArge}\n\\newcommand{\\chapstyle}{\\bfseries\\boldmath}\n\\newcommand{\\chapauthsize}{\\normalsize}\n\\newcommand{\\chapauthstyle}{\\bfseries\\boldmath}\n\\newcommand{\\mottosize}{\\small}\n\\newcommand{\\mottostyle}{\\itshape\\unboldmath\\raggedright}\n\\newcommand{\\secsize}{\\large}\n\\newcommand{\\secstyle}{\\bfseries\\boldmath}\n\\newcommand{\\subsecsize}{\\large}\n%\\newcommand{\\subsecstyle}{\\bfseries\\itshape\\boldmath}\n\\newcommand{\\subsecstyle}{\\bfseries\\boldmath}\n\\newcommand{\\subsubsecstyle}{\\bfseries\\boldmath}\n%\n\\def\\cleardoublepage{\\clearpage\\if@twoside \\ifodd\\c@page\\else\n    \\hbox{}\\newpage\\if@twocolumn\\hbox{}\\newpage\\fi\\fi\\fi}\n\n\\newcommand{\\clearemptydoublepage}{%\n        \\clearpage{\\pagestyle{empty}\\cleardoublepage}}\n\\newcommand{\\startnewpage}{\\if@openright\\clearemptydoublepage\\else\\clearpage\\fi}\n\n% MiniTOC\n% one outputstream for all minitocs\n\\newwrite\\minitoc\n\\let\\MiniTOC=N % switch for MT processing in .aux files\n\\newcounter{minitocdepth}\n\\setcounter{minitocdepth}{0}\n\n% stolen from LaTeX.ltx - read miniTOC and redirect output stream\n\\long\\def \\protected@immwrite#1#2#3{%\n      \\begingroup\n       \\let\\thepage\\relax\n       #2%\n       \\let\\protect\\@unexpandable@protect\n       \\edef\\reserved@a{\\immediate\\write#1{#3}}%\n       \\reserved@a\n      \\endgroup\n      \\if@nobreak\\ifvmode\\nobreak\\fi\\fi}\n%\n\\newcommand{\\@mtstarttoc}[1]\n{\\begingroup\n \\makeatletter\n \\immediate\\write\\@auxout{\\string\\immediate\\string\\closeout\\string\\minitoc}%\n \\typeout{input jobname.#1}%\n\\small\n \\@input{\\jobname.#1}%\n \\protected@immwrite\\@auxout\n   {\\let\\label\\@gobble \\let\\index\\@gobble\n    \\let\\glossary\\@gobble}%\n   {\\immediate\\openout\\minitoc \\jobname.#1\\relax}\n \\global\\@nobreakfalse\\endgroup}\n%\n\\newcommand{\\@mtstarttocquiet}[1]\n{\\begingroup\n \\makeatletter\n \\protected@write\\@auxout\n   {\\let\\label\\@gobble \\let\\index\\@gobble\n    \\let\\glossary\\@gobble}%\n   {\\immediate\\openout\\minitoc \\jobname.#1\\relax}\n \\global\\@nobreakfalse\\endgroup}\n%\n\\newcommand{\\mtaddtocont}[1]\n{\\protected@write \\@auxout\n  {\\let\\label\\@gobble \\let\\index\\@gobble\n   \\let\\glossary\\@gobble}%\n  {\\string\\@mtwritefile{#1}}}\n%\n\\newcommand{\\@mtwritefile}[1]{\\if Y\\MiniTOC\n\\@temptokena{#1} \\immediate\\write\\minitoc{\\the\\@temptokena}\\fi}\n\n\\AtEndDocument{\\immediate\\write\\@auxout{\\string\\immediate\\string\\closeout\\string\\minitoc}}\n\n\\newcommand{\\dominitoc}{% switch \\let\\MiniTOC=Y\n    \\protected@immwrite\\@auxout{}{\\let\\MiniTOC=Y}%\n    \\ifnum \\c@minitocdepth<1\n        \\@mtstarttocquiet{t\\thecontribution}\\relax\n    \\else\n        \\@mtstarttoc{t\\thecontribution}\\par\\addvspace\\bigskipamount\n    \\fi}\n\n% redefinition of \\part\n\\renewcommand\\part{\\clearemptydoublepage\n         \\thispagestyle{empty}\n         \\if@twocolumn\n            \\onecolumn\n            \\@tempswatrue\n         \\else\n            \\@tempswafalse\n         \\fi\n         \\@ifundefined{thispagecropped}{}{\\thispagecropped}\n         \\secdef\\@part\\@spart}\n\n\\def\\@part[#1]#2{\\ifnum \\c@secnumdepth >-2\\relax\n        \\refstepcounter{part}\n        \\addcontentsline{toc}{part}{\\partname\\\n        \\thepart\\thechapterend\\hspace{\\betweenumberspace}%\n        #1}\\else\n        \\addcontentsline{toc}{part}{#1}\\fi\n   \\markboth{}{}\n   {\\raggedleft\n    \\hyphenpenalty \\@M\n    \\interlinepenalty\\@M\n    \\ifnum \\c@secnumdepth >-2\\relax\n      \\normalfont\\partnumsize\\partnumstyle %\\vrule height 34pt width 0pt depth 0pt%\n     \\partname\\ \\thepart %\\llap{\\smash{\\lower 5pt\\hbox to\\textwidth{\\hrulefill}}}\n    \\par\n    \\vskip 2\\p@ \\fi\n    \\partsize\\partstyle #2\\par}\\@endpart}\n%\n% \\@endpart finishes the part page\n%\n\\def\\@endpart{\\vfil\\newpage\n   \\if@twoside\n       \\hbox{}\n       \\thispagestyle{empty}\n       \\newpage\n   \\fi\n   \\if@tempswa\n     \\twocolumn\n   \\fi}\n%\n\\def\\@spart#1{{\\raggedleft\n   \\normalfont\\partsize\\partstyle\n   #1\\par}\\@endpart}\n%\n\\newenvironment{partbacktext}{\\def\\@endpart{\\vfil\\newpage}}\n{\\thispagestyle{empty} \\newpage}\n%\n% (re)define sectioning\n\\setcounter{secnumdepth}{3}\n\n\\def\\seccounterend{}\n\\def\\seccountergap{\\hskip\\betweenumberspace}\n\\def\\@seccntformat#1{\\csname the#1\\endcsname\\seccounterend\\seccountergap\\ignorespaces}\n%\n\\let\\firstmark=\\botmark\n%\n\\@ifundefined{thechapterend}{\\def\\thechapterend{}}{}\n%\n\\if@sechang\n   \\def\\sec@hangfrom#1{\\setbox\\@tempboxa\\hbox{#1}%\n         \\hangindent\\wd\\@tempboxa\\noindent\\box\\@tempboxa}\n\\else\n   \\def\\sec@hangfrom#1{\\setbox\\@tempboxa\\hbox{#1}%\n         \\hangindent\\z@\\noindent\\box\\@tempboxa}\n\\fi\n\n\\def\\chap@hangfrom#1{\\if!#1!\\else\n\\@chapapp\\ #1\\vskip2pt\\fi}\n\\def\\schap@hangfrom{\\chap@hangfrom{}}\n\n\\newcounter{chapter}\n\n\\newif\\if@mainmatter \\@mainmattertrue\n\\newcommand\\frontmatter{\\startnewpage\n            \\@mainmatterfalse\\pagenumbering{roman}\n            \\setcounter{page}{1}}\n%\n\\newcommand\\mainmatter{\\clearemptydoublepage\n            \\@mainmattertrue\n            \\markboth{}{}\n            \\pagenumbering{arabic}}\n%\n\\newcommand\\backmatter{%\n\\setcounter{minitocdepth}{0}%\n\\pagestyle{headings}%\n\\clearemptydoublepage %\\@mainmatterfalse\n\\let\\appendix=\\bppendix\n\\def\\bibsection{\\chapter*{\\refname}\\@mkboth{\\refname}{\\refname}%\n     \\addcontentsline{toc}{chapter}{\\refname}%\n     \\csname biblst@rthook\\endcsname\\par}%\n}\n\n\\renewenvironment{titlepage}\n    {%\n      \\cleardoublepage\n      \\if@twocolumn\n        \\@restonecoltrue\\onecolumn\n      \\else\n        \\@restonecolfalse\\newpage\n      \\fi\n      \\thispagestyle{empty}%\n      %\\addtocounter{page}\\m@ne\n  \\def\\and{\\unskip, }\n  \\parindent=\\z@\n  \\pretolerance=10000\n  \\rightskip=0pt plus 1fil\n  \\large                    % default size for titlepage\n  \\vspace*{2em}             % Vertical space above title.\n }{{\\LARGE                   % each author set in \\LARGE\n   \\lineskip .5em\n   \\@author\n   \\par}%\n  \\vskip 2cm                % Vertical space after author.\n  {\\Huge\\bfseries\\@title \\par}% Title set in \\Huge size and bold face\n  \\vskip 1cm                % Vertical space after title.\n  \\if!\\@subtitle!\\else\n   {\\LARGE\\ignorespaces\\@subtitle \\par}\n   \\vskip 1cm               % Vertical space after subtitle.\n  \\fi\n  \\if!\\@date!\\else\n    \\@date\n    \\par\n    \\vskip 1.5em            % Vertical space after date.\n  \\fi\n \\vfill\n% {\\Large\\bfseries Springer\\par}\n%\\vskip 3pt\n%\\itshape\n%  Berlin\\enspace Heidelberg\\enspace New\\kern0.1em York\\\\\n%  Hong\\kern0.2em Kong\\enspace London\\\\\n%  Milan\\enspace Paris\\enspace Tokyo\\par\n     \\if@restonecol\\twocolumn \\else \\newpage \\fi\n     \\if@twoside\\else\n        \\setcounter{page}\\@ne\n     \\fi\n \\clearheadinfo\n}\n\n\\def\\@chapapp{\\chaptername}\n\n\\newdimen\\mottowidth\n\\newcommand\\motto[2][77mm]{%\n\\setlength{\\mottowidth}{#1}%\n\\gdef\\m@ttotext{#2}}\n%\n\\newcommand{\\processmotto}{\\@ifundefined{m@ttotext}{}{%\n    \\setbox0=\\hbox{\\vbox{\\hyphenpenalty=50\n    \\begin{flushright}\n    \\begin{minipage}{\\mottowidth}\n       \\vrule\\@width\\z@\\@height21\\p@\\@depth\\z@\n       \\normalfont\\mottosize\\mottostyle\\m@ttotext\n    \\end{minipage}\n    \\end{flushright}}}%\n    \\@tempdima=\\pagetotal\n    \\advance\\@tempdima by\\ht0\n    \\ifdim\\@tempdima<157\\p@\n       \\multiply\\@tempdima by-1\n       \\advance\\@tempdima by157\\p@\n       \\vskip\\@tempdima\n    \\fi\n    \\box0\\par\n    \\global\\let\\m@ttotext=\\undefined}}\n\n\\newcommand{\\chapsubtitle}[1]{%\n\\gdef\\ch@psubtitle{#1}}\n%\n\\newcommand{\\processchapsubtit}{\\@ifundefined{ch@psubtitle}{}{%\n    {\\normalfont\\chapnumsize\\chapnumstyle\n    \\vskip 14\\p@\n    \\ch@psubtitle\n    \\par}\n    \\global\\let\\ch@psubtitle=\\undefined}}\n\n\\newcommand{\\chapauthor}[1]{%\n\\gdef\\ch@pauthor{#1}}\n%\n\\newcommand{\\processchapauthor}{\\@ifundefined{ch@pauthor}{}{%\n    {\\normalfont\\chapauthsize\\chapauthstyle\n    \\vskip 20\\p@\n    \\ch@pauthor\n    \\par}\n    \\global\\let\\ch@pauthor=\\undefined}}\n\n\\newcommand\\chapter{\\startnewpage\n                    \\@ifundefined{thispagecropped}{}{\\thispagecropped}\n                    \\thispagestyle{bchap}%\n                    \\if@chapnum\\else\n                       \\begingroup\n                         \\let\\@elt\\@stpelt\n                         \\csname cl@chapter\\endcsname\n                       \\endgroup\n                    \\fi\n                    \\global\\@topnum\\z@\n                    \\@afterindentfalse\n                    \\secdef\\@chapter\\@schapter}\n\n\\def\\@chapter[#1]#2{\\if@chapnum  % war mal \\ifnum \\c@secnumdepth >\\m@ne\n                       \\refstepcounter{chapter}%\n                       \\if@mainmatter\n                         \\typeout{\\@chapapp\\space\\thechapter.}%\n                         \\addcontentsline{toc}{chapter}{\\protect\n                                  \\numberline{\\thechapter\\thechapterend}#1}%\n                       \\else\n                         \\addcontentsline{toc}{chapter}{#1}%\n                       \\fi\n                    \\else\n                      \\addcontentsline{toc}{chapter}{#1}%\n                    \\fi\n                    \\chaptermark{#1}%\n                    \\addtocontents{lof}{\\protect\\addvspace{10\\p@}}%\n                    \\addtocontents{lot}{\\protect\\addvspace{10\\p@}}%\n                    \\if@twocolumn\n                      \\@topnewpage[\\@makechapterhead{#2}]%\n                    \\else\n                      \\@makechapterhead{#2}%\n                      \\@afterheading\n                    \\fi}\n\n\\def\\@schapter#1{\\if@twocolumn\n                   \\@topnewpage[\\@makeschapterhead{#1}]%\n                 \\else\n                   \\@makeschapterhead{#1}%\n                   \\@afterheading\n                 \\fi}\n\n%%changes position and layout of numbered chapter headings\n\\def\\@makechapterhead#1{{\\parindent\\z@\\raggedright\\normalfont\n  \\hyphenpenalty \\@M\n  \\interlinepenalty\\@M\n  \\if@chapnum\n     \\chapnumsize\\chapnumstyle\n     \\@chapapp\\ \\thechapter\\thechapterend\\par\n     \\vskip 2\\p@\n  \\fi\n  \\chapsize\\chapstyle\n  \\ignorespaces#1\\par\\nobreak\n  \\processchapsubtit\n  \\processchapauthor\n  \\processmotto\n  \\ifdim\\pagetotal>67\\p@\n     \\vskip 11\\p@\n  \\else\n     \\@tempdima=67\\p@\\advance\\@tempdima by-\\pagetotal\n     \\vskip\\@tempdima\n  \\fi}}\n\n%%changes position and layout of unnumbered chapter headings\n\\def\\@makeschapterhead#1{{\\parindent \\z@ \\raggedright\\normalfont\n  \\hyphenpenalty \\@M\n  \\interlinepenalty\\@M\n  \\chapsize\\chapstyle\n  \\ignorespaces#1\\par\\nobreak\n  \\processmotto\n  \\ifdim\\pagetotal>67\\p@\n     \\vskip 11\\p@\n  \\else\n     \\@tempdima=67\\p@\\advance\\@tempdima by-\\pagetotal\n     \\vskip\\@tempdima\n  \\fi}}\n%\n% dedication environment\n\\newenvironment{dedication}\n{\\clearemptydoublepage\n\\thispagestyle{empty}\n\\vspace*{13\\baselineskip}\n\\large\\itshape\n\\let\\\\\\@centercr\\@rightskip\\@flushglue \\rightskip\\@rightskip\n\\leftskip4cm\\parindent\\z@\\relax\n\\everypar{\\parindent=\\svparindent\\let\\everypar\\empty}}{\\clearpage}\n%\n% predefined unnumbered headings\n\\newcommand{\\preface}[1][\\prefacename]{\\chapter*{#1}\\markboth{#1}{#1}}\n\\newcommand{\\foreword}[1][\\forewordname]{\\chapter*{#1}\\markboth{#1}{#1}}\n\\newcommand{\\contributors}[1][\\contriblistname]{\\chapter*{#1}\\markboth{#1}{#1}}\n\\newcommand{\\extrachap}[1]{\\chapter*{#1}\\markboth{#1}{#1}}\n% same with TOC entry\n\\newcommand{\\Extrachap}[1]{\\chapter*{#1}\\markboth{#1}{#1}%\n\\addcontentsline{toc}{chapter}{#1}}\n\n% measures and setting of sections\n\\renewcommand\\section{\\@startsection{section}{1}{\\z@}%\n                       {-30\\p@}% \\p@lus -4\\p@ \\@minus -4\\p@}%\n                       {16\\p@}% \\p@lus 4\\p@ \\@minus 4\\p@}%\n                       {\\normalfont\\secsize\\secstyle\n                        \\rightskip=\\z@ \\@plus 8em\\pretolerance=10000 }}\n\\renewcommand\\subsection{\\@startsection{subsection}{2}{\\z@}%\n                       {-30\\p@}% \\p@lus -4\\p@ \\@minus -4\\p@}%\n                       {16\\p@}% \\p@lus 4\\p@ \\@minus 4\\p@}%\n                       {\\normalfont\\subsecsize\\subsecstyle\n                        \\rightskip=\\z@ \\@plus 8em\\pretolerance=10000 }}\n\\renewcommand\\subsubsection{\\@startsection{subsubsection}{3}{\\z@}%\n                       {-24\\p@}% \\p@lus -4\\p@ \\@minus -4\\p@}%\n                       {12\\p@}% \\p@lus 4\\p@ \\@minus 4\\p@}%\n                       {\\normalfont\\normalsize\\subsubsecstyle\n                        \\rightskip=\\z@ \\@plus 8em\\pretolerance=10000 }}\n\\renewcommand\\paragraph{\\@startsection{paragraph}{4}{\\z@}%\n                       {-24\\p@}% \\p@lus -4\\p@ \\@minus -4\\p@}%\n                       {12\\p@}% \\p@lus 4\\p@ \\@minus 4\\p@}%\n                       {\\normalfont\\normalsize\\upshape\n                        \\rightskip=\\z@ \\@plus 8em\\pretolerance=10000 }}\n\\renewcommand\\subparagraph{\\@startsection{paragraph}{4}{\\z@}%\n                       {-18\\p@}% \\p@lus -4\\p@ \\@minus -4\\p@}%\n                       {6\\p@}% \\p@lus 4\\p@ \\@minus 4\\p@}%\n                       {\\normalfont\\normalsize\\itshape\n                        \\rightskip=\\z@ \\@plus 8em\\pretolerance=10000 }}\n\\newcommand\\runinhead{\\@startsection{paragraph}{4}{\\z@}%\n                       {-6\\p@}% \\p@lus -4\\p@ \\@minus -4\\p@}%\n                       {-6\\p@}%\n                       {\\normalfont\\normalsize\\bfseries\\boldmath\n                        \\rightskip=\\z@ \\@plus 8em\\pretolerance=10000 }}\n\\newcommand\\subruninhead{\\@startsection{paragraph}{4}{\\z@}%\n                       {-6\\p@}% \\p@lus -4\\p@ \\@minus -4\\p@}%\n                       {-6\\p@}%\n                       {\\normalfont\\normalsize\\itshape\n                        \\rightskip=\\z@ \\@plus 8em\\pretolerance=10000 }}\n\n% Appendix\n\\renewcommand\\appendix{\\par}         %article appendix\n\n\\newcommand\\bppendix{\\startnewpage            %book appendix\n                \\pagestyle{headings}\n                \\stepcounter{chapter}\n                \\setcounter{chapter}{0}\n                \\stepcounter{section}\n                \\setcounter{section}{0}\n                \\setcounter{equation}{0}\n                \\setcounter{figure}{0}\n                \\setcounter{table}{0}\n                \\setcounter{footnote}{0}\n\\let\\if@chapnum=\\iftrue\n\\def\\@chapapp{\\appendixname}\n\\renewcommand\\thechapter{\\@Alph\\c@chapter}\n\\renewcommand\\thesection{\\thechapter.\\@arabic\\c@section}\n\\renewcommand\\thesubsection{\\thesection.\\@arabic\\c@subsection}\n\\renewcommand\\theequation{\\thechapter.\\@arabic\\c@equation}\n\\renewcommand\\thefigure{\\thechapter.\\@arabic\\c@figure}\n\\renewcommand\\thetable{\\thechapter.\\@arabic\\c@table}}\n\n\\def\\hyperhrefextend{\\ifx\\hyper@anchor\\@undefined\\else\n{\\@currentHref}\\fi}\n\n\\def\\runinsep{}\n\\def\\aftertext{\\unskip\\runinsep}\n%\n%\n\\def\\@ssect#1#2#3#4#5{%\n  \\@tempskipa #3\\relax\n  \\ifdim \\@tempskipa>\\z@\n    \\begingroup\n      #4{%\n        \\@hangfrom{\\hskip #1}%\n          \\raggedright\n          \\hyphenpenalty \\@M\n          \\interlinepenalty \\@M #5\\@@par}%\n    \\endgroup\n  \\else\n    \\def\\@svsechd{#4{\\hskip #1\\relax #5}}%\n  \\fi\n  \\@xsect{#3}}\n%\n\\def\\@sect#1#2#3#4#5#6[#7]#8{%\n   \\ifnum #2>\\c@secnumdepth\n      \\let\\@svsec\\@empty\n   \\else\n      \\refstepcounter{#1}%\n      \\protected@edef\\@svsec{\\@seccntformat{#1}\\relax}%\n   \\fi\n   \\@tempskipa #5\\relax\n   \\ifdim \\@tempskipa>\\z@\n      \\begingroup #6\\relax\n         \\sec@hangfrom{\\hskip #3\\relax\\@svsec}%\n         {\\raggedright\n          \\hyphenpenalty \\@M\n          \\interlinepenalty \\@M #8\\@@par}%\n      \\endgroup\n      \\csname #1mark\\endcsname{#7}%\n      \\addcontentsline{toc}{#1}{%\n        \\ifnum #2>\\c@secnumdepth \\else\n          \\protect\\numberline{\\csname the#1\\endcsname}%\n        \\fi\n        #7}%\n      \\ifnum #2>\\c@minitocdepth \\else\n         \\mtaddtocont{\\protect\\contentsline\n             \\ifnum #2>\\@ne{mtsec}\\else{mtchap}\\fi\n             \\ifnum #2>\\c@secnumdepth\n                {#7}%\n             \\else\n                {\\protect\\numberline{\\csname the#1\\endcsname}#7}%\n             \\fi\n             {\\thepage}\\hyperhrefextend}%\n      \\fi\n   \\else\n      \\def\\@svsechd{%\n         #6\\hskip #3\\relax\n         \\@svsec #8\\aftertext\\ignorespaces\n         \\csname #1mark\\endcsname{#7}%\n         \\addcontentsline{toc}{#1}{%\n            \\ifnum #2>\\c@secnumdepth \\else\n                \\protect\\numberline{\\csname the#1\\endcsname}%\n            \\fi\n            #7}}%\n   \\fi\n   \\@xsect{#5}}\n\n% figures and tables are processed in small print\n\\def \\@floatboxreset {%\n        \\reset@font\n        \\small\n        \\@setnobreak\n        \\@setminipage\n}\n\\def\\fps@figure{htbp}\n\\def\\fps@table{htbp}\n%\n% Frame for paste-in figures or tables\n\\def\\mpicplace#1#2{%  #1 =width   #2 =height\n\\vbox{\\hbox to #1{\\vrule\\@width \\fboxrule \\@height #2\\hfill}}}\n%\n\\newenvironment{svgraybox}%\n       {\\ClassWarning{Springer-SVMono}{Environment \"svgraybox\" not available,\\MessageBreak\n         switching over to \"quotation\" environment;\\MessageBreak\n         specify documentclass option \"graybox\",\\MessageBreak\n         see SVMono documentation -}%\n                \\par\\addvspace{6pt}\n                \\list{}{\\listparindent12\\p@%\n                        \\leftmargin=12\\p@%\n                        \\itemindent    \\listparindent\n                        \\rightmargin   \\leftmargin\n                        \\parsep        \\z@ \\@plus\\p@}%\n                \\expandafter\\item\\parindent=\\svparindent\n                \\relax\\hskip-\\listparindent}%\n       {\\endlist}%\n%\n\\newenvironment{svtintedbox}%\n       {\\ClassWarning{Springer-SVMono}{Environment \"svtintedbox\" not available,\\MessageBreak\n         switching over to \"quotation\" environment;\\MessageBreak\n         specify documentclass option \"graybox\",\\MessageBreak\n         see SVMono documentation -}%\n                \\par\\addvspace{6pt}\n                \\list{}{\\listparindent12\\p@%\n                        \\leftmargin=12\\p@%\n                        \\itemindent    \\listparindent\n                        \\rightmargin   \\leftmargin\n                        \\parsep        \\z@ \\@plus\\p@}%\n                \\expandafter\\item\\parindent=\\svparindent\n                \\relax\\hskip-\\listparindent}%\n       {\\endlist}%\n%\n\\renewenvironment{quotation}\n               {\\par\\addvspace{6pt}\n                \\list{}{\\listparindent12\\p@%\n                        \\leftmargin=12\\p@%\n                        \\itemindent    \\listparindent\n                        \\rightmargin   \\leftmargin\n                        \\parsep        \\z@ \\@plus\\p@%\n                        \\small}%\n                \\item\\relax\\hskip-\\listparindent}\n               {\\endlist}\n%\n\\renewenvironment{quote}\n               {\\par\\addvspace{6pt}\n                \\list{}{\\leftmargin=12\\p@%\n                \\rightmargin\\leftmargin\n                \\parsep=3\\p@\n                \\small}%\n                \\item\\relax}\n               {\\endlist}\n\n% labels of enumerate\n\\renewcommand\\labelenumii{\\theenumii.}\n\\renewcommand\\theenumii{\\@alph\\c@enumii}\n\n% labels of itemize\n\\renewcommand\\labelitemi{\\textbullet}\n\\renewcommand\\labelitemii{\\textendash}\n\\let\\labelitemiii=\\labelitemiv\n\n% labels of description\n\\renewcommand*\\descriptionlabel[1]{\\hspace\\labelsep #1\\hfil}\n\n% fixed indentation for standard itemize-environment\n\\newdimen\\svitemindent \\setlength{\\svitemindent}{\\parindent}\n\n\n% make indentations changeable\n\n\\def\\setitemindent#1{\\settowidth{\\labelwidth}{#1}%\n        \\let\\setit@m=Y%\n        \\leftmargini\\labelwidth\n        \\advance\\leftmargini\\labelsep\n   \\def\\@listi{\\leftmargin\\leftmargini\n        \\labelwidth\\leftmargini\\advance\\labelwidth by -\\labelsep\n        \\parsep=\\parskip\n        \\topsep=\\medskipamount\n        \\itemsep=\\parskip \\advance\\itemsep by -\\parsep}}\n\\def\\setitemitemindent#1{\\settowidth{\\labelwidth}{#1}%\n        \\let\\setit@m=Y%\n        \\leftmarginii\\labelwidth\n        \\advance\\leftmarginii\\labelsep\n\\def\\@listii{\\leftmargin\\leftmarginii\n        \\labelwidth\\leftmarginii\\advance\\labelwidth by -\\labelsep\n        \\parsep=\\parskip\n        \\topsep=6\\p@\n        \\itemsep=\\parskip \\advance\\itemsep by -\\parsep}}\n%\n% adjusted environment \"description\"\n% if an optional parameter (at the first two levels of lists)\n% is present, its width is considered to be the widest mark\n% throughout the current list.\n\\def\\description{\\@ifnextchar[{\\@describe}{\\list{}{\\labelwidth\\z@\n\\labelsep=12pt\\relax  %!!!!!!!!!\n\\leftmargini=12pt\\relax  %!!!!!!!!!\n\\leftmargin=12pt\\relax  %!!!!!!!!!\n          \\itemindent-\\leftmargin \\let\\makelabel\\descriptionlabel}}}\n%\n\\def\\describelabel#1{#1\\hfil}\n\\def\\@describe[#1]{\\labelsep=12pt\\relax\n\\relax\\ifnum\\@listdepth=0\n\\setitemindent{#1}\\else\\ifnum\\@listdepth=1\n\\setitemitemindent{#1}\\fi\\fi\n\\list{--}{\\let\\makelabel\\describelabel}}\n%\n\\def\\itemize{%\n  \\ifnum \\@itemdepth >\\thr@@\\@toodeep\\else\n    \\advance\\@itemdepth\\@ne\n    \\ifx\\setit@m\\undefined\n       \\ifnum \\@itemdepth=1 \\leftmargini=\\svitemindent\n          \\labelwidth\\leftmargini\\advance\\labelwidth-\\labelsep\n          \\leftmarginii=\\leftmargini \\leftmarginiii=\\leftmargini\n       \\fi\n    \\fi\n    \\edef\\@itemitem{labelitem\\romannumeral\\the\\@itemdepth}%\n    \\expandafter\\list\n      \\csname\\@itemitem\\endcsname\n      {\\def\\makelabel##1{\\rlap{##1}\\hss}}%\n  \\fi}\n%\n\\def\\enumerate{%\n  \\ifnum \\@enumdepth >\\thr@@\\@toodeep\\else\n    \\advance\\@enumdepth\\@ne\n    \\ifx\\setit@m\\undefined\n       \\ifnum \\@enumdepth=1 \\leftmargini=\\svitemindent\n          \\labelwidth\\leftmargini\\advance\\labelwidth-\\labelsep\n          \\leftmarginii=\\leftmargini \\leftmarginiii=\\leftmargini\n       \\fi\n    \\fi\n    \\edef\\@enumctr{enum\\romannumeral\\the\\@enumdepth}%\n      \\expandafter\n      \\list\n        \\csname label\\@enumctr\\endcsname\n        {\\usecounter\\@enumctr\\def\\makelabel##1{\\hss\\llap{##1}}}%\n  \\fi}\n%\n\\newdimen\\verbatimindent \\verbatimindent\\parindent\n\\def\\verbatim{\\advance\\@totalleftmargin by\\verbatimindent\n\\@verbatim \\frenchspacing\\@vobeyspaces \\@xverbatim}\n\n%\n%  special signs and characters\n\\newcommand{\\D}{\\mathrm{d}}\n\\newcommand{\\E}{\\mathrm{e}}\n\\let\\eul=\\E\n\\newcommand{\\I}{{\\rm i}}\n\\let\\imag=\\I\n%\n% the definition of uppercase Greek characters\n% Springer likes them as italics to depict variables\n\\DeclareMathSymbol{\\Gamma}{\\mathalpha}{letters}{\"00}\n\\DeclareMathSymbol{\\Delta}{\\mathalpha}{letters}{\"01}\n\\DeclareMathSymbol{\\Theta}{\\mathalpha}{letters}{\"02}\n\\DeclareMathSymbol{\\Lambda}{\\mathalpha}{letters}{\"03}\n\\DeclareMathSymbol{\\Xi}{\\mathalpha}{letters}{\"04}\n\\DeclareMathSymbol{\\Pi}{\\mathalpha}{letters}{\"05}\n\\DeclareMathSymbol{\\Sigma}{\\mathalpha}{letters}{\"06}\n\\DeclareMathSymbol{\\Upsilon}{\\mathalpha}{letters}{\"07}\n\\DeclareMathSymbol{\\Phi}{\\mathalpha}{letters}{\"08}\n\\DeclareMathSymbol{\\Psi}{\\mathalpha}{letters}{\"09}\n\\DeclareMathSymbol{\\Omega}{\\mathalpha}{letters}{\"0A}\n% the upright forms are defined here as \\var<Character>\n\\DeclareMathSymbol{\\varGamma}{\\mathalpha}{operators}{\"00}\n\\DeclareMathSymbol{\\varDelta}{\\mathalpha}{operators}{\"01}\n\\DeclareMathSymbol{\\varTheta}{\\mathalpha}{operators}{\"02}\n\\DeclareMathSymbol{\\varLambda}{\\mathalpha}{operators}{\"03}\n\\DeclareMathSymbol{\\varXi}{\\mathalpha}{operators}{\"04}\n\\DeclareMathSymbol{\\varPi}{\\mathalpha}{operators}{\"05}\n\\DeclareMathSymbol{\\varSigma}{\\mathalpha}{operators}{\"06}\n\\DeclareMathSymbol{\\varUpsilon}{\\mathalpha}{operators}{\"07}\n\\DeclareMathSymbol{\\varPhi}{\\mathalpha}{operators}{\"08}\n\\DeclareMathSymbol{\\varPsi}{\\mathalpha}{operators}{\"09}\n\\DeclareMathSymbol{\\varOmega}{\\mathalpha}{operators}{\"0A}\n% Upright Lower Case Greek letters without using a new MathAlphabet\n\\newcommand{\\greeksym}[1]{\\usefont{U}{psy}{m}{n}#1}\n\\newcommand{\\greeksymbold}[1]{{\\usefont{U}{psy}{b}{n}#1}}\n\\newcommand{\\allmodesymb}[2]{\\relax\\ifmmode{\\mathchoice\n{\\mbox{\\fontsize{\\tf@size}{\\tf@size}#1{#2}}}\n{\\mbox{\\fontsize{\\tf@size}{\\tf@size}#1{#2}}}\n{\\mbox{\\fontsize{\\sf@size}{\\sf@size}#1{#2}}}\n{\\mbox{\\fontsize{\\ssf@size}{\\ssf@size}#1{#2}}}}\n\\else\n\\mbox{#1{#2}}\\fi}\n% Definition of lower case Greek letters\n\\newcommand{\\ualpha}{\\allmodesymb{\\greeksym}{a}}\n\\newcommand{\\ubeta}{\\allmodesymb{\\greeksym}{b}}\n\\newcommand{\\uchi}{\\allmodesymb{\\greeksym}{c}}\n\\newcommand{\\udelta}{\\allmodesymb{\\greeksym}{d}}\n\\newcommand{\\ugamma}{\\allmodesymb{\\greeksym}{g}}\n\\newcommand{\\umu}{\\allmodesymb{\\greeksym}{m}}\n\\newcommand{\\unu}{\\allmodesymb{\\greeksym}{n}}\n\\newcommand{\\upi}{\\allmodesymb{\\greeksym}{p}}\n\\newcommand{\\utau}{\\allmodesymb{\\greeksym}{t}}\n% redefines the \\vec accent to a bold character - if desired\n\\def\\fig@type{arrow}% temporarily abused\n\\ifx\\vec@style\\fig@type\\else\n\\@ifundefined{vec@style}{%\n \\def\\vec#1{\\ensuremath{\\mathchoice\n                     {\\mbox{\\boldmath$\\displaystyle\\boldsymbol{#1}$}}\n                     {\\mbox{\\boldmath$\\textstyle\\boldsymbol{#1}$}}\n                     {\\mbox{\\boldmath$\\scriptstyle\\boldsymbol{#1}$}}\n                     {\\mbox{\\boldmath$\\scriptscriptstyle\\boldsymbol{#1}$}}}}%\n}\n{\\def\\vec#1{\\ensuremath{\\mathchoice\n                     {\\mbox{\\boldmath$\\displaystyle#1$}}\n                     {\\mbox{\\boldmath$\\textstyle#1$}}\n                     {\\mbox{\\boldmath$\\scriptstyle#1$}}\n                     {\\mbox{\\boldmath$\\scriptscriptstyle#1$}}}}%\n}\n\\fi\n% tensor\n\\def\\tens#1{\\relax\\ifmmode\\mathsf{#1}\\else\\textsf{#1}\\fi}\n\n% end of proof symbol\n\\newcommand\\qedsymbol{\\hbox{\\rlap{$\\sqcap$}$\\sqcup$}}\n\\newcommand\\qed{\\relax\\ifmmode\\else\\unskip\\quad\\fi\\qedsymbol}\n\\newcommand\\smartqed{\\renewcommand\\qed{\\relax\\ifmmode\\qedsymbol\\else\n  {\\unskip\\nobreak\\hfil\\penalty50\\hskip1em\\null\\nobreak\\hfil\\qedsymbol\n  \\parfillskip=\\z@\\finalhyphendemerits=0\\endgraf}\\fi}}\n%\n\\newif\\if@numart   \\@numarttrue\n\\def\\ds@numart{\\@numarttrue\n  \\@takefromreset{figure}{chapter}%\n  \\@takefromreset{table}{chapter}%\n  \\@takefromreset{equation}{chapter}%\n  \\def\\thesection{\\@arabic\\c@section}%\n  \\def\\thefigure{\\@arabic\\c@figure}%\n  \\def\\thetable{\\@arabic\\c@table}%\n  \\def\\theequation{\\arabic{equation}}%\n  \\def\\thesubequation{\\arabic{equation}\\alph{subequation}}}\n%\n\\def\\ds@book{\\@numartfalse\n\\def\\thesection{\\thechapter.\\@arabic\\c@section}%\n\\def\\thefigure{\\thechapter.\\@arabic\\c@figure}%\n\\def\\thetable{\\thechapter.\\@arabic\\c@table}%\n\\def\\theequation{\\thechapter.\\arabic{equation}}%\n\\@addtoreset{section}{chapter}%\n\\@addtoreset{figure}{chapter}%\n\\@addtoreset{table}{chapter}%\n\\@addtoreset{equation}{chapter}}\n%\n% Ragged bottom for the actual page\n\\def\\thisbottomragged{\\def\\@textbottom{\\vskip\\z@ \\@plus.0001fil\n\\global\\let\\@textbottom\\relax}}\n\n% This is texte.tex\n% it defines various texts and their translations\n% called up with documentstyle options\n\\def\\switcht@albion{%\n\\def\\abbrsymbname{List of Abbreviations and Symbols}%\n\\def\\abstractname{Abstract}%\n\\def\\ackname{Acknowledgements}%\n\\def\\andname{and}%\n\\def\\bibname{References}%\n\\def\\lastandname{, and}%\n\\def\\appendixname{Appendix}%\n\\def\\chaptername{Chapter}%\n\\def\\claimname{Claim}%\n\\def\\conjecturename{Conjecture}%\n\\def\\contentsname{Contents}%\n\\def\\corollaryname{Corollary}%\n\\def\\definitionname{Definition}%\n\\def\\emailname{e-mail}%\n\\def\\examplename{Example}%\n\\def\\exercisename{Exercise}%\n\\def\\figurename{Fig.}%\n\\def\\forewordname{Foreword}%\n\\def\\keywordname{{\\bf Key words:}}%\n\\def\\indexname{Index}%\n\\def\\lemmaname{Lemma}%\n\\def\\contriblistname{List of Contributors}%\n\\def\\listfigurename{List of Figures}%\n\\def\\listtablename{List of Tables}%\n\\def\\mailname{{\\it Correspondence to\\/}:}%\n\\def\\noteaddname{Note added in proof}%\n\\def\\notename{Note}%\n\\def\\partname{Part}%\n\\def\\prefacename{Preface}%\n\\def\\problemname{Problem}%\n\\def\\proofname{Proof}%\n\\def\\propertyname{Property}%\n\\def\\propositionname{Proposition}%\n\\def\\questionname{Question}%\n\\def\\refname{References}%\n\\def\\remarkname{Remark}%\n\\def\\seename{see}%\n\\def\\solutionname{Solution}%\n\\def\\subclassname{{\\it Subject Classifications\\/}:}%\n\\def\\tablename{Table}%\n\\def\\theoremname{Theorem}}\n\\switcht@albion\n% Names of theorem like environments are already defined\n% but must be translated if another language is chosen\n%\n% French section\n\\def\\switcht@francais{\\svlanginfo\n \\def\\abbrsymbname{Liste des abbr\\'eviations et symboles}%\n \\def\\abstractname{R\\'esum\\'e.}%\n \\def\\ackname{Remerciements.}%\n \\def\\andname{et}%\n \\def\\lastandname{ et}%\n \\def\\appendixname{Appendice}%\n \\def\\bibname{Bibliographie}%\n \\def\\chaptername{Chapitre}%\n \\def\\claimname{Pr\\'etention}%\n \\def\\conjecturename{Hypoth\\`ese}%\n \\def\\contentsname{Table des mati\\`eres}%\n \\def\\corollaryname{Corollaire}%\n \\def\\definitionname{D\\'efinition}%\n \\def\\emailname{e-mail}%\n \\def\\examplename{Exemple}%\n \\def\\exercisename{Exercice}%\n \\def\\figurename{Fig.}%\n \\def\\forewordname{Avant-propos}%\n \\def\\keywordname{{\\bf Mots-cl\\'e:}}%\n \\def\\indexname{Index}%\n \\def\\lemmaname{Lemme}%\n \\def\\contriblistname{Liste des contributeurs}%\n \\def\\listfigurename{Liste des figures}%\n \\def\\listtablename{Liste des tables}%\n \\def\\mailname{{\\it Correspondence to\\/}:}%\n \\def\\noteaddname{Note ajout\\'ee \\`a l'\\'epreuve}%\n \\def\\notename{Remarque}%\n \\def\\partname{Partie}%\n \\def\\prefacename{Pr\\'eface}%\n \\def\\problemname{Probl\\`eme}%\n \\def\\proofname{Preuve}%\n \\def\\propertyname{Caract\\'eristique}%\n%\\def\\propositionname{Proposition}%\n \\def\\questionname{Question}%\n \\def\\refname{Litt\\'erature}%\n \\def\\remarkname{Remarque}%\n \\def\\seename{voir}%\n \\def\\solutionname{Solution}%\n \\def\\subclassname{{\\it Subject Classifications\\/}:}%\n \\def\\tablename{Tableau}%\n \\def\\theoremname{Th\\'eor\\`eme}%\n}\n%\n% German section\n\\def\\switcht@deutsch{\\svlanginfo\n \\def\\abbrsymbname{Abk\\\"urzungs- und Symbolverzeichnis}%\n \\def\\abstractname{Zusammenfassung}%\n \\def\\ackname{Danksagung}%\n \\def\\andname{und}%\n \\def\\lastandname{ und}%\n \\def\\appendixname{Anhang}%\n \\def\\bibname{Literaturverzeichnis}%\n \\def\\chaptername{Kapitel}%\n \\def\\claimname{Behauptung}%\n \\def\\conjecturename{Hypothese}%\n \\def\\contentsname{Inhaltsverzeichnis}%\n \\def\\corollaryname{Korollar}%\n%\\def\\definitionname{Definition}%\n \\def\\emailname{E-mail}%\n \\def\\examplename{Beispiel}%\n \\def\\exercisename{\\\"Ubung}%\n \\def\\figurename{Abb.}%\n \\def\\forewordname{Geleitwort}%\n \\def\\keywordname{{\\bf Schl\\\"usselw\\\"orter:}}%\n \\def\\indexname{Sachverzeichnis}%\n%\\def\\lemmaname{Lemma}%\n \\def\\contriblistname{Mitarbeiter}%\n \\def\\listfigurename{Abbildungsverzeichnis}%\n \\def\\listtablename{Tabellenverzeichnis}%\n \\def\\mailname{{\\it Correspondence to\\/}:}%\n \\def\\noteaddname{Nachtrag}%\n \\def\\notename{Anmerkung}%\n \\def\\partname{Teil}%\n \\def\\prefacename{Vorwort}%\n%\\def\\problemname{Problem}%\n \\def\\proofname{Beweis}%\n \\def\\propertyname{Eigenschaft}%\n%\\def\\propositionname{Proposition}%\n \\def\\questionname{Frage}%\n \\def\\refname{Literaturverzeichnis}%\n \\def\\remarkname{Anmerkung}%\n \\def\\seename{siehe}%\n \\def\\solutionname{L\\\"osung}%\n \\def\\subclassname{{\\it Subject Classifications\\/}:}%\n \\def\\tablename{Tabelle}%\n%\\def\\theoremname{Theorem}%\n}\n\n\\def\\getsto{\\mathrel{\\mathchoice {\\vcenter{\\offinterlineskip\n\\halign{\\hfil\n$\\displaystyle##$\\hfil\\cr\\gets\\cr\\to\\cr}}}\n{\\vcenter{\\offinterlineskip\\halign{\\hfil$\\textstyle##$\\hfil\\cr\\gets\n\\cr\\to\\cr}}}\n{\\vcenter{\\offinterlineskip\\halign{\\hfil$\\scriptstyle##$\\hfil\\cr\\gets\n\\cr\\to\\cr}}}\n{\\vcenter{\\offinterlineskip\\halign{\\hfil$\\scriptscriptstyle##$\\hfil\\cr\n\\gets\\cr\\to\\cr}}}}}\n\\def\\lid{\\mathrel{\\mathchoice {\\vcenter{\\offinterlineskip\\halign{\\hfil\n$\\displaystyle##$\\hfil\\cr<\\cr\\noalign{\\vskip1.2\\p@}=\\cr}}}\n{\\vcenter{\\offinterlineskip\\halign{\\hfil$\\textstyle##$\\hfil\\cr<\\cr\n\\noalign{\\vskip1.2\\p@}=\\cr}}}\n{\\vcenter{\\offinterlineskip\\halign{\\hfil$\\scriptstyle##$\\hfil\\cr<\\cr\n\\noalign{\\vskip\\p@}=\\cr}}}\n{\\vcenter{\\offinterlineskip\\halign{\\hfil$\\scriptscriptstyle##$\\hfil\\cr\n<\\cr\n\\noalign{\\vskip0.9\\p@}=\\cr}}}}}\n\\def\\gid{\\mathrel{\\mathchoice {\\vcenter{\\offinterlineskip\\halign{\\hfil\n$\\displaystyle##$\\hfil\\cr>\\cr\\noalign{\\vskip1.2\\p@}=\\cr}}}\n{\\vcenter{\\offinterlineskip\\halign{\\hfil$\\textstyle##$\\hfil\\cr>\\cr\n\\noalign{\\vskip1.2\\p@}=\\cr}}}\n{\\vcenter{\\offinterlineskip\\halign{\\hfil$\\scriptstyle##$\\hfil\\cr>\\cr\n\\noalign{\\vskip\\p@}=\\cr}}}\n{\\vcenter{\\offinterlineskip\\halign{\\hfil$\\scriptscriptstyle##$\\hfil\\cr\n>\\cr\n\\noalign{\\vskip0.9\\p@}=\\cr}}}}}\n\\def\\grole{\\mathrel{\\mathchoice {\\vcenter{\\offinterlineskip\n\\halign{\\hfil\n$\\displaystyle##$\\hfil\\cr>\\cr\\noalign{\\vskip-\\p@}<\\cr}}}\n{\\vcenter{\\offinterlineskip\\halign{\\hfil$\\textstyle##$\\hfil\\cr\n>\\cr\\noalign{\\vskip-\\p@}<\\cr}}}\n{\\vcenter{\\offinterlineskip\\halign{\\hfil$\\scriptstyle##$\\hfil\\cr\n>\\cr\\noalign{\\vskip-0.8\\p@}<\\cr}}}\n{\\vcenter{\\offinterlineskip\\halign{\\hfil$\\scriptscriptstyle##$\\hfil\\cr\n>\\cr\\noalign{\\vskip-0.3\\p@}<\\cr}}}}}\n\\def\\bbbr{{\\rm I\\!R}} %reelle Zahlen\n\\def\\bbbm{{\\rm I\\!M}}\n\\def\\bbbn{{\\rm I\\!N}} %natuerliche Zahlen\n\\def\\bbbf{{\\rm I\\!F}}\n\\def\\bbbh{{\\rm I\\!H}}\n\\def\\bbbk{{\\rm I\\!K}}\n\\def\\bbbp{{\\rm I\\!P}}\n\\def\\bbbone{{\\mathchoice {\\rm 1\\mskip-4mu l} {\\rm 1\\mskip-4mu l}\n{\\rm 1\\mskip-4.5mu l} {\\rm 1\\mskip-5mu l}}}\n\\def\\bbbc{{\\mathchoice {\\setbox0=\\hbox{$\\displaystyle\\rm C$}\\hbox{\\hbox\nto\\z@{\\kern0.4\\wd0\\vrule\\@height0.9\\ht0\\hss}\\box0}}\n{\\setbox0=\\hbox{$\\textstyle\\rm C$}\\hbox{\\hbox\nto\\z@{\\kern0.4\\wd0\\vrule\\@height0.9\\ht0\\hss}\\box0}}\n{\\setbox0=\\hbox{$\\scriptstyle\\rm C$}\\hbox{\\hbox\nto\\z@{\\kern0.4\\wd0\\vrule\\@height0.9\\ht0\\hss}\\box0}}\n{\\setbox0=\\hbox{$\\scriptscriptstyle\\rm C$}\\hbox{\\hbox\nto\\z@{\\kern0.4\\wd0\\vrule\\@height0.9\\ht0\\hss}\\box0}}}}\n\\def\\bbbq{{\\mathchoice {\\setbox0=\\hbox{$\\displaystyle\\rm\nQ$}\\hbox{\\raise\n0.15\\ht0\\hbox to\\z@{\\kern0.4\\wd0\\vrule\\@height0.8\\ht0\\hss}\\box0}}\n{\\setbox0=\\hbox{$\\textstyle\\rm Q$}\\hbox{\\raise\n0.15\\ht0\\hbox to\\z@{\\kern0.4\\wd0\\vrule\\@height0.8\\ht0\\hss}\\box0}}\n{\\setbox0=\\hbox{$\\scriptstyle\\rm Q$}\\hbox{\\raise\n0.15\\ht0\\hbox to\\z@{\\kern0.4\\wd0\\vrule\\@height0.7\\ht0\\hss}\\box0}}\n{\\setbox0=\\hbox{$\\scriptscriptstyle\\rm Q$}\\hbox{\\raise\n0.15\\ht0\\hbox to\\z@{\\kern0.4\\wd0\\vrule\\@height0.7\\ht0\\hss}\\box0}}}}\n\\def\\bbbt{{\\mathchoice {\\setbox0=\\hbox{$\\displaystyle\\rm\nT$}\\hbox{\\hbox to\\z@{\\kern0.3\\wd0\\vrule\\@height0.9\\ht0\\hss}\\box0}}\n{\\setbox0=\\hbox{$\\textstyle\\rm T$}\\hbox{\\hbox\nto\\z@{\\kern0.3\\wd0\\vrule\\@height0.9\\ht0\\hss}\\box0}}\n{\\setbox0=\\hbox{$\\scriptstyle\\rm T$}\\hbox{\\hbox\nto\\z@{\\kern0.3\\wd0\\vrule\\@height0.9\\ht0\\hss}\\box0}}\n{\\setbox0=\\hbox{$\\scriptscriptstyle\\rm T$}\\hbox{\\hbox\nto\\z@{\\kern0.3\\wd0\\vrule\\@height0.9\\ht0\\hss}\\box0}}}}\n\\def\\bbbs{{\\mathchoice\n{\\setbox0=\\hbox{$\\displaystyle     \\rm S$}\\hbox{\\raise0.5\\ht0\\hbox\nto\\z@{\\kern0.35\\wd0\\vrule\\@height0.45\\ht0\\hss}\\hbox\nto\\z@{\\kern0.55\\wd0\\vrule\\@height0.5\\ht0\\hss}\\box0}}\n{\\setbox0=\\hbox{$\\textstyle        \\rm S$}\\hbox{\\raise0.5\\ht0\\hbox\nto\\z@{\\kern0.35\\wd0\\vrule\\@height0.45\\ht0\\hss}\\hbox\nto\\z@{\\kern0.55\\wd0\\vrule\\@height0.5\\ht0\\hss}\\box0}}\n{\\setbox0=\\hbox{$\\scriptstyle      \\rm S$}\\hbox{\\raise0.5\\ht0\\hbox\nto\\z@{\\kern0.35\\wd0\\vrule\\@height0.45\\ht0\\hss}\\raise0.05\\ht0\\hbox\nto\\z@{\\kern0.5\\wd0\\vrule\\@height0.45\\ht0\\hss}\\box0}}\n{\\setbox0=\\hbox{$\\scriptscriptstyle\\rm S$}\\hbox{\\raise0.5\\ht0\\hbox\nto\\z@{\\kern0.4\\wd0\\vrule\\@height0.45\\ht0\\hss}\\raise0.05\\ht0\\hbox\nto\\z@{\\kern0.55\\wd0\\vrule\\@height0.45\\ht0\\hss}\\box0}}}}\n\\def\\bbbz{{\\mathchoice {\\hbox{$\\textstyle\\sf Z\\kern-0.4em Z$}}\n{\\hbox{$\\textstyle\\sf Z\\kern-0.4em Z$}}\n{\\hbox{$\\scriptstyle\\sf Z\\kern-0.3em Z$}}\n{\\hbox{$\\scriptscriptstyle\\sf Z\\kern-0.2em Z$}}}}\n\n\\let\\ts\\,\n\n\\setlength\\arrayrulewidth{.5\\p@}\n\\def\\svhline{%\n  \\noalign{\\ifnum0=`}\\fi\\hrule \\@height2\\arrayrulewidth \\futurelet\n   \\reserved@a\\@xhline}\n\n\\setlength \\labelsep     {5\\p@}\n\\setlength\\leftmargini   {17\\p@}\n\\setlength\\leftmargin    {\\leftmargini}\n\\setlength\\leftmarginii  {\\leftmargini}\n\\setlength\\leftmarginiii {\\leftmargini}\n\\setlength\\leftmarginiv  {\\leftmargini}\n\\setlength\\labelwidth    {\\leftmargini}\n\\addtolength\\labelwidth{-\\labelsep}\n\n\\def\\@listI{\\leftmargin\\leftmargini\n        \\parsep=\\parskip\n        \\topsep=\\medskipamount\n        \\itemsep=\\parskip \\advance\\itemsep by -\\parsep}\n\\let\\@listi\\@listI\n\\@listi\n\n\\def\\@listii{\\leftmargin\\leftmarginii\n        \\labelwidth\\leftmarginii\n        \\advance\\labelwidth by -\\labelsep\n        \\parsep=\\parskip\n        \\topsep=6\\p@\n        \\itemsep=\\parskip\n        \\advance\\itemsep by -\\parsep}\n\n\\def\\@listiii{\\leftmargin\\leftmarginiii\n        \\labelwidth\\leftmarginiii\\advance\\labelwidth by -\\labelsep\n        \\parsep=\\parskip\n        \\topsep=\\z@\n        \\itemsep=\\parskip\n        \\advance\\itemsep by -\\parsep\n        \\partopsep=\\topsep}\n\n\\setlength\\arraycolsep{1.5\\p@}\n\\setlength\\tabcolsep{1.5\\p@}\n\n\\def\\tableofcontents{\\chapter*{\\contentsname\\markboth{{\\contentsname}}%\n                                                    {{\\contentsname}}}\n \\def\\authcount##1{\\setcounter{auco}{##1}\\setcounter{@auth}{1}}\n \\def\\lastand{\\ifnum\\value{auco}=2\\relax\n                 \\unskip{} \\andname\\\n              \\else\n                 \\unskip \\lastandname\\\n              \\fi}%\n \\def\\and{\\stepcounter{@auth}\\relax\n          \\ifnum\\value{@auth}=\\value{auco}%\n             \\lastand\n          \\else\n             \\unskip,\n          \\fi}%\n \\@starttoc{toc}\\if@restonecol\\twocolumn\\fi}\n\n\\setcounter{tocdepth}{2}\n\n\\def\\l@part#1#2{\\addpenalty{\\@secpenalty}%\n   \\addvspace{1em \\@plus\\p@}%\n   \\begingroup\n     \\parindent \\z@\n     \\rightskip \\z@ \\@plus 5em\n%    \\hrule\\vskip5\\p@\n     \\bfseries\\boldmath\n     \\leavevmode\n     #1\\par\n%    \\vskip5\\p@\n%    \\hrule\n     \\vskip\\p@\n     \\nobreak\n   \\addvspace{1em \\@plus\\p@}%\n   \\endgroup}\n\n\\def\\@dotsep{2}\n\n\\def\\addnumcontentsmark#1#2#3{%\n\\addtocontents{#1}{\\protect\\contentsline{#2}{\\protect\\numberline\n                                    {\\thechapter}#3}{\\thepage}}}\n\\def\\addcontentsmark#1#2#3{%\n\\addtocontents{#1}{\\protect\\contentsline{#2}{#3}{\\thepage}}}\n\\def\\addcontentsmarkwop#1#2#3{%\n\\addtocontents{#1}{\\protect\\contentsline{#2}{#3}{0}}}\n\n\\def\\@adcmk[#1]{\\ifcase #1 \\or\n\\def\\@gtempa{\\addnumcontentsmark}%\n  \\or    \\def\\@gtempa{\\addcontentsmark}%\n  \\or    \\def\\@gtempa{\\addcontentsmarkwop}%\n  \\fi\\@gtempa{toc}{chapter}}\n\\def\\addtocmark{\\@ifnextchar[{\\@adcmk}{\\@adcmk[3]}}\n\n\\def\\l@chapter#1#2{\\par\\addpenalty{-\\@highpenalty}\n \\addvspace{1.0em \\@plus \\p@}\n \\@tempdima \\tocchpnum \\begingroup\n \\parindent \\z@ \\rightskip \\@tocrmarg\n \\advance\\rightskip by \\z@ \\@plus 2cm\n \\parfillskip -\\rightskip \\pretolerance=10000\n \\leavevmode \\advance\\leftskip\\@tempdima \\hskip -\\leftskip\n {\\bfseries\\boldmath#1}\\ifx0#2\\hfil\\null\n \\else\n      \\nobreak\n      \\leaders\\hbox{$\\m@th \\mkern \\@dotsep mu\\hbox{.}\\mkern\n      \\@dotsep mu$}\\hfill\n      \\nobreak\\hbox to\\@pnumwidth{\\hfil #2}%\n \\fi\\par\n \\penalty\\@highpenalty \\endgroup}\n\n\\newcommand{\\tocauthorstyle}{\\upshape}\n\\newcommand{\\toctitlestyle}{\\bfseries}\n\n\\def\\l@title#1#2{\\addpenalty{-\\@highpenalty}\n \\addvspace{8\\p@ \\@plus \\p@}\n \\@tempdima \\z@\n \\begingroup\n \\tocchpnum \\z@ \\calctocindent\n \\parindent \\z@ \\rightskip \\@tocrmarg\n \\advance\\rightskip by \\z@ \\@plus 2cm\n \\pretolerance=10000\n \\parfillskip -\\@tocrmarg\n \\leavevmode \\advance\\leftskip\\@tempdima \\hskip -\\leftskip\n {\\toctitlestyle#1}%\\nobreak\n \\leaders\\hbox{$\\m@th \\mkern \\@dotsep mu.\\mkern\n \\@dotsep mu$}\\hfill\n \\nobreak\\hbox to\\@pnumwidth{\\hss #2}%\n \\par\n \\penalty\\@highpenalty \\endgroup}\n\n\\def\\l@titlech#1#2{\\addpenalty{-\\@highpenalty}\n \\addvspace{8\\p@ \\@plus \\p@}\n \\@tempdima=\\tocchpnum\n \\begingroup\n \\parindent \\z@ \\rightskip \\@tocrmarg\n \\advance\\rightskip by \\z@ \\@plus 2cm\n \\pretolerance=10000\n \\parfillskip -\\@tocrmarg\n \\leavevmode \\advance\\leftskip\\@tempdima \\hskip -\\leftskip\n {\\toctitlestyle#1}%\\nobreak\n \\leaders\\hbox{$\\m@th \\mkern \\@dotsep mu.\\mkern\n \\@dotsep mu$}\\hfill\n \\nobreak\\hbox to\\@pnumwidth{\\hss #2}%\n \\par\n \\penalty\\@highpenalty \\endgroup}\n\n\\newcommand{\\tocaftauthskip}{\\z@}\n\\def\\l@author#1#2{%\\addpenalty{\\@highpenalty}\n \\@tempdima \\z@\n \\begingroup\n \\pretolerance=10000\n \\parindent \\z@ \\rightskip \\@tocrmarg\n \\advance\\rightskip by \\z@ \\@plus 2cm\n%\\parfillskip -\\@tocrmarg\n \\leavevmode \\advance\\leftskip\\@tempdima \\hskip -\\leftskip\n {\\tocauthorstyle#1}\\nobreak\n%\\leaders\\hbox{$\\m@th \\mkern \\@dotsep mu.\\mkern\n%\\@dotsep mu$}\\hfill\n%\\nobreak\\hbox to\\@pnumwidth{\\hss #2}%\n \\par\n \\penalty\\@highpenalty\n \\addvspace{\\tocaftauthskip}\\endgroup}\n\n\\def\\l@authorch#1#2{%\\addpenalty{\\@highpenalty}\n \\@tempdima=\\tocchpnum\n \\begingroup\n \\pretolerance=10000\n \\parindent \\z@ \\rightskip \\@tocrmarg\n \\advance\\rightskip by \\z@ \\@plus 2cm\n%\\parfillskip -\\@tocrmarg\n \\leavevmode \\advance\\leftskip\\@tempdima %\\hskip -\\leftskip\n {\\tocauthorstyle#1}\\nobreak\n%\\leaders\\hbox{$\\m@th \\mkern \\@dotsep mu.\\mkern\n%\\@dotsep mu$}\\hfill\n%\\nobreak\\hbox to\\@pnumwidth{\\hss #2}%\n \\par\n \\penalty\\@highpenalty\n \\addvspace{\\tocaftauthskip}\\endgroup}\n\n\\newdimen\\tocchpnum\n\\newdimen\\tocsecnum\n\\newdimen\\tocsectotal\n\\newdimen\\tocsubsecnum\n\\newdimen\\tocsubsectotal\n\\newdimen\\tocsubsubsecnum\n\\newdimen\\tocsubsubsectotal\n\\newdimen\\tocparanum\n\\newdimen\\tocparatotal\n\\newdimen\\tocsubparanum\n\\tocchpnum=20\\p@            % chapter {\\bf 88.} \\@plus 5.3\\p@\n\\tocsecnum=28.5\\p@          % section 88.8. plus 4.722\\p@\n\\tocsubsecnum=36.5\\p@       % subsection 88.8.8 plus 4.944\\p@\n\\tocsubsubsecnum=43\\p@      % subsubsection 88.8.8.8 plus 4.666\\p@\n\\tocparanum=45\\p@           % paragraph 88.8.8.8.8 plus 3.888\\p@\n\\tocsubparanum=53\\p@        % subparagraph 88.8.8.8.8.8 plus 4.11\\p@\n\\def\\calctocindent{%\n\\tocsectotal=\\tocchpnum\n\\advance\\tocsectotal by\\tocsecnum\n\\tocsubsectotal=\\tocsectotal\n\\advance\\tocsubsectotal by\\tocsubsecnum\n\\tocsubsubsectotal=\\tocsubsectotal\n\\advance\\tocsubsubsectotal by\\tocsubsubsecnum\n\\tocparatotal=\\tocsubsubsectotal\n\\advance\\tocparatotal by\\tocparanum}\n\\calctocindent\n\n\\def\\@dottedtocline#1#2#3#4#5{%\n  \\ifnum #1>\\c@tocdepth \\else\n    \\vskip \\z@ \\@plus.2\\p@\n    {\\leftskip #2\\relax \\rightskip \\@tocrmarg \\advance\\rightskip by \\z@ \\@plus 2cm\n               \\parfillskip -\\rightskip \\pretolerance=10000\n     \\parindent #2\\relax\\@afterindenttrue\n     \\interlinepenalty\\@M\n     \\leavevmode\n     \\@tempdima #3\\relax\n     \\advance\\leftskip \\@tempdima \\null\\nobreak\\hskip -\\leftskip\n     {#4}\\nobreak\n     \\leaders\\hbox{$\\m@th\n        \\mkern \\@dotsep mu\\hbox{.}\\mkern \\@dotsep\n        mu$}\\hfill\n     \\nobreak\n     \\hb@xt@\\@pnumwidth{\\hfil\\normalfont \\normalcolor #5}%\n     \\par}%\n  \\fi}\n%\n\\def\\l@section{\\@dottedtocline{1}{\\tocchpnum}{\\tocsecnum}}\n\\def\\l@subsection{\\@dottedtocline{2}{\\tocsectotal}{\\tocsubsecnum}}\n\\def\\l@subsubsection{\\@dottedtocline{3}{\\tocsubsectotal}{\\tocsubsubsecnum}}\n\\def\\l@paragraph{\\@dottedtocline{4}{\\tocsubsubsectotal}{\\tocparanum}}\n\\def\\l@subparagraph{\\@dottedtocline{5}{\\tocparatotal}{\\tocsubparanum}}\n\n\\renewcommand\\listoffigures{%\n    \\chapter*{\\listfigurename\n      \\markboth{\\listfigurename}{\\listfigurename}}%\n    \\@starttoc{lof}%\n    }\n\n\\renewcommand\\listoftables{%\n    \\chapter*{\\listtablename\n      \\markboth{\\listtablename}{\\listtablename}}%\n    \\@starttoc{lot}%\n    }\n\n\\newenvironment{thecontriblist}\n               {\\par\n                \\addvspace{\\bigskipamount}\n                \\parindent\\z@\n                \\rightskip\\z@ \\@plus 40\\p@\n                \\def\\iand{\\\\[\\medskipamount]\\let\\and=\\nand}%\n                \\def\\nand{\\ifhmode\\unskip\\nobreak\\fi\\ $\\cdot$ }%\n                \\let\\and=\\nand\n                \\def\\at{\\\\\\let\\and=\\iand}%\n                }\n               {\\par\n                \\addvspace{\\bigskipamount}}\n\n\\renewcommand\\footnoterule{%\n    \\kern-3\\p@\n    \\hrule\\@width 36mm\n    \\kern2.6\\p@}\n\n\\newdimen\\foot@parindent\n\\foot@parindent 10.83\\p@\n\\footnotesep 9\\p@\n\n\\AtBeginDocument{%\n\\renewcommand\\@makefntext[1]{%\n    \\parindent 12\\p@\n    \\noindent\n    \\mbox{\\@makefnmark} #1}}\n%\n\\if@spthms\n% Definition of the \"\\spnewtheorem\" command.\n%\n% Usage:\n%\n%     \\spnewtheorem{env_nam}{caption}[within]{cap_font}{body_font}\n% or  \\spnewtheorem{env_nam}[numbered_like]{caption}{cap_font}{body_font}\n% or  \\spnewtheorem*{env_nam}{caption}{cap_font}{body_font}\n%\n% New is \"cap_font\" and \"body_font\". It stands for\n% fontdefinition of the caption and the text itself.\n%\n% \"\\spnewtheorem*\" gives a theorem without number.\n%\n% A defined spnewthoerem environment is used as described\n% by Lamport.\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\def\\@thmcountersep{.}\n\\def\\@thmcounterend{.}\n\\newcommand\\nocaption{\\noexpand\\@gobble}\n\\newdimen\\spthmsep \\spthmsep=3pt\n\n\\def\\spnewtheorem{\\@ifstar{\\@sthm}{\\@Sthm}}\n\n% definition of \\spnewtheorem with number\n\n\\def\\@spnthm#1#2{%\n  \\@ifnextchar[{\\@spxnthm{#1}{#2}}{\\@spynthm{#1}{#2}}}\n\\def\\@Sthm#1{\\@ifnextchar[{\\@spothm{#1}}{\\@spnthm{#1}}}\n\n\\def\\@spxnthm#1#2[#3]#4#5{\\expandafter\\@ifdefinable\\csname #1\\endcsname\n   {\\@definecounter{#1}\\@addtoreset{#1}{#3}%\n   \\expandafter\\xdef\\csname the#1\\endcsname{\\expandafter\\noexpand\n     \\csname the#3\\endcsname \\noexpand\\@thmcountersep \\@thmcounter{#1}}%\n   \\expandafter\\xdef\\csname #1name\\endcsname{#2}%\n   \\global\\@namedef{#1}{\\@spthm{#1}{\\csname #1name\\endcsname}{#4}{#5}}%\n                              \\global\\@namedef{end#1}{\\@endtheorem}}}\n\n\\def\\@spynthm#1#2#3#4{\\expandafter\\@ifdefinable\\csname #1\\endcsname\n   {\\@definecounter{#1}%\n   \\expandafter\\xdef\\csname the#1\\endcsname{\\@thmcounter{#1}}%\n   \\expandafter\\xdef\\csname #1name\\endcsname{#2}%\n   \\global\\@namedef{#1}{\\@spthm{#1}{\\csname #1name\\endcsname}{#3}{#4}}%\n                               \\global\\@namedef{end#1}{\\@endtheorem}}}\n\n\\def\\@spothm#1[#2]#3#4#5{%\n  \\@ifundefined{c@#2}{\\@latexerr{No theorem environment `#2' defined}\\@eha}%\n  {\\expandafter\\@ifdefinable\\csname #1\\endcsname\n  {\\global\\@namedef{the#1}{\\@nameuse{the#2}}%\n  \\expandafter\\xdef\\csname #1name\\endcsname{#3}%\n  \\global\\@namedef{#1}{\\@spthm{#2}{\\csname #1name\\endcsname}{#4}{#5}}%\n  \\global\\@namedef{end#1}{\\@endtheorem}}}}\n\n\\def\\@spthm#1#2#3#4{\\topsep 7\\p@ \\@plus2\\p@ \\@minus4\\p@\n\\labelsep=\\spthmsep\\refstepcounter{#1}%\n\\@ifnextchar[{\\@spythm{#1}{#2}{#3}{#4}}{\\@spxthm{#1}{#2}{#3}{#4}}}\n\n\\def\\@spxthm#1#2#3#4{\\@spbegintheorem{#2}{\\csname the#1\\endcsname}{#3}{#4}%\n                    \\ignorespaces}\n\n\\def\\@spythm#1#2#3#4[#5]{\\@spopargbegintheorem{#2}{\\csname\n       the#1\\endcsname}{#5}{#3}{#4}\\ignorespaces}\n\n\\def\\normalthmheadings{\\def\\@spbegintheorem##1##2##3##4{\\trivlist\n                 \\item[\\hskip\\labelsep{##3##1\\ ##2\\@thmcounterend}]##4}\n\\def\\@spopargbegintheorem##1##2##3##4##5{\\trivlist\n      \\item[\\hskip\\labelsep{##4##1\\ ##2}]{##4(##3)\\@thmcounterend\\ }##5}}\n\\normalthmheadings\n\n\\def\\reversethmheadings{\\def\\@spbegintheorem##1##2##3##4{\\trivlist\n                 \\item[\\hskip\\labelsep{##3##2\\ ##1\\@thmcounterend}]##4}\n\\def\\@spopargbegintheorem##1##2##3##4##5{\\trivlist\n      \\item[\\hskip\\labelsep{##4##2\\ ##1}]{##4(##3)\\@thmcounterend\\ }##5}}\n\n% definition of \\spnewtheorem* without number\n\n\\def\\@sthm#1#2{\\@Ynthm{#1}{#2}}\n\n\\def\\@Ynthm#1#2#3#4{\\expandafter\\@ifdefinable\\csname #1\\endcsname\n   {\\global\\@namedef{#1}{\\@Thm{\\csname #1name\\endcsname}{#3}{#4}}%\n    \\expandafter\\xdef\\csname #1name\\endcsname{#2}%\n    \\global\\@namedef{end#1}{\\@endtheorem}}}\n\n\\def\\@Thm#1#2#3{\\topsep 7\\p@ \\@plus2\\p@ \\@minus4\\p@\n\\@ifnextchar[{\\@Ythm{#1}{#2}{#3}}{\\@Xthm{#1}{#2}{#3}}}\n\n\\def\\@Xthm#1#2#3{\\@Begintheorem{#1}{#2}{#3}\\ignorespaces}\n\n\\def\\@Ythm#1#2#3[#4]{\\@Opargbegintheorem{#1}\n       {#4}{#2}{#3}\\ignorespaces}\n\n\\def\\@Begintheorem#1#2#3{#3\\trivlist\n                           \\item[\\hskip\\labelsep{#2#1\\@thmcounterend}]}\n\n\\def\\@Opargbegintheorem#1#2#3#4{#4\\trivlist\n      \\item[\\hskip\\labelsep{#3#1}]{#3(#2)\\@thmcounterend\\ }}\n\n% initialize theorem environment\n\n\\if@envcntshowhiercnt % show hierarchy counter\n   \\def\\@thmcountersep{.}\n   \\spnewtheorem{theorem}{Theorem}[\\envankh]{\\bfseries}{\\itshape}\n   \\@addtoreset{theorem}{chapter}\n\\else          % theorem counter only\n   \\spnewtheorem{theorem}{Theorem}{\\bfseries}{\\itshape}\n   \\if@envcntreset\n      \\@addtoreset{theorem}{chapter}\n      \\if@envcntresetsect\n         \\@addtoreset{theorem}{section}\n      \\fi\n   \\fi\n\\fi\n\n%definition of divers theorem environments\n\\spnewtheorem*{claim}{Claim}{\\itshape}{\\rmfamily}\n\\spnewtheorem*{proof}{Proof}{\\itshape}{\\rmfamily}\n%\n\\if@envcntsame % all environments like \"Theorem\" - using its counter\n   \\def\\spn@wtheorem#1#2#3#4{\\@spothm{#1}[theorem]{#2}{#3}{#4}}\n\\else % all environments with their own counter\n   \\if@envcntshowhiercnt % show hierarchy counter\n      \\def\\spn@wtheorem#1#2#3#4{\\@spxnthm{#1}{#2}[\\envankh]{#3}{#4}}\n   \\else          % environment counter only\n      \\if@envcntreset % environment counter is reset each section\n         \\if@envcntresetsect\n            \\def\\spn@wtheorem#1#2#3#4{\\@spynthm{#1}{#2}{#3}{#4}\n             \\@addtoreset{#1}{chapter}\\@addtoreset{#1}{section}}\n         \\else\n            \\def\\spn@wtheorem#1#2#3#4{\\@spynthm{#1}{#2}{#3}{#4}\n                                      \\@addtoreset{#1}{chapter}}\n         \\fi\n      \\else\n         \\let\\spn@wtheorem=\\@spynthm\n      \\fi\n   \\fi\n\\fi\n%\n\\let\\spdefaulttheorem=\\spn@wtheorem\n%\n\\spn@wtheorem{case}{Case}{\\itshape}{\\rmfamily}\n\\spn@wtheorem{conjecture}{Conjecture}{\\itshape}{\\rmfamily}\n\\spn@wtheorem{corollary}{Corollary}{\\bfseries}{\\itshape}\n\\spn@wtheorem{definition}{Definition}{\\bfseries}{\\rmfamily}\n\\spn@wtheorem{example}{Example}{\\itshape}{\\rmfamily}\n\\spn@wtheorem{exercise}{Exercise}{\\bfseries}{\\rmfamily}\n\\spn@wtheorem{lemma}{Lemma}{\\bfseries}{\\itshape}\n\\spn@wtheorem{note}{Note}{\\itshape}{\\rmfamily}\n\\spn@wtheorem{problem}{Problem}{\\bfseries}{\\rmfamily}\n\\spn@wtheorem{property}{Property}{\\itshape}{\\rmfamily}\n\\spn@wtheorem{proposition}{Proposition}{\\bfseries}{\\itshape}\n\\spn@wtheorem{question}{Question}{\\itshape}{\\rmfamily}\n\\spn@wtheorem{solution}{Solution}{\\bfseries}{\\rmfamily}\n\\spn@wtheorem{remark}{Remark}{\\itshape}{\\rmfamily}\n%\n\\newenvironment{theopargself}\n    {\\def\\@spopargbegintheorem##1##2##3##4##5{\\trivlist\n         \\item[\\hskip\\labelsep{##4##1\\ ##2}]{##4##3\\@thmcounterend\\ }##5}\n     \\def\\@Opargbegintheorem##1##2##3##4{##4\\trivlist\n         \\item[\\hskip\\labelsep{##3##1}]{##3##2\\@thmcounterend\\ }}}{}\n\\newenvironment{theopargself*}\n    {\\def\\@spopargbegintheorem##1##2##3##4##5{\\trivlist\n         \\item[\\hskip\\labelsep{##4##1\\ ##2}]{\\hspace*{-\\labelsep}##4##3\\@thmcounterend}##5}\n     \\def\\@Opargbegintheorem##1##2##3##4{##4\\trivlist\n         \\item[\\hskip\\labelsep{##3##1}]{\\hspace*{-\\labelsep}##3##2\\@thmcounterend}}}{}\n%\n\\spn@wtheorem{prob}{\\nocaption}{\\bfseries}{\\rmfamily}\n\\newcommand{\\probref}[1]{\\textbf{\\ref{#1}} }\n\\newenvironment{sol}{\\par\\addvspace{6pt}\\noindent\\probref}{\\par\\addvspace{6pt}}\n%\n\\fi\n\n\\def\\@takefromreset#1#2{%\n    \\def\\@tempa{#1}%\n    \\let\\@tempd\\@elt\n    \\def\\@elt##1{%\n        \\def\\@tempb{##1}%\n        \\ifx\\@tempa\\@tempb\\else\n            \\@addtoreset{##1}{#2}%\n        \\fi}%\n    \\expandafter\\expandafter\\let\\expandafter\\@tempc\\csname cl@#2\\endcsname\n    \\expandafter\\def\\csname cl@#2\\endcsname{}%\n    \\@tempc\n    \\let\\@elt\\@tempd}\n\n% redefininition of the captions for \"figure\" and \"table\" environments\n%\n\\@ifundefined{floatlegendstyle}{\\def\\floatlegendstyle{\\bfseries}}{}\n\\def\\floatcounterend{\\enspace}\n\\def\\capstrut{\\vrule\\@width\\z@\\@height\\topskip}\n\\@ifundefined{captionstyle}{\\def\\captionstyle{\\normalfont\\small}}{}\n\\@ifundefined{instindent}{\\newdimen\\instindent}{}\n\n\\long\\def\\@caption#1[#2]#3{\\par\\addcontentsline{\\csname\n  ext@#1\\endcsname}{#1}{\\protect\\numberline{\\csname\n  the#1\\endcsname}{\\ignorespaces #2}}\\begingroup\n    \\@parboxrestore\\if@minipage\\@setminipage\\fi\n    \\@makecaption{\\csname fnum@#1\\endcsname}{\\ignorespaces #3}\\par\n  \\endgroup}\n\n\\def\\twocaptionwidth#1#2{\\def\\first@capwidth{#1}\\def\\second@capwidth{#2}}\n% Default: .46\\textwidth\n\\twocaptionwidth{.46\\textwidth}{.46\\textwidth}\n\n\\def\\leftcaption{\\refstepcounter\\@captype\\@dblarg%\n            {\\@leftcaption\\@captype}}\n\n\\def\\rightcaption{\\refstepcounter\\@captype\\@dblarg%\n            {\\@rightcaption\\@captype}}\n\n\\long\\def\\@leftcaption#1[#2]#3{\\addcontentsline{\\csname\n  ext@#1\\endcsname}{#1}{\\protect\\numberline{\\csname\n  the#1\\endcsname}{\\ignorespaces #2}}\\begingroup\n    \\@parboxrestore\n    \\vskip\\figcapgap\n    \\@maketwocaptions{\\csname fnum@#1\\endcsname}{\\ignorespaces #3}%\n    {\\first@capwidth}\\ignorespaces\\hspace{.073\\textwidth}\\hfill%\n  \\endgroup}\n\n\\long\\def\\@rightcaption#1[#2]#3{\\addcontentsline{\\csname\n  ext@#1\\endcsname}{#1}{\\protect\\numberline{\\csname\n  the#1\\endcsname}{\\ignorespaces #2}}\\begingroup\n    \\@parboxrestore\n    \\@maketwocaptions{\\csname fnum@#1\\endcsname}{\\ignorespaces #3}%\n    {\\second@capwidth}\\par\n  \\endgroup}\n\n\\long\\def\\@maketwocaptions#1#2#3{%\n   \\parbox[t]{#3}{{\\floatlegendstyle #1\\floatcounterend}#2}}\n\n\\def\\fig@pos{l}\n\\newcommand{\\leftfigure}[2][\\fig@pos]{\\makebox[.4635\\textwidth][#1]{#2}}\n\\let\\rightfigure\\leftfigure\n\n\\newdimen\\figgap\\figgap=0.5cm  % hgap between figure and sidecaption\n%\n\\long\\def\\@makesidecaption#1#2{\\@tempdimb=3.6cm\n   \\setbox0=\\vbox{\\hsize=\\@tempdimb\n                  \\captionstyle{\\floatlegendstyle\n                                         #1\\floatcounterend}#2}%\n   \\ifdim\\instindent<\\z@\n      \\ifdim\\ht0>-\\instindent\n         \\advance\\instindent by\\ht0\n         \\typeout{^^JClass-Warning: Legend of \\string\\sidecaption\\space for\n                     \\@captype\\space\\csname the\\@captype\\endcsname\n                  ^^Jis \\the\\instindent\\space taller than the corresponding float -\n                  ^^Jyou'd better switch the environment. }%\n         \\instindent\\z@\n      \\fi\n   \\else\n      \\ifdim\\ht0<\\instindent\n         \\advance\\instindent by-\\ht0\n         \\advance\\instindent by-\\dp0\\relax\n         \\advance\\instindent by\\topskip\n         \\advance\\instindent by-11\\p@\n      \\else\n         \\advance\\instindent by-\\ht0\n         \\instindent=-\\instindent\n         \\typeout{^^JClass-Warning: Legend of \\string\\sidecaption\\space for\n                     \\@captype\\space\\csname the\\@captype\\endcsname\n                  ^^Jis \\the\\instindent\\space taller than the corresponding float -\n                  ^^Jyou'd better switch the environment. }%\n         \\instindent\\z@\n      \\fi\n   \\fi\n   \\parbox[b]{\\@tempdimb}{\\captionstyle{\\floatlegendstyle\n                                        #1\\floatcounterend}#2%\n                          \\ifdim\\instindent>\\z@ \\\\\n                               \\vrule\\@width\\z@\\@height\\instindent\n                                     \\@depth\\z@\n                          \\fi}}\n\\def\\sidecaption{\\@ifnextchar[\\sidec@ption{\\sidec@ption[b]}}\n%\n\\newbox\\bildb@x\n%\n\\def\\sidec@ption[#1]#2\\caption{%\n\\setbox\\bildb@x=\\hbox{\\ignorespaces#2\\unskip}%\n\\if@twocolumn\n \\ifdim\\hsize<\\textwidth\\else\n   \\ifdim\\wd\\bildb@x<\\columnwidth\n      \\typeout{Double column float fits into single column -\n            ^^Jyou'd better switch the environment. }%\n   \\fi\n \\fi\n\\fi\n  \\instindent=\\ht\\bildb@x\n  \\advance\\instindent by\\dp\\bildb@x\n\\if t#1\n\\else\n  \\instindent=-\\instindent\n\\fi\n\\@tempdimb=\\hsize\n\\advance\\@tempdimb by-\\figgap\n\\advance\\@tempdimb by-\\wd\\bildb@x\n\\ifdim\\@tempdimb<3.6cm\n   \\ClassWarning{SVMult}{\\string\\sidecaption: No sufficient room for the legend;\n             ^^Jusing normal \\string\\caption}%\n   \\unhbox\\bildb@x\n   \\let\\@capcommand=\\@caption\n\\else\n%  \\ifdim\\@tempdimb<4.5cm\n%     \\ClassWarning{SVMono}{\\string\\sidecaption: Room for the legend very narrow;\n%              ^^Jusing \\string\\raggedright}%\n      \\toks@\\expandafter{\\captionstyle\\sloppy\n                         \\rightskip=\\z@\\@plus6mm\\relax}%\n      \\def\\captionstyle{\\the\\toks@}%\n%  \\fi\n   \\let\\@capcommand=\\@sidecaption\n%  \\leavevmode\n%  \\unhbox\\bildb@x\n%  \\hfill\n\\fi\n\\refstepcounter\\@captype\n\\@dblarg{\\@capcommand\\@captype}}\n\\long\\def\\@sidecaption#1[#2]#3{\\addcontentsline{\\csname\n  ext@#1\\endcsname}{#1}{\\protect\\numberline{\\csname\n  the#1\\endcsname}{\\ignorespaces #2}}\\begingroup\n    \\@parboxrestore\n    \\@makesidecaption{\\csname fnum@#1\\endcsname}{\\ignorespaces #3}%\n    \\hfill\n    \\unhbox\\bildb@x\n    \\par\n  \\endgroup}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\def\\fig@type{figure}\n\n\\def\\leftlegendglue{\\relax}\n\\newdimen\\figcapgap\\figcapgap=5\\p@   % vgap between figure and caption\n\\newdimen\\tabcapgap\\tabcapgap=3\\p@ % vgap between caption and table\n\n\\long\\def\\@makecaption#1#2{%\n \\captionstyle\n \\ifx\\@captype\\fig@type\n   \\vskip\\figcapgap\n \\fi\n \\setbox\\@tempboxa\\hbox{{\\floatlegendstyle #1\\floatcounterend}%\n \\capstrut #2}%\n \\ifdim \\wd\\@tempboxa >\\hsize\n   {\\floatlegendstyle #1\\floatcounterend}\\capstrut #2\\par\n \\else\n   \\hbox to\\hsize{\\leftlegendglue\\unhbox\\@tempboxa\\hfil}%\n \\fi\n \\ifx\\@captype\\fig@type\\else\n   \\vskip\\tabcapgap\n \\fi}\n\n\\newcounter{merk}\n\n\\def\\endfigure{\\resetsubfig\\end@float}\n\n\\@namedef{endfigure*}{\\resetsubfig\\end@dblfloat}\n\n\\def\\resetsubfig{\\global\\let\\last@subfig=\\undefined}\n\n\\def\\r@setsubfig{\\xdef\\last@subfig{\\number\\value{figure}}%\n\\setcounter{figure}{\\value{merk}}%\n\\setcounter{merk}{0}}\n\n\\def\\subfigures{\\refstepcounter{figure}%\n   \\@tempcnta=\\value{merk}%\n   \\setcounter{merk}{\\value{figure}}%\n   \\setcounter{figure}{\\the\\@tempcnta}%\n   \\def\\thefigure{\\if@numart\\else\\thechapter.\\fi\n   \\@arabic\\c@merk\\alph{figure}}%\n   \\let\\resetsubfig=\\r@setsubfig}\n\n\\def\\samenumber{\\addtocounter{\\@captype}{-1}%\n\\@ifundefined{last@subfig}{}{\\setcounter{merk}{\\last@subfig}}}\n\n% redefinition of the \"bibliography\" environment\n%\n\\def\\biblstarthook#1{\\gdef\\biblst@rthook{#1}}\n%\n\\AtBeginDocument{%\n\\ifx\\chpbibl\\undefined\n  \\def\\bibsection{\\section*{\\refname}\\ifx\\sectionmark\\@gobble\\else\n      \\markright{\\refname}\\fi\n      \\addcontentsline{toc}{section}{\\refname}%\n      \\mtaddtocont{\\protect\\contentsline{mtchap}{\\refname}{\\thepage}\\hyperhrefextend}%\n      \\csname biblst@rthook\\endcsname\\par}\n\\else\n \\def\\bibsection{\\chapter*{\\refname}\\@mkboth{\\refname}{\\refname}%\n     \\addcontentsline{toc}{chapter}{\\refname}%\n     \\csname biblst@rthook\\endcsname\\par}\n\\fi}\n\\ifx\\oribibl\\undefined % Springer way of life\n   \\renewenvironment{thebibliography}[1]{\\bibsection\n         \\global\\let\\biblst@rthook=\\undefined\n         \\def\\@biblabel##1{##1.}\n         \\small\n         \\list{\\@biblabel{\\@arabic\\c@enumiv}}%\n              {\\settowidth\\labelwidth{\\@biblabel{#1}}%\n               \\leftmargin\\labelwidth\n               \\advance\\leftmargin\\labelsep\n               \\if@openbib\n                 \\advance\\leftmargin\\bibindent\n                 \\itemindent -\\bibindent\n                 \\listparindent \\itemindent\n                 \\parsep \\z@\n               \\fi\n               \\usecounter{enumiv}%\n               \\let\\p@enumiv\\@empty\n               \\renewcommand\\theenumiv{\\@arabic\\c@enumiv}}%\n         \\if@openbib\n           \\renewcommand\\newblock{\\par}%\n         \\else\n           \\renewcommand\\newblock{\\hskip .11em \\@plus.33em \\@minus.07em}%\n         \\fi\n         \\sloppy\\clubpenalty4000\\widowpenalty4000%\n         \\sfcode`\\.=\\@m}\n        {\\def\\@noitemerr\n          {\\@latex@warning{Empty `thebibliography' environment}}%\n         \\endlist}\n   \\def\\@lbibitem[#1]#2{\\item[{[#1]}\\hfill]\\if@filesw\n        {\\let\\protect\\noexpand\\immediate\n        \\write\\@auxout{\\string\\bibcite{#2}{#1}}}\\fi\\ignorespaces}\n\\else % original bibliography is required\n   \\let\\bibname=\\refname\n   \\renewenvironment{thebibliography}[1]\n     {\\chapter*{\\bibname\n        \\markboth{\\bibname}{\\bibname}}%\n      \\list{\\@biblabel{\\@arabic\\c@enumiv}}%\n           {\\settowidth\\labelwidth{\\@biblabel{#1}}%\n            \\leftmargin\\labelwidth\n            \\advance\\leftmargin\\labelsep\n            \\@openbib@code\n            \\usecounter{enumiv}%\n            \\let\\p@enumiv\\@empty\n            \\renewcommand\\theenumiv{\\@arabic\\c@enumiv}}%\n      \\sloppy\n      \\clubpenalty4000\n      \\@clubpenalty \\clubpenalty\n      \\widowpenalty4000%\n      \\sfcode`\\.\\@m}\n     {\\def\\@noitemerr\n       {\\@latex@warning{Empty `thebibliography' environment}}%\n      \\endlist}\n\\fi\n\n\\let\\if@threecolind\\iffalse\n\\def\\threecolindex{\\let\\if@threecolind\\iftrue}\n\\def\\indexstarthook#1{\\gdef\\indexst@rthook{#1}}\n\\renewenvironment{theindex}\n               {\\if@twocolumn\n                  \\@restonecolfalse\n                \\else\n                  \\@restonecoltrue\n                \\fi\n                \\columnseprule \\z@\n                \\columnsep 1cc\n                \\@nobreaktrue\n                \\if@threecolind\n                   \\begin{multicols}{3}[\\chapter*{\\indexname}%\n                \\else\n                   \\begin{multicols}{2}[\\chapter*{\\indexname}%\n                \\fi\n                {\\csname indexst@rthook\\endcsname}]%\n                \\global\\let\\indexst@rthook=\\undefined\n                \\markboth{\\indexname}{\\indexname}%\n                \\addcontentsline{toc}{chapter}{\\indexname}%\n                \\parindent\\z@\n                \\rightskip\\z@ \\@plus 40\\p@\n                \\parskip\\z@ \\@plus .3\\p@\\relax\n                \\flushbottom\n                \\let\\item\\@idxitem\n                \\def\\,{\\relax\\ifmmode\\mskip\\thinmuskip\n                             \\else\\hskip0.2em\\ignorespaces\\fi}%\n                \\normalfont\\small}\n               {\\end{multicols}\n                \\global\\let\\if@threecolind\\iffalse\n                \\if@restonecol\\onecolumn\\else\\clearpage\\fi}\n\n\\def\\idxquad{\\hskip 10\\p@}% space that divides entry from number\n\n\\def\\@idxitem{\\par\\setbox0=\\hbox{--\\,--\\,--\\enspace}%\n                  \\hangindent\\wd0\\relax}\n\n\\def\\subitem{\\par\\noindent\\setbox0=\\hbox{--\\enspace}% second order\n                \\kern\\wd0\\setbox0=\\hbox{--\\,--\\,--\\enspace}%\n                \\hangindent\\wd0\\relax}% indexentry\n\n\\def\\subsubitem{\\par\\noindent\\setbox0=\\hbox{--\\,--\\enspace}% third order\n                \\kern\\wd0\\setbox0=\\hbox{--\\,--\\,--\\enspace}%\n                \\hangindent\\wd0\\relax}% indexentry\n\n\\def\\indexspace{\\par \\vskip 10\\p@ \\@plus5\\p@ \\@minus3\\p@\\relax}\n\n% LaTeX does not provide a command to enter the authors institute\n% addresses. The \\institute command is defined here.\n\n\\newcounter{@inst}\n\\newcounter{@auth}\n\\newcounter{auco}\n\\newdimen\\instindent\n\\newbox\\authrun\n\\newtoks\\authorrunning\n\\newtoks\\tocauthor\n\\newbox\\titrun\n\\newtoks\\titlerunning\n\\newtoks\\toctitle\n\n\\def\\clearheadinfo{\\gdef\\@author{No Author Given}%\n                   \\gdef\\@title{No Title Given}%\n                   \\gdef\\@subtitle{}%\n                   \\gdef\\@institute{}%\n                   \\gdef\\@thanks{}%\n                   \\global\\titlerunning={}\\global\\authorrunning={}%\n                   \\global\\toctitle={}\\global\\tocauthor={}}\n\n\\def\\institute#1{\\gdef\\@institute{#1}}\n\n\\def\\title{\\@ifstar\\s@title\\n@title}\n\\def\\s@title#1{\\gdef\\@title{#1}\\ds@numart}\n\\def\\n@title#1{\\gdef\\@title{#1}\\ds@book}\n\n\\def\\institutename\n {\\begingroup\n \\if!\\@institute!\\else\n \\def\\thanks##1{\\unskip{}}%\n \\def\\iand{\\\\[5pt]\\let\\and=\\nand}%\n \\def\\nand{\\ifhmode\\unskip\\nobreak\\fi\\ $\\cdot$ }%\n \\let\\and=\\nand\n \\def\\at{\\\\\\let\\and=\\iand}%\n \\footnotetext[0]{\\kern-\\bibindent\n \\ignorespaces\\@institute}\\vspace{5dd}\\fi\n \\endgroup\n }%\n\n\\def\\@fnsymbol#1{\\ensuremath{\\ifcase#1\\or\\star\\or{\\star\\star}\\or\n   {\\star{\\star}\\star}\\or \\dagger\\or \\ddagger\\or\n   \\mathchar \"278\\or \\mathchar \"27B\\or \\|\\or **\\or \\dagger\\dagger\n   \\or \\ddagger\\ddagger \\else\\@ctrerr\\fi}}\n\n\\def\\inst#1{\\unskip$^{#1}$}\n\\def\\fnmsep{\\unskip$^,$}\n\n\\def\\subtitle#1{\\gdef\\@subtitle{#1}}\n\\clearheadinfo\n\n\\def\\@bfdottedtocline#1#2#3#4#5{%\n  \\ifnum #1>\\c@minitocdepth \\else\n    \\par\n    \\if@minipage\\else\\addvspace{5\\p@}\\fi\n    {\\leftskip #2\\relax \\rightskip \\@tocrmarg \\advance\\rightskip by \\z@ \\@plus 2cm\n               \\parfillskip -\\rightskip \\pretolerance=10000\n     \\parindent #2\\relax\\@afterindenttrue\n     \\interlinepenalty\\@M\n     \\leavevmode\n     \\@tempdima #3\\relax\n     \\advance\\leftskip \\@tempdima \\null\\nobreak\\hskip -\\leftskip\n     {\\bfseries#4}\\nobreak\n     \\leaders\\hbox{$\\m@th\n        \\mkern \\@dotsep mu\\hbox{.}\\mkern \\@dotsep\n        mu$}\\hfill\n     \\nobreak\n     \\hb@xt@\\@pnumwidth{\\hfil\\normalfont \\normalcolor #5}%\n     \\par\\addvspace{5\\p@}}%\n  \\fi}\n\n\\def\\@rmdottedtocline#1#2#3#4#5{%\n  \\ifnum #1>\\c@minitocdepth \\else\n    \\vskip \\z@ \\@plus.2\\p@\n    {\\leftskip #2\\relax \\rightskip \\@tocrmarg \\advance\\rightskip by \\z@ \\@plus 2cm\n               \\parfillskip -\\rightskip \\pretolerance=10000\n     \\parindent #2\\relax\\@afterindenttrue\n     \\interlinepenalty\\@M\n     \\leavevmode\n     \\@tempdima #3\\relax\n     \\advance\\leftskip \\@tempdima \\null\\nobreak\\hskip -\\leftskip\n     {#4}\\nobreak\n     \\leaders\\hbox{$\\m@th\n        \\mkern \\@dotsep mu\\hbox{.}\\mkern \\@dotsep\n        mu$}\\hfill\n     \\nobreak\n     \\hb@xt@\\@pnumwidth{\\hfil\\normalfont \\normalcolor #5}%\n     \\par}%\n  \\fi}\n\n%def\\l@mtchap{\\@bfdottedtocline{1}{\\z@}{\\tocsectotal}}\n\\def\\l@mtchap{\\@rmdottedtocline{1}{\\z@}{\\tocsecnum}}\n\\def\\l@mtsec{\\@rmdottedtocline{1}{\\tocsecnum}{\\tocsubsecnum}}\n\n\\newcounter{contribution}\n\n\\renewcommand\\maketitle{\\par\\startnewpage\n  \\stepcounter{section}%\n  \\setcounter{section}{0}%\n  \\setcounter{subsection}{0}%\n  \\setcounter{figure}{0}\n  \\setcounter{table}{0}\n  \\setcounter{equation}{0}\n  \\setcounter{footnote}{0}%\n  \\if@numart\n     \\stepcounter{chapter}%\n     \\addtocounter{chapter}{-1}%\n  \\else\n     \\refstepcounter{chapter}%\n  \\fi\n  \\stepcounter{contribution}%\n  \\immediate\\write\\@auxout{\\string\\immediate\\string\\closeout\\string\\minitoc}%\n  \\immediate\\write\\@auxout{\\let\\MiniTOC=N}%\n% try to be hyperref-compatible\n  \\csname phantomsection\\endcsname\n  \\begingroup\n    \\parindent=\\z@\n%%%%%%%%%    \\renewcommand\\thefootnote{\\@fnsymbol\\c@footnote}%\n%\n    \\renewcommand\\thefootnote{\\@fnsymbol\\c@footnote}%\n    \\def\\@makefnmark{$^{\\@thefnmark}$}%\n    \\renewcommand\\@makefntext[1]{%\n    \\noindent\n    \\hb@xt@\\bibindent{\\hss\\@makefnmark\\enspace}##1\\vrule height0pt\n    width0pt depth8pt}\n%\n    \\if@twocolumn\n      \\ifnum \\col@number=\\@ne\n        \\@maketitle\n      \\else\n        \\twocolumn[\\@maketitle]%\n      \\fi\n    \\else\n      \\newpage\n      \\global\\@topnum\\z@   % Prevents figures from going at top of page.\n      \\@maketitle\n    \\fi\n    \\@ifundefined{thispagecropped}{}{\\thispagecropped}\n    \\thispagestyle{bchap}\\@thanks\n%\n    \\def\\\\{\\unskip\\ \\ignorespaces}\\def\\inst##1{\\unskip{}}%\n    \\def\\thanks##1{\\unskip{}}\\def\\fnmsep{\\unskip}%\n    \\instindent=\\hsize\n    \\advance\\instindent by-\\headlineindent\n    \\if@numart % keine Nummer\n        \\if!\\the\\toctitle!\\addcontentsline{toc}{title}{\\@title}\\else\n        \\addcontentsline{toc}{title}{\\the\\toctitle}\\fi\n    \\else\n        \\if!\\the\\toctitle!\\addcontentsline{toc}{titlech}{\\protect\\numberline{\\thechapter\\thechapterend}\\@title}\\else\n        \\addcontentsline{toc}{titlech}{\\protect\\numberline{\\thechapter\\thechapterend}\\the\\toctitle}\\fi\n    \\fi\n    \\if@runhead\n       \\if!\\the\\titlerunning!\\else\n         \\edef\\@title{\\the\\titlerunning}%\n       \\fi\n       \\global\\setbox\\titrun=\\hbox{\\small\\rm\\unboldmath\\if@numart\\else\n                                   \\@seccntformat{chapter}\\fi\n                                   \\ignorespaces\\@title}%\n       \\ifdim\\wd\\titrun>\\instindent\n          \\typeout{Title too long for running head. Please supply}%\n          \\typeout{a shorter form with \\string\\titlerunning\\space prior to\n                   \\string\\maketitle}%\n          \\global\\setbox\\titrun=\\hbox{\\small\\rm\n          Title Suppressed Due to Excessive Length}%\n       \\fi\n       \\xdef\\@title{\\copy\\titrun}%\n    \\fi\n%\n    \\if!\\the\\tocauthor!\\relax\n      {\\def\\and{\\noexpand\\protect\\noexpand\\and}%\n      \\protected@xdef\\toc@uthor{\\@author}}%\n    \\else\n      \\def\\\\{\\noexpand\\protect\\noexpand\\newline}%\n      \\protected@xdef\\scratch{\\the\\tocauthor}%\n      \\protected@xdef\\toc@uthor{\\scratch}%\n    \\fi\n    \\addtocontents{toc}{\\noexpand\\protect\\noexpand\\authcount{\\the\\c@auco}}%\n    \\if@numart\n       \\addcontentsline{toc}{author}{\\toc@uthor}%\n    \\else\n       \\addcontentsline{toc}{authorch}{\\toc@uthor}%\n    \\fi\n    \\if@runhead\n       \\if!\\the\\authorrunning!\n         \\value{@inst}=\\value{@auth}%\n         \\setcounter{@auth}{1}%\n       \\else\n         \\edef\\@author{\\the\\authorrunning}%\n       \\fi\n       \\global\\setbox\\authrun=\\hbox{\\small\\unboldmath\\@author\\unskip}%\n       \\ifdim\\wd\\authrun>\\instindent\n          \\typeout{Names of authors too long for running head. Please supply}%\n          \\typeout{a shorter form with \\string\\authorrunning\\space prior to\n                   \\string\\maketitle}%\n          \\global\\setbox\\authrun=\\hbox{\\small\\rm\n          Authors Suppressed Due to Excessive Length}%\n       \\fi\n       \\xdef\\scratch{\\copy\\authrun}%\n       \\markboth{\\scratch}{\\@title}%\n     \\fi\n  \\endgroup\n% \\setcounter{footnote}{0}% footnote starts at (\\inst+1)\n  \\@afterindentfalse\\@afterheading\n  \\clearheadinfo}\n%\n\\def\\@maketitle{\\newpage\n \\markboth{}{}%\n \\def\\lastand{\\ifnum\\value{@inst}=2\\relax\n                 \\unskip{} \\andname\\\n              \\else\n                 \\unskip \\lastandname\\\n              \\fi}%\n \\def\\and{\\stepcounter{@auth}\\relax\n          \\ifnum\\value{@auth}=\\value{@inst}%\n             \\lastand\n          \\else\n             \\unskip,\n          \\fi}%\n  \\raggedright\n {\\chapnumsize\n  \\chapnumstyle\n  \\pretolerance=10000\n  \\let\\\\=\\newline\n% \\@hangfrom{\\@svsec}%\n%%%  \\@svsec\n  \\raggedright\n  \\hyphenpenalty \\@M\n  \\interlinepenalty \\@M\n  \\if@numart\n     \\chap@hangfrom{}%!!!\n  \\else\n     \\chap@hangfrom{\\thechapter\\thechapterend\\hskip\\betweenumberspace}%!!!\n  \\fi\n  \\ignorespaces\n  \\chapsize\n  \\chapstyle\n  \\@title \\par}\\vskip .8cm\n\\if!\\@subtitle!\\else {\\chapnumsize\\chapnumstyle\n  \\vskip -.65cm\n  \\pretolerance=10000\n  \\@subtitle \\par}\\vskip .8cm\\fi\n \\setbox0=\\vbox{\\setcounter{@auth}{1}\\def\\and{\\stepcounter{@auth}}%\n \\def\\thanks##1{}\\@author}%\n \\global\\value{@inst}=\\value{@auth}%\n \\global\\value{auco}=\\value{@auth}%\n \\setcounter{@auth}{1}%\n{\\lineskip .5em\n \\noindent\\ignorespaces\n \\@author\\vskip.35cm}\n \\processmotto % {\\small\\institutename\\par}\n \\institutename\n \\ifdim\\pagetotal>157\\p@\n     \\vskip 11\\p@\n \\else\n     \\@tempdima=168\\p@\\advance\\@tempdima by-\\pagetotal\n     \\vskip\\@tempdima\n \\fi\n}\n\n\\def\\email#1{\\emailname: \\url{#1}}\n\n% Useful environments\n\\newenvironment{abbrsymblist}[1][\\qquad]\n   {\\section*{\\abbrsymbname}\n    \\mtaddtocont{\\protect\\contentsline{mtchap}{\\abbrsymbname}{\\thepage}\\hyperhrefextend}\n    \\begin{description}[#1]}{\\end{description}\\addvspace{10\\p@}}\n%\n\\newenvironment{acknowledgement}{\\par\\addvspace{17\\p@}\\small\\rm\n\\trivlist\\item[\\hskip\\labelsep{\\bfseries\\ackname}]}\n{\\endtrivlist\\addvspace{6\\p@}}\n%\n\\newenvironment{noteadd}{\\par\\addvspace{17\\p@}\\small\\rm\n\\trivlist\\item[\\hskip\\labelsep{\\it\\noteaddname}]}\n{\\endtrivlist\\addvspace{6\\p@}}\n%\n\\DeclareRobustCommand\\abstract{\\@ifstar\\@abstgobl\\@abstract}\n\\def\\@abstract#1{\\noindent\\textbf{\\abstractname} #1\\par\n%\\@afterindentfalse\n%\\@afterheading\n}\n\\def\\@abstgobl#1{\\par\n%\\@afterindentfalse\n%\\@afterheading\n}\n%\n\\newcommand{\\keywords}[1]{\\par\\addvspace\\baselineskip\n\\noindent\\keywordname\\enspace\\ignorespaces#1}\n%\n% define the running headings of a twoside text\n\\def\\runheadsize{\\small}\n\\def\\runheadstyle{\\rmfamily\\upshape}\n\\def\\customizhead{\\hspace{\\headlineindent}}\n\n\\def\\ps@bchap{%\\let\\@mkboth\\@gobbletwo\n     \\let\\@oddhead\\@empty\\let\\@evenhead\\@empty\n     \\def\\@oddfoot{\\reset@font\\small\\hfil\\thepage}%\n     \\let\\@evenfoot\\@oddfoot}\n\n\\def\\ps@headings{\\let\\@mkboth\\markboth\n   \\let\\@oddfoot\\@empty\\let\\@evenfoot\\@empty\n   \\def\\@evenhead{\\runheadsize\\runheadstyle\\rlap{\\thepage}\\hfil\n                  \\leftmark}\n   \\def\\@oddhead{\\runheadsize\\runheadstyle\\rightmark\\hfil\n                  \\llap{\\thepage}}\n   \\def\\chaptermark##1{\\markboth{{\\ifnum\\c@secnumdepth>\\m@ne\n      \\thechapter\\thechapterend\\hskip\\betweenumberspace\\fi ##1}}{{\\ifnum %!!!\n      \\c@secnumdepth>\\m@ne\\thechapter\\thechapterend\\hskip\\betweenumberspace\\fi ##1}}}%!!!\n   \\def\\sectionmark##1{\\markright{{\\ifnum\\c@secnumdepth>\\z@\n      \\thesection\\hskip\\betweenumberspace\\fi ##1}}}}\n\n\\def\\ps@myheadings{\\let\\@mkboth\\@gobbletwo\n   \\let\\@oddfoot\\@empty\\let\\@evenfoot\\@empty\n   \\def\\@evenhead{\\runheadsize\\runheadstyle\\rlap{\\thepage}\\hfil\n                  \\leftmark}\n   \\def\\@oddhead{\\runheadsize\\runheadstyle\\rightmark\\hfil\n                  \\llap{\\thepage}}\n   \\let\\chaptermark\\@gobble\n   \\let\\sectionmark\\@gobble\n   \\let\\subsectionmark\\@gobble}\n\n\\if@runhead\\ps@myheadings\\else\n\\ps@empty\\fi\n\n\\endinput\n%end of file svmult.cls\n"
  },
  {
    "path": "titlepage.tex",
    "content": "\\onecolumn\n\\begin{titlepage}\n\n\\url{https://github.com/soulmachine/machine-learning-cheat-sheet}\n\n\\end{titlepage}\n\n\\newpage\n\n\\noindent \\textcopyright  2013 soulmachine \\\\\nExcept where otherwise noted, This document is licensed under a Creative Commons \nAttribution-ShareAlike 3.0 Unported (CC BY-SA3.0) license \\\\ (\\url{http://creativecommons.org/licenses/by/3.0/}).\n"
  }
]