% 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} %,twocolumn
%\usepackage[dvips]{graphicx,graphics}
%\usepackage{times,amsmath,amsfonts}

% Use following instead for LaTex 2.09 (may need some other mods as well).
% \documentstyle[times,twocolumn]{article}

% Set dimensions of columns, gap between columns, and paragraph indent
\setlength{\textheight}{9.9in} \setlength{\textwidth}{6.9in}
%\setlength{\columnsep}{0.3125in} \setlength{\topmargin}{0in}
\setlength{\headheight}{0in} \setlength{\headsep}{-1in}
\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{\diff}[1] {\frac{\partial}{\partial #1}}
\newcommand{\jacob}[3]{\frac{\partial^2 #3}{\partial #1 \partial #2}}
\newcommand{\der}[2]{\frac{\partial #2}{\partial #1}}
\begin{document}

% Don't want date printed
%\date{January 23, 2003}

% Make title bold and 14 pt font (Latex default is non-bold, 16pt)
\title{Stat 471 Massive Data:\\
Two-sample $t$ test example}

% For single author (just remove % characters)
\author{Moo K. Chung\\
mchung@stat.wisc.edu}
%\date{Feb 20, 2003}
% For two authors (default example)
\maketitle \thispagestyle{empty} 

\subsection*{Two-sample $t$ test with unequal variance}
In some situation it is impossible to load whole data
into $\tt{MATLAB}$ or $\tt{R}$ due to the shear size of massive data.
One example would be the 3D magnetic resonance images of the human brain.
A Brain image $I$ is basically 3D array of size $200^3$. 

Even if there are
only 30 brain images, it would not be easy to load them into statistical package and do relevent statistical package unless you have huge computer memory. For instance, suppose we have $m$ brain images $I_1,\cdots,I_m$ from normal population and $n$ brain images $J_1,\cdots,J_n$ from autistic patients. If you are interested in comparing the two population means, two sample $t$ test is needed. To compute the two sample $t$ statistic, the sample means and the variances are needed. So you may tempted to compute the sample mean for normal population in the following way:
\begin{verbatim}
for i=1:m
  I(i) = load control_i
end

\end{verbatim}

However, this is not a good way. A beter appraoach is to use
$$\bar I= \frac{1}{m}\sum_{i=1}^m I_i = \frac{1}{m} (I_m + \sum_{i=1}^{m-1} I_i)$$

$$S_I^2=  \frac{1}{m-1}\Big((I_m -\bar I)^2 + \sum_{i=1}^{m-1} (I_i-\bar I)^2\Big)$$

\begin{enumerate}
\item Pooled sample variance:
$$S_p^2 = \frac{(n-1)S_X^2 + (m-1)S_Y^2}{n+m-2}.$$

\item Let $X_1,\cdots,X_n$ and $Y_1,\cdots,Y_m$ be two independent
samples from normal distributions with the same population
variance. The test statistic for testing
$$H_0: \mu_X = \mu_Y \mbox{ vs. } H_1: \mu_X \neq \mu_Y$$
$$T=\frac{\bar X - \bar Y -(\mu_X -\mu_Y)}{S_p\sqrt{1/n + 1/m}} \sim t_{n+m-2}.$$
Reject $H_0$ if $|T| > t_{\alpha/2,n+m-2}$.

\end{enumerate}
\subsection*{In-class problems}  {\em Example 1.} A study
was conducted to compare the weights of cats and dogs. Weights of
cats: 20, 21, 35, 13, 21, 10. Weights of dogs: 31, 10, 20, 40.
Assume that the population variance to be same for both cats and
dogs. Is there any difference between the weights of cats and
dogs?
\begin{verbatim}
> x<-c(20,21,35,13,21,10)
> y<-c(31,10,20,40)
\end{verbatim}
If you use R, it is very easy to do two sample hypothesis testing.
\begin{verbatim}
>t.test(x,y,alternative="two.sided",
var.equal=TRUE,conf.level=0.9)
        Two Sample t-test
data:x and y t = -0.7725, df = 8,
p-value = 0.462 alternative
hypothesis: true difference in means is not equal to 0 90 percent
confidence interval:
 -17.88739   7.38739

>t.test(x,y,alternative="two.sided",
conf.level=0.9)
        Welch Two Sample t-test
data:x and y t = -0.7073,df = 4.778,
p-value = 0.5124 alternative
hypothesis: true difference in means is not equal to 0 90 percent
confidence interval:
 -20.361647   9.861647
\end{verbatim}

\subsection*{Self-study problems} Compute a CI for $\mu_X - \mu_Y$
in Example 1. Please read p. 370. section Pooled $t$-Procures.
Example 9.6., 9.7. using Concept 2.

\end{document}
