% 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[12pt,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}{10in} \setlength{\textwidth}{7in}
%\setlength{\columnsep}{0.3125in} \setlength{\topmargin}{0in}
\setlength{\headheight}{0in} \setlength{\headsep}{-1in}
\setlength{\parindent}{1pc}
\setlength{\oddsidemargin}{-.5in}  % Centers text.
\setlength{\evensidemargin}{-.5in}

% 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}

% Make title bold and 14 pt font (Latex default is non-bold, 16pt)
\title{Stat 471: Lecture 13\\
Monte-Carlo Inference.}
% 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 Quantile function. For given probability $\alpha$, the
quantile is the point $q$ such that $q_{\alpha}=F^{-1}(\alpha)$.
In lecture 11, we showed how to estimate the CDF based on
Monte-Carlo integration. It was shown that $F(x)$ can be estimated
by $\sum_{i=1}^n \mathbb{I}_{X_i \leq x}/n$, i.e. the proportion
of random sample that is smaller than $x$. Now consider the order
statistics $X_{(i)}$ of $X_i$. If $X_{(j)} \leq x< X_{(j+1)}$,
there are $j$ samples that are smaller than $x$ so $F(x)=j/n$.
Given $j/n \leq \alpha < (j+1)/n$, $q_{\alpha} \approx X_{(j)}$.
\begin{verbatim}
function q=quantile(x,p)
sorted=sort(x);
q=sorted(round(size(x,1)*p));
\end{verbatim}
A different possibly more sophisticated estimation can be found in
Frigge {\em et al.} (1989) The American Statistician. {\bf
43}:50-54.
 \item We are interested in testing if
the arm strength $x_i$ of the construction workers is 80 pounds
(load strength.data). Let $\mu$ be the mean arm strength. Then
$$H_0: \mu = 80 \mbox{ vs. } H_1: \mu \neq 80.$$
If $x_i$ are from normal, under $H_0$, the appropriate test
statistic is $t$-statistic
$$T= \frac{\bar X - \mu}{S/\sqrt{n}} \sim t_{n-1}.$$

We reject $H_0$ if $T$ is either large or small. Suppose $P(-c <T<
c) = \alpha$. We reject $H_0$ if $|t| > c$ with $100(1-\alpha) \%$
significance. Assume that you do not know the distributional form
of $T$ in which case you do now know the value of $c$ and in turn
there is no inference.
\begin{figure}
\centering
\includegraphics[scale=0.32]{lecture13-1.eps}
\end{figure}
\item From QQ-plot, the arm strength data $x_i$ seems to follow
$N(\mu,\sigma)$ so we use $N(\mu,\sigma)$ as the
pseudo-population. We generate $m$ random samples from the
pseudo-population and compute $T$ statistic for each random
sample.
\begin{verbatim}
n=size(arm,1); m=10000; t=zeros(m,1);
 mu=mean(arm); sigma=std(arm);
>>[mu sigma]
ans =
   78.7517   21.1093
>>tob =(mu-80)/(sigma/sqrt(n))
tob =
   -0.7170
 for i=1:m x=sigma*snrnd(n)+mu;
t(i)=(mean(x) - 80)/(sigma/sqrt(n));
 end;
>> quantile(t,[0.05 0.95])
ans =
   -2.3720 0.9107
>> normcdf([-1.65, 1.65])
ans =
    0.0495 0.9509
\end{verbatim}
\end{document}
for i=1:m
 x=normrnd(mu,sigma,n,1);
 t(i)=(mean(x)-80)/(sigma/sqrt(n));
 end;
