% Make two column format for LaTex 2e.
\documentclass[11pt]{article}
%\usepackage[dvips]{graphicx,graphics}
\usepackage{times,amsmath,amsfonts}

\newcommand{\bqn}{\begin{eqnarray*}}
\newcommand{\eqn}{\end{eqnarray*}}

% Set dimensions of columns, gap between columns, and paragraph indent
\setlength{\textheight}{9in} \setlength{\textwidth}{6.875in}
%\setlength{\columnsep}{0.3125in} \setlength{\topmargin}{0in}
\setlength{\headheight}{0in} \setlength{\headsep}{-1in}
\setlength{\parindent}{1pc}
\setlength{\oddsidemargin}{-.1875in}  % Centers text.
\setlength{\evensidemargin}{-.1875in}

% 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}}
\title{Stat312: Midterm Exam II.}
% For single author (just remove % characters)
\author{Moo K. Chung, Tao Yu\\
mchung@stat.wisc.edu, yutao@stat.wisc.edu} \maketitle
\thispagestyle{empty}
\begin{document}

\begin{enumerate}
\item The amount of lateral expansion was determined for a sample
of 15 pulsed-power gas metal arc weld used in LNG ship containment
tanks. The measurements and necessary {\tt R} output are given
below. Assuming normality, derive a 99\% confidence interval for
population standard deviation $\sigma$ [5pts].
\begin{verbatim}
> mean(Y)
[1] 24.73333
> var(Y)
[1] 10.78095
> qchisq(c(0.005, 0.01, 0.995, 0.99), 15)
[1] 4.60  5.23  32.80  30.58
> qchisq(c(0.005,0.01, 0.995, 0.99), 14)
[1] 4.07  4.66  31.32  29.14
\end{verbatim}

{\em Solution.} $(n-1)S^2/\sigma^2 \sim \chi_{n-1}^2$.
$\alpha=0.01$. To construct a $99\%$ CI for $\sigma^2$, we need to
compute critical values $\chi_{\alpha/2,n-1}^2 = {\tt
qchisq(0.005,14)}=4.07$ and $\chi_{1-\alpha/2,n-1}^2 = {\tt
qchisq(0.995,14)}=31.32$. Then $99 \%$ CI for $\sigma^2$ is
$$ \Big(\frac{(n-1)}{\chi_{1-\alpha/2,n-1}^2}s^2, \frac{(n-1)}{\chi_{\alpha/2,n-1}^2}s^2\Big)\\
=\Big(\frac{14}{31.32}10.78, \frac{14}{4.07}10.78\Big) = (4.82,
37.08)$$ and $99\%$ CI for $\sigma$ is
$$(\sqrt{4.82}, \sqrt{37.08}) = (2.20, 6.09).$$

\item Consider a sample of fat content of 100 randomly selected
hotdogs. We have following observations: $\bar x = 22, S^2=10^2$. We
are interested in checking if the fat content is 24.
\begin{verbatim}
> qnorm((1:10)/200)
[1] -2.57 -2.33 -2.17 -2.05 -1.96 -1.88 -1.81 -1.75 -1.6 -1.64
> qt((1:10)/200,99)
[1] -2.63 -2.36 -2.20 -2.08 -1.98 -1.90 -1.83 -1.77 -1.71 -1.66
\end{verbatim}
\begin{itemize}
\item[(1)] What is a test statistic and it's distribution under the null assumption? [5pts].

\item[(2)] What is the rejection region at level $0.01$? Perform the test if the fat content is 24 at level
$0.01$ [5pts].
\item[(3)] What is the type II error of the previous test
when the actual fat content of hotdogs is 23? Express your answer
using function $\Phi$, which is defined as $\Phi(y)
=\int_{-\infty}^y \frac{1}{\sqrt{2\pi}}e^{-y^2/2}\;dy$ [5pts].
\end{itemize}
{\em Solution.} (1) The proper hypotheses are $$H_0: \mu = 24 \mbox{
vs. } H_1: \mu \neq 24.$$ Since we have large sample ($n=100$) with
no assumption on the sample distribution, we use $Z = \bar X - 24$
as a test statistic. Under $H_0$, $Z \sim N(0,1)$. (2) We reject
$H_0$ if $|\bar X - 24| > z_{\alpha/2} = z_{0.005}=-{\tt
qnorm}(0.005)=2.57$. So the rejection region is $R=(-\infty, -2.57)
\bigcup (2.57,\infty)$. Since $Z=22-24=-2 \notin R$, we do not
reject $H_0$. (3) \bqn \beta(23) &=& P(\mbox{ not reject }
H_0|\mu=23)
= P(-2.57 <\bar X - 24 < 2.57|\mu = 23)\\
&=& P(-1.57 <\bar X - 23 < 3.57) \mbox{ when } \mathbb{E} X_i =
23\\
&=& \Phi(3.57) - \Phi(-1.57)\eqn


\item When you toss a coin 100 times, you observed 40 heads.
\begin{itemize}
\item[(1)] Construct a 99$\%$ confidence interval for the
probability of getting head [5pts].
\newpage
\item[(2)] Test if the coin is biased at level 0.01 [5pts].
\end{itemize}
{\em Solution.} (1) Let $p$ be the probability of getting head. Let
$X_i$ be the number of head when we toss the coin $i$-th time. Then
$\hat p = \bar x = 0.4$. $$\frac{\bar X - p}{\sqrt{\hat p(1-\hat
p)/100}} \sim N(0,1).$$ So the $100(1-\alpha)\%$ CI for $p$ is
$$\bar x \pm z_{\alpha/2}\sqrt{\hat p(1-\hat p)/100}
= 0.4 \pm 2.57 \sqrt{0.4(1-0.4)/100} = 0.4 \pm 0.126$$
\end{enumerate}
\end{document}
