% 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[11pt,twocolumn]{article} %
\usepackage[dvips]{graphicx,graphics,color}
\usepackage{times,amsmath,amsfonts}

\setlength{\textheight}{10in} \setlength{\textwidth}{6.875in}
\setlength{\columnsep}{0.3125in} \setlength{\topmargin}{-0.5in}
\setlength{\headheight}{0in} \setlength{\headsep}{0in}
\setlength{\parindent}{1pc}
\setlength{\oddsidemargin}{-.2in}  % Centers text.
\setlength{\evensidemargin}{-.2in}

% Add the period after section numbers.  Adjust spacing.
\newcommand{\Section}[1]{\vspace{-8pt}\section{\hskip -1em.~~#1}\vspace{-3pt}}
\newcommand{\SubSection}[1]{\vspace{-3pt}\subsection{\hskip -1em.~~#1}
        \vspace{-3pt}}
\newcommand{\bqn}{\begin{eqnarray}}
\newcommand{\eqn}{\end{eqnarray}}
\newcommand{\bq}{\begin{eqnarray*}}
\newcommand{\eq}{\end{eqnarray*}}
\begin{document}

% Don't want date printed
\date{March 8, 2005}

% Make title bold and 14 pt font (Latex default is non-bold, 16pt)
\title{Stat 324: Lecture 12\\
Correlation}

% For single author (just remove % characters)
\author{Moo K. Chung\\
mchung@stat.wisc.edu}

% For two authors (default example)
\maketitle \thispagestyle{empty}

\section*{Concepts}
\begin{enumerate}


\item The {\em conditional probability density} of $Y$ given $X=x$ is
defined as $$f_{Y|X}(y|x) = \frac{f(x,y)}{f_X(x)}.$$ The {\em
conditional expectation} of $Y$ given $X=x$ is $$\mathbb{E}
(Y|X=x)=\int_{-\infty}^{\infty} yf_{Y|X}(y|x)\;dy.$$

\item The covariance between $X$ and $Y$ is
$${\bf Cov} (X,Y) = \mathbb{E} (X-\mu_x)(Y-\mu_y),$$
where $\mu_x = \mathbb{E} X, \mu_y = \mathbb{E} Y$.

{\em Example.} Mathematical achievement test scores ($x_i$) and
calculus grades
($y_i$) for 10 college freshmen?\\
x$\|39,43,21,64,57,47,28,75,34,52$\\
y$\|65,78,52,82,92,89,73,98,56,75$\\
We will assume $p(x_i,y_i) = 0.1$ and $p(x_i,x_j)=0$ for $i \neq j$.

\begin{verbatim}
> x<-c(39,43,21,64,57,47,28,75,34,52)
> y<-c(65,78,52,82,92,89,73,98,56,75)
> sum(x*y)/10-mean(x)*mean(y)
[1] 189.4
\end{verbatim}

\item {\em Correlation coefficient} is given by $$\rho(X,Y) =
\frac{{\bf Cov}(X,Y)}{\sqrt{{\bf Var}(X){\bf Var}(Y)}}$$.
\begin{verbatim}
> mean(x^2)-mean(x)^2
[1] 247.4
> mean(y^2)-mean(y)^2
[1] 205.6
> 189.4/(sqrt(247.4)*sqrt(205.6))
[1] 0.8397859
> cor(x,y)
[1] 0.8397859
\end{verbatim}

{\em Example.} Negative correlation. The number of
times you miss submitting homeworks ($x_i$) and the final grade ($y_i$)?\\
x$\|03,04, 01,02,01,00,00,07,08,05$\\
y$\|70,75,80,75,85,95,90,70,50,60$
\begin{verbatim}
> x<-c(03,04, 01,02,01,00,00,07,08,05)
> y<-c(70,75,80,75,85,95,90,70,50,60)
> cor(x,y)
[1] -0.8938321
\end{verbatim}

\begin{figure}[t]
\centering
\renewcommand{\baselinestretch}{1}
\includegraphics[scale=0.3]{324.12.01.ps}
\includegraphics[scale=0.3]{324.12.02.ps}
\caption{Left: calculus grade example showing positive correlation.
Right: missing homework example showing negative correlation.}
\end{figure}

\item $${\bf Cov} (aX+b,cY+d) = ac {\bf Cov} (X,Y).$$
$${\bf Cov} (X,X)
= \mathbb{V} X.$$
$$\rho(aX+b,cY+d) = \rho(X,Y).$$

\end{enumerate}

\section*{Problems}
\begin{enumerate}
\item Suppose that the joint distribution of $X$ and $Y$ is a uniform distribution over $x^2 + y^2 \leq 1$. Determine the correlation coefficient of $X$ and $Y$.\\
{\em Solution.} The joint density is $f(x,y)= \frac{1}{\pi}$,for
$(x,y) \in \{(x,y)|x^2 + y^2 \leq 1\}$ and 0 otherwise. The marginal
density is
$$ f_X(x) =\int_{-\sqrt{1-x^2}}^{\sqrt{1-x^2}} \frac{1}{\pi} \; dy
           = \frac{2\sqrt{1-x^2}}{\pi}, -1 \leq x \leq 1.$$
Since $f_X(x)$ is an even function, $xf_X(x)$ is odd so from
symmetry, $\mathbb{E}X = 0$. Similarly, $\mathbb{E}Y=0$. Also you
should be able to show $\mathbb{E}(XY) = 0$. Therefore, $\rho = 0$.

\item Suppose that $X$ and $Y$ are identically distributed Bernoulli random variables with parameter $0< p < 1$ such that ${\bf Cov}(X,Y) = 0$. Show that $X$ and $Y$ are independent.\\
{\em solution.} The condition ${\bf Cov}(X,Y)=0$ is equivalent to $P(X=1,Y=1)=P(X=1)P(Y=1)=p^2$. Then it follows $P(X=1,Y=0)=P(X=1)-P(X=1,Y=1)= p(1-p)=P(X=1)P(Y=0)$ and similarly for other cases.
So we have $P(X=i,Y=j) = P(X=i)P(Y=j) \mbox{ for all } i,j =0,1.\\

\item For random variables $X$ and $Y$, prove or disprove that
$X$ and $Y-\mathbb{E}(Y|X)$ are correlated. \\
{\it Solution.} \bq {\bf cov}(X,Y-\mathbb{E}(Y|X)) &=&
\mathbb{E}\{X(Y-E(Y|X))\}
-\mathbb{E}(X)\mathbb{E}\{Y-\mathbb{E}(Y|X)\} \\
&=& \mathbb{E}(XY)-\mathbb{E}\{X\mathbb{E}(Y|X)\}-\mathbb{E}(X)\mathbb{E}(Y) + \mathbb{E}(X)\mathbb{E}\{\mathbb{E}(Y|X)\} \\
&=&\mathbb{E}(XY)-\mathbb{E}\{\mathbb{E}(XY|X)\}
-\mathbb{E}(X)\mathbb{E}(Y) + \mathbb{E}(X)\mathbb{E}(Y) =0\eq

\end{enumerate}
{\bf Assigned Problems:} Please read Chapter 5. Exercise 5.32.,
5.36. Second midterm is tentatively scheduled to be on April 5th. It
will cover from Lecture 1.
\end{document}
