% This is a simple LaTex sample document that gives a submission format
%   for IEEE PAMI-TC conference submissions.  Use at your own risk.
% Make two column format for LaTex 2e.\
\documentclass[10pt,twocolumn]{article} %,twocolumn
\usepackage{times,amsmath,amsfonts}

% Use following instead for LaTex 2.09 (may need some other mods as well).
%\documentstyle[times,twocolumn]{article}
\usepackage[dvips]{graphicx,graphics}
% Set dimensions of columns, gap between columns, and paragraph indent
\setlength{\textheight}{10.5in} \setlength{\textwidth}{7.6in}
%\setlength{\columnsep}{0.3125in} \setlength{\topmargin}{0in}
\setlength{\headheight}{0in} \setlength{\headsep}{-1in}
\setlength{\parindent}{1pc}
\setlength{\oddsidemargin}{-0.6in}  % Centers text.
\setlength{\evensidemargin}{-0.5in}

% Add the period after section numbers.  Adjust spacing.
\newcommand{\Section}[1]{\vspace{-5pt}\section{\hskip -1em.~~#1}\vspace{-3pt}}
\newcommand{\SubSection}[1]{\vspace{-2pt}\subsection{\hskip -1em.~~#1}
        \vspace{-3pt}}
\newcommand{\bqn}{\begin{eqnarray*}}
\newcommand{\eqn}{\end{eqnarray*}}
\newcommand{\bq}{\begin{eqnarray}}
\newcommand{\eq}{\end{eqnarray}}

\begin{document}

% Make title bold and 14 pt font (Latex default is non-bold, 16pt)
\title{Stat 471: Lecture 28\\
Bivariate smoothing.}
% For single author (just remove % characters)
\author{Moo K. Chung\\
mchung@stat.wisc.edu}
% For two authors (default example)
\maketitle \thispagestyle{empty}
\begin{enumerate}
\item We studied how to simulate scalar, vector data. To simulate
continues stochastic processes (lecture 29), we need a concept of
smoothing. Let us study kernel smoothing in $\mathbb{R}^k$. Let
$y_1,\cdots,y_m$ be the neighboring data in close proximity to
data $y_0$. Then Nadaraya-Watson version (1964) of kernel
smoothing is defined as mapping
$$ y_0 \to \sum_{i=0}^m w_iy_i$$
where $\sum_{i=0} ^m w_i =1$. We need to choose $w_i$ such that
$w_i$ measures the contribution of data $y_i$. The contribution
should be decrease as the distance between $y_i$ and $y_0$
increases. So our first guess in designing kernel would be to use
$$w_i(y_i,y_0) = \exp \Big(-\frac{\|y_i - y_0\|}{2\sigma^2} \Big).$$
It guarantee the condition that the contribution of data $y_i$
decreases but it will not make the total sum of weights equal to
1. So we normalized it such that

$$ w_i(y_i,y_0) = \frac{\exp \big(-\frac{\|y_i - y_0\|}{2\sigma^2} \big)}
{\sum_{i=0}^m \exp \big(-\frac{\|y_i - y_0\|}{2\sigma^2}\big)}.$$
$\sigma^2$ controls the amount of smoothing.

\item Suppose we have spatial data $y_i$ collected at point $p_i$.
We assume the following bivariate  model
$$Y_i = g(p_i,\sigma^2) + \epsilon_i$$
where we assume $\epsilon_i$ are iid. We are interested in
estimating $g$. We estimate $g$ by performing the bivariate kernel
smoothing.
\begin{figure}
\centering
\renewcommand{\baselinestretch}{1}
\includegraphics[scale=0.37]{lecture28-1.eps}
\includegraphics[scale=0.25]{lecture28-3.eps}
\includegraphics[scale=0.37]{lecture28-4.eps}
\includegraphics[scale=0.32]{lecture28-5.eps}
\end{figure}
\begin{verbatim}
[px,py] = meshgrid([-3:0.1:3]);
g = px.*exp(-px.^2-py.^2);
mesh(g);
e=normrnd(0,0.2,61,61);
y=g+e;
kernel=inline('exp(-(x.^2+y.^2)/2)')
dx=kron(ones(3,1),[-1:1])
dy=kron(ones(1,3),[-1:1]')
>>weight=kernel(dx,dy)/sum(sum(kernel(dx,dy)))
    0.0751    0.1238    0.0751
    0.1238    0.2042    0.1238
    0.0751    0.1238    0.0751
temp_y=y;
for i=1:10
   smooth_y=conv2(temp_y, weight,'same');
   temp_y=smooth_y;
end;
\end{verbatim}

\end{enumerate}
\end{document}
