\chapter{Statistics of Sampling}

\specialsection{Introduction}
The idea of taking a random sample of likely voters and asking 
them their voting preferences in order to understand the possible 
outcome of an upcoming political election is possibly even over-familiar 
from recent Presidential and Congressional campaigns.  The idea that 
the process of taking a collection of measurements in a scientific 
experiment is actually quite analogous to the process 
of selecting a sample from a population of potential voters  
might be less familiar.  But as we will see in this chapter, this analogy 
is quite powerful and useful.  The analogy is probably clearest when we 
are collecting measurements from a sample of organisms selected from
population in the wild.  We have seen a number of examples of datasets
of this type in previous chapters.  But even measurements
in a lab experiment can be thought of as a sample from the ``population''
of all possible measurements of the quantity being measured.  

In this chapter we will develop some of the theory underlying 
methods for making inferences about a population from the 
information contained in a sample.  This theory will be applied in the 
next chapter to develop the framework of hypothesis testing using
data.  

\specialsection{Models of Sampling}
\index{sampling|(}
\subsection*{Sampling to Estimate a Proportion}
Suppose we have a population of $N$ individuals and each one of
them either has a certain characteristic or does not.  Think, for example, of 
the characteristic that the individual will vote for the candidate of one specified party
in an upcoming election.  If $n_1$ individuals out of the total population
have the characteristic and $n_2$ do not, so $n_1 + n_2 = N$, then by what we
said in Chapter 10, the fractions
$$p = \frac{n_1}{N} \quad {\rm and} \quad q = \frac{n_2}{N}$$
would represent the probabilities that a single individual
chosen from the population at random will have the characteristic, or 
respectively, will not have the characteristic.
The process of selecting a single individual and determining 
whether or not the characteristic is present is modeled by one of the random variables
\index{Bernoulli trial}
\index{distribution!Bernoulli trial}
\index{random variable!Bernoulli trial}
called \emph{Bernoulli trials} in Chapter 10.\footnote{We usually think
the ``success'' outcome represents having the particular characteristic in this
context.}

The sampling done in public opinion polling, for instance, consists
of choosing some sample of $n$ individuals out of the total population
of $n$ and determining their voting preferences.  Saying the sample is
(perfectly) \emph{random} means that every set of $n$ individuals drawn
from the population has 
(exactly) the same probability of being selected.  As you might imagine 
this is not an easy condition to enforce or verify in practice.  But
it is a necessary condition for the validity of the methods we will
discuss.   

If $m_1$ out of the $n$
individuals \emph{in the sample} have the particular characteristic (e.g. intending
to vote Democratic), then we would usually use the fraction $\frac{m_1}{n}$ as
an \emph{estimator} for $p = \frac{n_1}{N}$.  Statisticians frequently 
use notation like this to indicate an \emph{estimator} for the population
\index{estimator}
parameter:
$$\framebox{$\hat{p} = \frac{m_1}{n} {\rm\ is\ an\ estimator\ for\ } p = \frac{n_1}{N}$.}$$
The most important thing to realize here is that, as we saw in the Chapter Project for Chapter 9, 
$\hat{p}$ \emph{depends on which sample we take}.  In other words, $\hat{p}$
is also \emph{a random variable}, with an associated probability distribution for  
the possible values we would observe from repeated samples with that sample size
$n$.  

What is that probability distribution?  
The sampling process would almost always be equivalent to drawing $n$ balls from an 
urn containing $N = n_1 + n_2$ balls \emph{without replacement}: in the public opinion 
polling context, for instance, it makes no sense to allow the same person to 
be asked his or her opinion more than once.  So, strictly speaking, we would would
have a scaled version of a random variable with a \emph{hypergeometric} probability distribution 
\index{hypergeometric distribution}
\index{distribution!hypergeometric}
\index{random variable!hypergeometric}
\index{without replacement}
as given in \eqref{eq:hypergeom} -- ``scaled'' since the values are not just the 
numbers of successes, but rather the fractions $\frac{m_1}{n}$. But note that
$$P(m_1\ {\rm successes}) = P\left(\hat{p} = \frac{m_1}{n}\right),$$
so we are in almost the same situation we described before.
  
However, as long as the sample size $n$ is small relative to the population size $N$, 
then as we discussed in \S 2 of Chapter 10, a \emph{binomial} probability distribution,
corresponding to doing the selection process \emph{with replacement},
would also be a good approximation.  This approximation is typically used 
to understand probabilities in this situation because
the binomial random variables are somewhat simpler to work with than the hypergeometric
ones.  
\index{with replacement}
\index{binomial distribution}
\index{distribution!binomial}
\index{random variable!binomial}

Since $m_1$ is the number of ``successes'' in the $n$ Bernoulli trials, note that
we can also describe the random variable $\hat{p}$ as the \emph{mean}, or average,
\index{mean}
\index{expected value}
of the Bernoulli trials corresponding to the individuals in the sample.  This means
that we can use the result of Theorem~\ref{IIDFacts} to determine the 
expected value and the variance or SD of $\hat{p}$.  Since a single Bernoulli
\index{variance}
\index{standard deviation (SD)}
trial $Y$ with success probability $p$ has $E(Y) = p$ and $V(Y) = p - p^2 = pq$, 
and we are averaging $n$ different Bernoulli trials with identical distributions, then
as long as the trials are independent, we have 
$$\framebox{$\displaystyle E(\hat{p}) = p \quad {\rm and} \quad V(\hat{p}) = \frac{pq}{n}$.}$$
In this context, another name is usually used for the \emph{SD of the estimator}.  We
call this the \emph{standard error}.  Hence here
\begin{equation}
\label{eq:SEhatp}
\framebox{$\displaystyle {\rm standard\ error\ (of\ }\hat{p}{\rm )} = SE = \sqrt{\frac{pq}{n}}$.}
\index{standard error (SE)}
\end{equation}

\begin{example}
\label{PlusOrMinus}  
Results of political polling are usually represented 
by giving a value (usually as a percent), and an 
\emph{interval of possible values around that}, 
for instance: ``Our poll shows that $57\%$, plus or minus $3\%$, of 
likely voters favor candidate X.''   
The estimate here would usually be derived from the $\hat{p}$ from the
sample, and the interval would usually be the 
interval corresponding to $\pm 2$ standard errors 
from the $\hat{p}$. This is an example of what is known 
as a \emph{confidence interval} and the rationale for the choice 
\index{confidence interval}
$\pm 2$ standard errors will become clear later.

A reasonable question to ask here is: How can one determine
the standard error without knowing what $p$ is?  (And that's what the
polling is supposed to do, after all, estimate the proportion $p$.)  
One possible approach is to use the value of $\hat{p}$ in the formula 
\eqref{eq:SEhatp} to \emph{estimate} the standard error.  A somewhat 
more conservative
method is to note that $pq = p(1 - p)$ is maximized at $p = 1/2$, so
no matter what $p$ or $\hat{p}$ are, the standard error will always be
\emph{at most} $\frac{1/2}{\sqrt{n}}$.  If $n = 1100$, for instance (a
typical order of magnitude for a sample size in political polling), then we get
$$SE \le \frac{1/2}{\sqrt{1100}} \doteq .015.$$
Hence 2 SE's would be at most about $.03$, or three percent.  In fact, from
the range of possible values, it is always possible to estimate
the size of the sample that was used to derive the interval if
that is not reported.

Note also that our estimate for the standard error is strongly based
on the assumption that the individual Bernoulli trials are 
\emph{independent}.  The results of political polling can be 
very unreliable if that is not true.  
$\triangle$
\end{example}

This sort of combination of a \emph{point estimate} (a single
\index{estimator!point}
\index{estimator!interval}
numerical value) and an \emph{interval estimate} (range of 
possible values) is a very common way to report estimated values
of population parameters derived from data.  

\begin{example}
\label{ConfInt1}
A random sample of $n = 300$ individuals are taken from a population of
animals and $m_1 = 175$ of them are determined to be male.  Let us give a 2-SE estimate for 
the interval of possible values of percentage of males in the whole
population and indicate how this sort of interval estimate might be used.

We have $\hat{p} = \frac{175}{300} \doteq .583$, so our point estimate
is that the males make up $58.3$ percent of the population.  Using the 
conservative method from the previous problem to estimate the standard 
error, we see 
$$SE = \frac{1/2}{\sqrt{300}} \doteq 0.0289$$
So our 2-SE estimate would be $58.3\% \pm 5.8\%$, or $52.5\%$ to $64.1\%$.
Looking ahead, we will see later that since $50\%$ is not in this interval, 
the value $p = .5$ for the actual proportion of males in the population
is not very likely. 

Another comment is in order here.  Note that it would be conceivable
to use the estimate $\hat{p} \doteq .583$ in the formula for the 
standard error.  If we do that, then $1 - .583 = .417$ would be our
estimate for $q$ and
$$\sqrt{\frac{(.583)\cdot (.471)}{300}} \doteq 0.0285$$
is slightly smaller than our conservative estimate above.  In practical
terms, the slight difference indicates that both choices would 
yield very similar results. That is true in most cases.  But the 
conservative method of taking $p = 1/2$ in the formula for the SE is
usually considered to be preferable
because it always applies and it will always yield an interval 
that is at least as large
as the actual 2-SE interval. $\triangle$ 
\end{example}

\subsection*{Sampling to Estimate an Average}
Now suppose we take a collection of measurements that yield
numerical values in some interval of the real line (not just
``yes/no'' answers or one of two possible values that might 
be represented by numbers $1/0$ as in the previous subsection).
For instance, we might be thinking of taking very precise measurements
of the heights of some sample of male first year college students to 
estimate the average height of a male first year college student.
If $Y_1,\ldots, Y_n$ are the measured heights of the students in
the sample, and $\mu$ represents the population average height, then
one estimator for $\mu$ would clearly be the sample mean 
$$\overline{Y} = \frac{1}{n}(Y_1 + \ldots + Y_n).$$
That is, 
$$\framebox{$\hat{\mu} = \overline{Y} {\rm\ is\ an\ estimator\ for\ } \mu$.}$$
\index{estimator}
Once again, though, the $\overline{Y}$ is a random variable that has a certain
probability distribution depending on which individuals are selected in the 
sample.  We need to understand the probability distribution of $\overline{Y}$, 
and Theorem~\ref{IIDFacts} contains the statements we need.  That theorem
says in this context that 
$$\framebox{$\displaystyle 
E(\overline{Y}) = \mu \quad {\rm and}\quad V(\overline{Y}) = \frac{\sigma^2}{n}$,}$$
where $\sigma$ is the population SD.  As in the previous case, we call the 
SD of the estimator the \emph{standard error}, or SE.  In this case too, notice
\index{standard error (SE)}
that exact value of the SE, namely
\begin{equation}
\label{SEYbar}
\framebox{$\displaystyle SE {\rm\ (for\ } \overline{Y} {\rm)} = \frac{\sigma}{\sqrt{n}}$}
\end{equation}
depends on information that we would not usually have at our disposal.  Namely, $\sigma$, 
the population SD, is not something we would usually expect to know exactly.  
Almost always, the best we can do from data alone is to \emph{estimate} the \emph{population
SD} using the \emph{sample SD} from \eqref{eq:SD}:
$$S = \sqrt{\frac{1}{n-1}\sum_{i=1}^n (Y_i - \overline{Y})^2}.$$
We reiterate that the sample SD is also an estimator -- in this case, an estimator for the 
population SD.  It also depends on the sample used and its values come with a particular
\index{standard deviation (SD)}
probability distribution if the $Y_i$ are normally distributed. 
We will see the underlying probability distribution for the closely related
quantity 
$$\frac{(n-1)S^2}{\sigma^2}$$
in a later section in this chapter.

\begin{example}
\label{MorePitcherPlants}
Refer to Table 1 in Chapter 9, which gives Height, Mouth, and Tube measurements
for $n = 25$ pitcher plants from the {\it Darlingtonia californica} species.  
As we indicated in the Introduction, as long as we were reasonably sure that
the measurements were independent values in a suitable sense (for instance,
if we had taken the measurements at different locations for pitcher plants
that were not interacting with each other), then it would be productive to view 
those measurements as a \emph{random sample}
from the whole population of this species of pitcher plants.
 We said in Example~\ref{PitcherPlantData} that the 
Height measurements have sample mean $\overline{Y} \doteq 611.7$ and sample SD 
$S \doteq 265.1$.  Hence our point estimator for the population mean height based on
this sample is $\hat{\mu} = \overline{Y} \doteq 611.7$.  The estimate for the 
SE would be 
$$\frac{S}{\sqrt{25}} = \frac{265.1}{5} \doteq 53.02.$$
A 2-SE interval centered at the point estimator value would be 
$$611.7 \pm 106.04$$
and this would represent an interval likely to contain the population mean
height, $\mu$.  We will make this more precise in the next section. $\triangle$ 
\end{example}

\specialsection{Sample Means from Normal Populations -- $t$ Distributions}
\index{estimator}
\index{random variable}
The key point to understand about both types of estimators described in the
previous section is that they are \emph{random variables} with 
probability distributions derived from the probability distribution of
the individual samples $Y_i$ (the Bernoulli trials in the first case,
\index{Bernoulli trial}
and the individual measurements in the second).  In this section, we
will introduce the probability distribution that describes the 
way sample means vary when the $Y_i$ are i.i.d. random variables
\index{random variable!i.i.d. collection}
\index{distribution!normal}
\index{normal distribution}
that have \emph{normal distributions}.  This is a very important 
special case that turns out to be even more widely applicable than 
might be apparent at first.  The idea here is:

\begin{theorem}  If $Y_i$ are all normally distributed with expected value
$\mu$ and variance $\sigma^2$, then
\begin{enumerate} 
\item The sample mean
\index{distribution!of sample mean}
\index{normal distribution}
\index{random variable!normal}
\index{distribution!normal}
$\overline{Y}$ is also normally distributed with expected value
$\mu$ and variance $\frac{\sigma^2}{n}$.
\item More generally, any linear combination 
$a_1 Y_1 + \cdots + a_n Y_n$, where $a_i$ are constant,
is normally distributed with expected value $(a_1 + \cdots + a_n)\mu$
and variance $(a_1^2 + \cdots + a_n^2)\sigma$.  
\end{enumerate}
\end{theorem}

This is a fact that is proved in more advanced mathematical statistics courses,
but we will have to accept it without proof here.   By Theorem~\ref{IIDFacts},
if each $Y_i$ has expected value $\mu$ and SD $\sigma$, then 
$$ 
E(\overline{Y}) = \mu \quad {\rm and}\quad V(\overline{Y}) = \frac{\sigma^2}{n},$$
as noted before.  To compute the probability that $\overline{Y}$ is in a 
given interval, we would want to follow the standardization process from 
\index{normal distribution!standardization formula}
Theorem~\ref{standardize} and look at 
$$Z = \frac{\overline{Y} - \mu}{\sigma/\sqrt{n}} 
= \frac{\sqrt{n}(\overline{Y} - \mu)}{\sigma},$$
which would have a standard normal distribution.  However, as discussed in
the previous section, we rarely have an exact value for $\sigma$ and must usually
``make do'' with the sample SD, $s$ instead.  The resulting ``approximate'' 
standardized sample mean
\begin{equation}
\label{eq:Tdef}
T = \frac{\sqrt{n}(\overline{Y} - \mu)}{S}
\end{equation}
\emph{does not have a standard normal distribution}.  
\index{standard normal distribution}
\index{distribution!standard normal}
\index{random variable!standard normal}

The exact probability distribution of the random variable $T$ above was
determined by William S. Gosset (1876 - 1937), a British statistician who worked for
\index{Gosset, William S.}
the Guiness brewery in Dublin.  The brewery company did not allow its
employees to publish results under their own names due to concerns about
possible theft of trade secrets.  In this case, Gosset was finally allowed to publish
his statistical work under the pseudonym ``Student'' and the probability
distributions he developed are still sometimes known as ``Student's 
$t$-distributions,'' although the simpler name ``$t$-distributions''
\index{Student's $t$ distribution}
\index{distribution!Student's $t$}
\index{t@$t$ distribution}
\index{random variable!$t$}
is now more common.  Gosset's main results here can be summarized as follows.

\begin{itemize}
\index{t@$t$ distribution!degrees of freedom of}
\item The $t$-distributions depend on a parameter known as the \emph{number
of degrees of freedom}, $\nu$,\footnote{This is the Greek letter ``nu'' -- the 
equivalent of the Roman ``n.''} which satisfies $\nu = n - 1$ in the case that $T$
is given by \eqref{eq:Tdef} using the sample mean and SD
of a sample of size $n$.  
\item For each $n$, there is an analytic formula 
\index{probability density function (p.d.f.)!t@$t$}
for the p.d.f. describing the $t$-distribution, which has the form 
$$f(t) = c \left(1 + \frac{t^2}{\nu}\right)^{-(\nu+1)/2},$$
where $c$ is a constant, depending on $\nu$, determined to make the total area between the 
graph of the p.d.f. and the $t$-axis equal to $1$.  
\item The $t$-distribution
p.d.f.'s have the same general shape as the standard normal p.d.f. In particular,
they are all \emph{symmetric} about $t = 0$.
\item  But
their maxima are \emph{lower} and they have \emph{more area in the ``tails''}
\index{tails of normal distribution}
as $t \to \pm \infty$ than the corresponding areas for the standard normal
p.d.f.  
The graph in Figure~\ref{fig:TvsZ} shows the standard normal p.d.f.
in red and the p.d.f. for the $t$-distribution with $n - 1 = 9$ degrees of 
freedom in black.  
\item  As $\nu$ increases, though, the p.d.f. for the $t$-distribution approaches
the standard normal p.d.f. more and more closely. 
\end{itemize}

\begin{figure}
\begin{center}
\includegraphics[width=3.0in,height=3.0in]{ZandT.png}
\caption{Standard normal and $t(9)$ densities compared.}
\label{fig:TvsZ}
\end{center}
\end{figure}
 

We will say $Y \sim t(\nu)$ if $Y$ has a $t$-distribution with $\nu$
degrees of freedom.  (Note that the value of $\nu$ in \eqref{eq:Tdef}
is $\nu = n-1$ for means of samples of size $n$.)

\begin{theorem}
\label{Tdist}
Let $Y_1,\ldots,Y_n$ be i.i.d. samples from a normal population 
\index{random variable!i.i.d. collection}
with mean $\mu$.  Then 
$$T = \frac{\sqrt{n}(\overline{Y} - \mu)}{S}$$
has a $t(n-1)$ distribution.
\end{theorem}

\index{R@{\tt R} statistical package}
The table in Figure~\ref{fig:PctPtsT} will be useful in working with the 
$t$-distributions.\footnote{From {\tt http://www.dummies.com}, downloaded 11/22/2017.  
These and other probabilities for the $t$-distributions can also be computed using the {\tt R} statistical
package introduced in the Chapter Project for Chapter 10.  With the free availability
of software like {\tt R}, the days of statistical tables are probably numbered(!)}  Note
that this table is laid out differently from the standard normal table in 
Figure~\ref{fig:NormalCurveAreas} from Chapter 10.
The number of degrees of freedom for the $t$-distribution is given in the column at the left.
For each number $\nu$ of degrees of freedom up to 30 (and for another row giving the corresponding 
information for the standard normal), the row in the table gives a collection of 
values known as \emph{percentage points} of the corresponding distribution.  We
\index{percentage points of a distribution}
\index{distribution!percentage points of}
\index{t@$t$ distribution!percentage points of}
\index{t@$t$ table}
will use the notation $t_p$ for the $p$-percentage point, which by definition 
is the \emph{lower endpoint} of the upper tail of the distribution for 
which $P(Y \ge t_p) = p$.  The table gives $t_p$ for the 
values $p = .4, .25, .1, .05, .025, .01, .005$, and $.0005$ and $Y \sim t(\nu)$
for the different $\nu$ shown.  

\begin{figure}
\begin{center}
\includegraphics[height=7in,width=5in]{Ttable.jpg}
\caption{A $t$-table.}
\label{fig:PctPtsT}
\end{center}
\end{figure}

\begin{example}
\label{Tbasics}
For instance, check in Figure~\ref{fig:PctPtsT} to find the entry for $p = .05$
for $\nu = 12$ degrees of freedom.  You should find $1.782288$.  This means that 
if $Y \sim t(12)$, then $P(Y \ge 1.782288) = .05$. 

Similarly, for $\nu = 20$, $t_{.005} = 2.84534$.  This means that $P(Y \ge 2.84534) = .005$
if $Y \sim t(20)$.  $\triangle$
\end{example}

At this point we can begin to explain the rationale for the 2-SE intervals that we 
were using as examples in the previous section and indicate how the $t$-table
in Figure~\ref{fig:PctPtsT} will allow us to do something analogous, but more
precise and general, with sample means from normal populations. 
 
\index{standard normal table}
From the standard normal table, Figure~\ref{fig:NormalCurveAreas},
we see that if $Z$ has a standard normal distribution, then 
$$P(-1.96 \le Z \le 1.96) = 2\cdot 0.4750 = 0.9500.$$
This can also be stated in the following form.  The number $1.96$ is the 
\emph{$.025$-percentage point for the standard normal distribution}, a fact
\index{percentage points of a distribution}
\index{distribution!percentage points of}
\index{standard normal distribution!percentage points of}
which is often abbreviated by saying 
$$z_{.025} = 1.96.$$
This is true because $P(Z \ge 1.96) = .5 - .4750 = .025$.

If $Y$ is any random variable with a normal distribution with mean $\mu$ and SD $\sigma$,
\index{normal distribution!standardization formula}
then by Theorem~\ref{standardize}, $Z = \frac{Y - \mu}{\sigma}$ has a standard normal 
distribution.  It follows that
$$0.9500 = P\left(-1.96 \le \frac{Y - \mu}{\sigma} \le 1.96\right) = P(Y - 1.96 \sigma \le \mu \le Y + 1.96\sigma).$$
The interval $Y \pm 1.96\sigma$ is called a $95\%$ \emph{confidence interval}.
\index{confidence interval!for population mean}
The precise meaning of this name is unfortunately rather easy to misunderstand.  
The confidence interval is based on a sample of values of $Y$ and hence really 
\index{interval estimator}
should be thought of as a sort of ``interval-valued random variable'' -- \emph{we
get different confidence intervals from different data} (i.e. different samples of values of $Y$).  
Saying this 
probability is equal to $0.9500$ really means that \emph{if we formed many intervals
of this kind based on different sampled values of $Y$, then roughly $95\%$ of those
intervals would contain the $\mu$ -- the expected value for the normal 
distribution describing the probability distribution of $Y$}.\footnote{It is easy to fall into the trap of  
saying ``there is a $95\%$ chance that the interval we get from the formula contains $\mu$.'' 
However, that does not really make sense because for 
every such interval, $\mu$ is either contained in the interval or it is not.  This is a subtle
point about what we are doing here that will require careful attention in order
to avoid misconceptions.}

This is the basis for a rule of thumb that if $Y$ has a normal distribution (or even
an approximately normal distribution), then the probability that $Y$ is within about 
2 SD's of its mean is about $0.95$, or $95 \%$.  In other words, the 2-SE intervals we
were looking at before were based on saying $1.96$ is very close to the ``round number'' 
2 and using the standard errors for the estimators we were considering.  

But now we can also see why the $t$-table in Figure~\ref{fig:PctPtsT} is set up the way it
is.  Namely, the information there is presented in exactly the form needed to 
derive a confidence interval for the population mean of a normally-distributed population 
based on the information contained in a sample of size $n$ from the population, in the 
form of the sample mean, $\overline{Y}$, and the sample SD, $S$. 
We see that if $p/2$ is any one of the probability values given in the top row of the $t$-table,
if $T \sim t(\nu)$, then by the symmetry of all of the $t(\nu)$-p.d.f.'s, 
$$1 - p = P(-t_{p/2}(\nu) < T < t_{p/2}(\nu)).$$
Hence, if $T = \frac{\sqrt{n}(\overline{Y} - \mu)}{S}$ as in Theorem~\ref{Tdist},
then  
$$1 - p = P\left(-t_{p/2}(n-1) \le \frac{\sqrt{n}(\overline{Y} - \mu)}{S} \le t_{p/2}(n-1)\right),$$
which (after some algebraic rearrangement) becomes
$$1 - p = P\left(\overline{Y} - t_{p/2}(n-1)\cdot\frac{S}{\sqrt{n}} \le 
\mu \le \overline{Y} + t_{p/2}(n-1)\cdot\frac{S}{\sqrt{n}}\right).$$
This gives the following general formula for the endpoints of a $(1 - p)\times 100\%$-confidence
interval for the population mean of a normally-distributed population:
\begin{equation}
\label{eq:MeanCI}
\framebox{$\displaystyle \overline{Y} \pm t_{p/2}(n-1)\cdot \frac{S}{\sqrt{n}}$,}
\end{equation}
based on the information contained in sampled values $Y_1,\ldots,Y_n$, under the 
assumption that the samples are independent and identically distributed (i.i.d.).
\index{confidence interval!for population mean}
\index{random variable!i.i.d. collection}


\begin{example}
\label{FirstMeanCI}
Let us return to the pitcher plant height data from Example~\ref{MorePitcherPlants}.
We will assume here that the heights follow a normal distribution.  If we wanted a 
$90\%$-confidence interval, for instance, then we would take $p = .1$ and hence
$p/2 = .05$.  Since there were $n = 25$ sampled values used to compute the
values of $\overline{Y} \doteq 611.7$ and $S \doteq 265.1$ given before, we use the $t$-table with 
$\nu = 25 - 1 = 24$ degrees of freedom.  The value $t_{.05}(24) = 1.710822$, so 
the endpoints of the $90\%$ confidence interval are
$$611.7 \pm 1.710822\cdot \frac{265.1}{5} \doteq 611.7 \pm 90.7$$
On the other hand, for a $98\%$ confidence interval we would take $p = .02$, so $p/2 = .01$
and then from the table $t_{.01}(24) = 2.49126$ and the endpoints would be 
\index{t@$t$ table}
$$611.7 \pm 2.49126\cdot \frac{265.1}{5} \doteq 611.7 \pm 132.1.$$
As we should expect, the $98\%$ confidence interval from a given collection
of samples will be wider than the $90\%$ confidence interval because we are saying
we want a recipe for making intervals more of which will contain the population mean.
Since the $\frac{S}{\sqrt{n}}$ factor in \eqref{eq:MeanCI}
also depends on how spread out the sample values are, though, we cannot say that
a $90\%$ confidence interval will \emph{necessarily always} be narrower than a 
$98\%$ confidence interval based on a sample of a fixed size from the same population, 
even though that \emph{usually} would be true.  $\triangle$
\end{example}

\specialsection{The Central Limit Theorem and an Application}
\index{Central Limit Theorem}
\index{random variable!i.i.d. collection}
\index{mean}
In the Chapter Project for Chapter 10, we observed that even if sampled
values $Y_1,\ldots,Y_n$ come from a probability distribution that is far
from being normal, the \emph{sample means} $\overline{Y} = \frac{1}{n}(Y_1 + \cdots + Y_n)$
have a probability distribution that seems to be close to normal
if the sample size $n$ is sufficiently large.  The way normal distributions
appear from the averaging process is the subject of a fundamental result
in mathematical statistics known as the \emph{Central Limit Theorem}, or CLT
for short.  Here is one of the simpler versions of the theorem.  This has been
vastly generalized by statisticians, but the simpler version will suffice 
for our purposes.

\begin{theorem}[Central Limit Theorem]  Let the $Y_1, \ldots, Y_n$ be
i.i.d. random variables with finite expected value $\mu$ and SD $\sigma$.   
Then the probability distribution of 
$$\frac{\sqrt{n}(\overline{Y} - \mu)}{\sigma}$$
will be close to a standard normal distribution if $n$ is sufficiently large.  
\end{theorem}

Some comments are in order:
\begin{itemize}
\item The hypotheses that $\mu$ and $\sigma$ are finite are not automatically true,
but they will hold in all of the cases we look at.\footnote{Technical 
note: This condition is a reasonably mild one; all of the examples we have seen satisfy it. 
But there are some continuous random variables with p.d.f.'s $f(y)$ for which 
the improper integrals 
$$E(Y^k) = \int_{-\infty}^\infty y^k f(y)\ dy$$
with $k = 1$ and/or $k = 2$, which go into computing $\mu$ and $\sigma^2$, do not converge .}
\item A commonly-used rule of thumb is that ``sufficiently large'' 
typically means that the agreement is already quite
close for $n \ge 30$ or so. 
\item The agreement also gets \emph{closer the larger $n$ is}, 
and a more precise statement is that the distribution of 
$$U_n = \frac{\sqrt{n}(\overline{Y} - \mu)}{\sigma}$$
actually \emph{converges to the standard normal distribution} as $n\to \infty$ in 
a certain sense.
\item Intuitively, the statement of the theorem also means that $\overline{Y}$
itself will have an approximately normal distribution with mean $\mu$ and
SD equal to $\frac{\sigma}{\sqrt{n}}$.  The form given in the theorem corresponds
to applying the standardization formula from Theorem~\ref{standardize}.
\item We will not try to give a formal justification of this fact because it requires additional
techniques that are beyond the scope of this text.\footnote{Technical note: The book {\it Mathematical
Statistics with Applications} by Wackerly, Mendenhall, and Scheaffer gives a 
somewhat more precise version of the theorem and discusses
one proof by the technique of moment generating functions.}  Instead, we will
simply rely on the intuition we gained from the Chapter Project in Chapter 10.
\end{itemize}

The CLT basically says that (under some relatively mild conditions)
any random variable obtained by an \emph{averaging
process} using enough values will have an approximately normal 
distribution, \emph{no matter what the underlying probability distribution
of the individual sampled values is}.  This says, for instance, 
that the methods for deriving confidence intervals from the last section would 
also apply if our data consisted of the \emph{sample means} from
samples with sufficiently large sample size $n$.  The CLT, or perhaps
more general statements of this kind that do not require such strict 
hypotheses on identical distribution of the $Y_i$, is also often offered
as the underlying reason why so many quantities observed in 
the natural world (e.g. heights and weights of plant or animal bodies, etc.
which are effectively results of a sort of averaging of many genetic and environmental
factors) follow normal distributions.   

Our main example in this section will concern the binomial random variables
\index{binomial distribution|(}
\index{distribution!binomial|(}
\index{binomial random variable|(}
\index{normal distribution!approximation to binomial|(}
\index{normal approximation to binomial|(}
from Chapter 10.  Recall that a binomial experiment consists of some number
$n$ of i.i.d. Bernoulli trials $Y_i$.  
The corresponding binomial random variable gives the number of 
successes in those trials, so we have 
$$Y = Y_1 + \cdots + Y_n = n\cdot \frac{1}{n}(Y_1 + \cdots + Y_n).$$
Since the $Y_i$ have finite expected value $p$ and variance $pq = p - p^2$,
the CLT applies.  We see that if $n$ is sufficiently large, the scaled 
binomial $\frac{1}{n}Y$ is the mean of the Bernoulli trials, and 
the CLT implies that it will have an approximately normal distribution with
expected value $p$ and SD equal to $\displaystyle{\sqrt{\frac{pq}{n}}}$.  Multiplying by $n$ 
to get $Y$ itself, we have the following Corollary of the CLT.

\begin{proposition} 
\label{NormApproxToBinom}
If $n$ is sufficiently large, then a 
binomial random variable $Y$ based on $n$ trials with success
$p$ has approximately the same distribution as a normal random
variable $U$ with expected value $np$ 
and SD equal to $\sqrt{npq}$.
\end{proposition}

The probability histogram in Figure~\ref{fig:BinomialNormal}, which is 
copied from Figure~\ref{fig:TroutPMF} for your
convenience, shows an example.   Even for $n = 10$ (not as large as the
rule of thumb $n = 30$ discussed above), and $p = .4516$, the shape of 
the probability histogram for the binomial is already quite
similar to the shape of the region under the graph of a normal p.d.f. . 
 
\begin{figure}
\begin{center}
\includegraphics[width=2.0in,height=2.0in]{ProbHist.png}
\caption{Binomial probabilities, $n = 10$, $p \doteq .4516$.}
\label{fig:BinomialNormal}
\end{center}
\end{figure}

Proposition~\ref{NormApproxToBinom} is the basis of a traditional method
for \emph{approximating binomial probabilities using the standard 
normal table}.  The only (small) ``wrinkle'' here is that the binomial 
is a \emph{discrete} random variable while the normal is \emph{continuous}.
\index{random variable!discrete}
\index{discrete random variable}
\index{random variable!continuous}
\index{continuous random variable}

This means that (as is suggested by the histogram in Figure~\ref{fig:BinomialNormal}), in doing
this approximation, we want to think of the value $Y = k$ for the 
binomial as corresponding not to a single value of the normal,\footnote{As for any
continuous random variable and one particular value, $P(U = 17) = 0$.} but rather
\emph{to the whole interval of values from $U = k - 1/2$ to $U = k + 1/2$}. 
If we want the probability that $Y$ has one of several possible values, we
just take a union of such intervals.   Here is an example.

\begin{example}
\label{NormalApproxBinomial}
Let $Y$ be a binomial random variable based on $n = 30$ trials with 
$p = 0.6$.  Let us use the idea sketched above to approximate the binomial
probability 
$$P(Y = 17, 18,\ {\rm or}\ 19).$$
By Proposition~\ref{NormApproxToBinom}
we want to use a normal random variable $U$ with expected value $np = 30\cdot 0.6 = 18$
and SD $\sqrt{30\cdot 0.6\cdot 0.4} \doteq 2.68328$.  The binomial probability
will be approximated by $P(16.5 \le U \le 19.5)$, where we have approximated 
$P(Y = 17)$ by $P(16.5 \le U \le 17.5)$, and so forth.  Standardizing and
using the standard normal table as in the examples from Chapter 10, we have 
\begin{align*}
P(16.5 \le U \le 19.5) &= 
P\left(\frac{16.5 - 18}{2.68328} \le Z \le \frac{19.5 - 18}{2.68328}\right)\\ 
&\doteq P(-0.56 \le Z \le .56)\\
&= 2 P(0 \le Z \le .56)\\
&= 2\cdot .2123\\
&= .4246.
\end{align*}
The exact value is 
\begin{align*} 
P(Y = 17, 18,\ {\rm or}\ 19) &= \binom{30}{17}(.4)^{17}(.6)^{13} + 
\binom{30}{18}(.4)^{18}(.6)^{12} + \binom{30}{19}(.4)^{19}(.6)^{11}\\
&\doteq .42303,
\end{align*}
so the approximation is good to two decimal places.  That would be 
sufficient for many purposes.

The awkwardness of computing the binomial coefficients such as 
$$\binom{30}{17} = 119,759,850$$
and raising $p$ and $q$ to such large powers \emph{by hand} 
probably sufficiently explains the appeal
of this normal approximation to binomial probabilities.  However, it must be said
that such calculations using the exact binomial p.m.f. formula 
are not at all difficult with the software and other computational
resources at our disposal at the present time.    
$\triangle$
\end{example}
\index{binomial distribution|)}
\index{distribution!binomial|)}
\index{binomial random variable|)}
\index{normal distribution!approximation to binomial|)}
\index{normal approximation to binomial|)}

\specialsection{$\chi^2$ and $F$ Distributions}
In this section we will rapidly\footnote{A euphemism for ``sketchily''(!)}
introduce two other types of continuous random variables
\index{random variable!continuous}
\index{continuous random variable}
that are used in various ways connected with estimating population \emph{variances}
\index{variance}
and developing the hypothesis tests that we will discuss in the next chapter.
\index{random variable!c@$\chi^2$}
\index{c@$\chi^2$ random variable}
\index{distribution!c@$\chi^2$}
\index{c@$\chi^2$ distribution}
The first of these are the so-called $\chi^2$ random variables.\footnote{$\chi$ is the Greek letter ``chi'' and $\chi^2$ is usually read as ``chi square.''}  
As for the $t$-distributed 
random variables introduced earlier in this chapter, there is a whole family of different
$\chi^2$ random variables parametrized by a positive integer $\nu$ called the 
\emph{number of degrees of freedom}.  We will write $\chi^2(\nu)$ to represent
the $\chi^2$ distribution with $\nu$ degrees of freedom.  
\index{c@$\chi^2$ distribution!degrees of freedom of}

We say $Y$ has a $\chi^2(1)$ distribution if $Y$ is the \emph{square of a standard normal}, 
\index{standard normal distribution}
\index{distribution!standard normal}
\index{random variable!standard normal}
that is $Y = Z^2$, where $Z$ is a normally-distributed random variable with 
expected value $\mu = 0$ and variance $\sigma^2 = 1$.  Probabilities for
these can be computed using the standard normal table.

\begin{example}
\label{ChiSqOne}
Let $Y \sim \chi^2(1)$.  Then for any $a > 0$, 
$$P(0 \le Y \le a) = P(0 \le Z^2 \le a) =  P(-\sqrt{a} \le Z \le \sqrt{a})$$
where $Z$ is a standard normal.  For instance, 
$$P(0 \le Y \le 2) = P(-\sqrt{2} \le Z \le \sqrt{2}) \doteq P(-1.41 \le Z \le 1.41)
= 2 \cdot .4207 = .8414,$$
using the standard normal table from Figure~\ref{fig:NormalCurveAreas}. $\triangle$
\index{standard normal table}
\end{example}

Then the other $\chi^2(\nu)$-distributed random variables for $\nu > 1$ 
are described as follows.

\begin{definition}
\label{X2Def}
$Y$ has a $\chi^2(\nu)$ distribution if $Y = Z_1^2 + \cdots + Z_\nu^2$, where
the $Z_i$ are independent standard normals.
\end{definition}

There is an analytic formula for the p.d.f. of a $\chi^2(\nu)$ random variable which 
has the form 
\index{probability density function (p.d.f.)!of a $\chi^2$ random variable}
\begin{equation}
\label{eq:ChiSqPDF}
f(y) = \begin{cases} c y^{(\nu/2) - 1} e^{-y/2} & y > 0\\
                               0 & y \le 0.
         \end{cases}
\end{equation}
Note $Z_i^2 < 0$ is never true so we expect the p.d.f. to be equal to $0$ for all 
$y < 0$.  The constant $c$, depending on $\nu$, is chosen to make the total area
under the graph of the p.d.f. for $y > 0$ equal to $1$.  Figure~\ref{fig:ChiSqPlots}
shows the p.d.f.'s for $\chi^2(1)$ in red, for $\chi^2(5)$ in black, and for 
$\chi^2(10)$ in blue.

\begin{figure}
\begin{center}
\includegraphics[width=2.0in,height=2.0in]{ChiSq.png}
\caption{$\chi^2(\nu)$ p.d.f.'s -- $\nu = 1$ in red, $\nu = 5$ in black and
$\nu = 10$ in blue.}
\label{fig:ChiSqPlots}
\end{center}
\end{figure}

The connection between $\chi^2$-distributed random variables and estimators
\index{estimator}
\index{variance}
for variance comes from the form of the sample variance:
$$S =\sqrt{\frac{1}{n-1}\sum_{i=1}^n (Y_i - \overline{Y})^2}.$$
From this, if the $Y_i$ are samples from a normal population with SD equal
to $\sigma$, we get
\begin{equation}
\label{eq:S2ChiSq}
\frac{(n-1)S^2}{\sigma^2} = \sum_{i=1}^n \left(\frac{Y_i - \overline{Y}}{\sigma}\right)^2.
\end{equation}
Now, if the $\overline{Y}$ was replaced by $\mu$ in each term on the right side of this equation, 
then we would be summing the squares of $n$ independent standard normals.  
But since we have the sample mean there rather than the population mean, the 
$Y_i - \overline{Y}$ are \emph{not independent}.  Note that their sum is always zero, so
any $n - 1$ of the terms determines the last one.  This is the genesis of the idea of ``$n-1$ 
\emph{degrees of freedom},'' in fact.  Only $n - 1$ one of those terms are independent, 
so we might say the sum on the right side of \eqref{eq:S2ChiSq} has only $n-1$ ``degrees
of freedom.''  Our next statement is not entirely obvious from what we have said, but
it can be proved with some fairly sophisticated algebraic manipulation.

\begin{theorem}
\label{S2ChiSqRel}
Let $Y_i$ be i.i.d. samples with a normal distribution with variance $\sigma^2$.
Then 
$$V = \frac{(n-1)S^2}{\sigma^2} = \sum_{i=1}^n \left(\frac{Y_i - \overline{Y}}{\sigma}\right)^2
$$
has a $\chi^2(n-1)$ distribution.  Moreover, $\overline{Y}$ and $S$ are independent 
random variables.\footnote{
Technical Note:  There is also a very close connection between these formulas and the 
one used before to define the $t(n-1)$ distribution.  Consider the approximate standardization 
$$T = \frac{\sqrt{n}(\overline{Y} - \mu)}{S}$$
using $S$.  If we solve for $S$ in the equation in Theorem~\ref{S2ChiSqRel}, then
$$S = \sigma \cdot \sqrt{\frac{V}{n-1}}.$$
Hence the formula for $T$ above can be rewritten by substituting for $S$:
$$T = \frac{\left(\frac{\overline{Y} - \mu}{\sigma/\sqrt{n}}\right)}{\sqrt{\frac{V}{n-1}}}.$$
The numerator $\displaystyle \left(\frac{\overline{Y} - \mu}{\sigma/\sqrt{n}}\right)$ is the standardization of the normal random variable
$\overline{Y}$; the denominator is the square root
of a $\chi^2(n-1)$ random variable $V$, divided by its number of degrees of 
freedom.  The numerator and denominator are independent by the last statement in
Theorem~\ref{S2ChiSqRel}.  The quotient is then a random variable with a $t(n-1)$-distribution.
Indeed, this is sometimes taken as the \emph{definition} of a $t(n-1)$-distributed
random variable.}
\end{theorem}


Tables of percentage points for the $\chi^2(\nu)$ distributions analogous 
\index{percentage points of a distribution}
\index{distribution!percentage points of}
to the table of percentage points for the $t(\nu)$ distributions given in 
Figure~\ref{fig:PctPtsT} have been compiled and are available in many places.
We will give one such table in the next chapter when we discuss hypothesis
testing using $\chi^2$-distributions.  Software such as {\tt R} also 
\index{R@{\tt R} statistical package}
gives ways to find any such percentage points that are required.

The final topic for this chapter is to introduce yet another family of 
distributions derived from the $\chi^2(\nu)$ family.  

\index{random variable!c@$F$}
\index{F@$F$ random variable}
\index{distribution!F@$F$}
\index{F@$F$ distribution}

\begin{definition}
\label{Fdef}
{\it Let $V_1 \sim \chi^2(\nu_1)$ and $V_2 \sim \chi^2(\nu_2)$ be two 
independent $\chi^2$ random variables.  The quotient 
$$F = \frac{V_1/\nu_1}{V_2/\nu_2}$$
is said to have an $F(\nu_1,\nu_2)$-distribution.}
\end{definition}

The number $\nu_1$ is called the number of degrees of freedom in the numerator
\index{numerator and denominator degrees of freedom ($F$ distributions)}
and the number $\nu_2$ is called the number of degrees of freedom in the denominator.
Tables of percentage points for the $F(\nu_1,\nu_2)$ distributions analogous 
to the table of percentage points for the $t(\nu)$ distributions given in 
Figure~\ref{fig:PctPtsT} and to those for the $\chi^2(\nu)$ distribution
have also been compiled and are available in many places.  Software
such as {\tt R} also allows one to compute them easily.  
\index{percentage points of a distribution}
\index{distribution!percentage points of}
\index{R@{\tt R} statistical package}

As you might expect if you think about the formula
\eqref{eq:S2ChiSq}, and the formula 
for $S$ obtained from it:
$$S^2 = \sigma^2 \cdot \frac{V}{n-1}$$
(in which $V$ has a $\chi^2(n-1)$ distribution), 
the values of the $F$ above will be used to compare the 
sample variances $S_1^2$ and $S_2^2$ of two groups of samples and 
determine whether it is reasonable to assume that they come from 
populations with \emph{same} population variance $\sigma^2$. 
This is a part of a test for whether there is evidence to say 
two population means are different or not based on the information
in groups of samples from each of the two populations.

\specialsection{Chapter Project}
\index{R@{\tt R} statistical package|(}
\index{confidence interval|(}
The goals of this chapter project are:
\begin{itemize}
\item To gain some more intuitive understanding of meaning of
confidence intervals by developing a graphical demonstration.  
The concept of confidence intervals is a notoriously ``slippery'' one.  
It is easy to go from the intuitively appealing ``confidence level'' 
$(1-p)\times 100\%$ as in the text
to statements that seem to be saying the same thing, but
are misleading at best, and completely meaningless at
worst.   To use this idea reliably to make inferences from
real-world data, it is very important to understand {\it exactly} 
what it means.
\item  To gain some experience with user-developed {\tt R} functions.
\end{itemize}
\vskip 10pt
\subsection*{A Confidence Interval Demo}
\vskip 10pt 
If we have $Y_1, \ldots, Y_n$ in the ``large sample'' case ($n \ge 30$ or so)
so the CLT has ``kicked in,'' then it follows from what we said in the text 
that an the endpoints of an (approximate) $(1 - p) \times 100\%$ 
confidence interval for the 
population mean $\mu$ is produced by the formula:
$$\overline{Y} \pm z_{p/2} \frac{S}{\sqrt{n}},$$
where $z_{p/2}$ is the percentage point for the standard normal
(the same as a number in the last row of the $t$-table in Figure~\ref{fig:PctPtsT}).
But what does this really mean, and what is the right way to interpret the ``confidence level''
$(1 - p)\times 100\%$?  

The following {\tt R} code will generate a collection of \emph{one hundred}
$95\%$ confidence intervals 
based on samples of size $n = 50$ from a normal population with mean $\mu = 10$
and $\sigma = 2$.  It produces two things:
\begin{enumerate}
\item[(a)] a graphic window display -- each interval is drawn with a horizontal line, 
and the location of the population mean is marked by the vertical line   
\item[(b)] the number of intervals containing $\mu$, printed in the R console window as the 
output of the function. 
\end{enumerate}

\begin{verbatim}
confdemo <- function()
{
  endpts <- matrix(1:200,nrow=100,byrow=T)
  nin <- 0
  for (i in 1:100)
  { 
     ysamp <- rnorm(50,10,2)
     ybar <- mean(ysamp)
     S <- sd(ysamp)
     endpts[i,1] <- ybar - qnorm(.975,0,1)*S/sqrt(50)
     endpts[i,2] <- ybar + qnorm(.975,0,1)*S/sqrt(50)
     if ((endpts[i,1] <= 10) && (10 <= endpts[i,2])) 
        nin <- nin + 1 
  }
  plot(c(endpts[1:100,1],endpts[1:100,2]),c(1:100,1:100),
     xlab="confidence intervals",ylab="number of trial") 
  for (i in 1:100) lines(c(endpts[i,1],endpts[i,2]),c(i,i))
  lines(c(10,10),c(1,100))
  return(nin)
}
\end{verbatim}
Enter the code line by line.  When you get no error messages, you call the function with
an input command:
\vskip 10pt
\centerline{\tt confdemo()}
\vskip 10pt
This will generate the graphical display and the output to the R console.  
\vskip 10pt
\subsection*{Questions}
\vskip 10pt
\begin{enumerate}
\item[1.]   Look over the {\tt R} code carefully and
try to figure out what each line does.  Explain.  In particular,
how are the plotting commands ({\tt plot} and {\tt lines}) working?
Note:  The {\tt c} 
is the {\tt R} constructor for a list.  {\tt c(a,b)}
denotes a list with entries $a,b$.
\item[2.]   Use the {\tt confdemo} function to generate the plot
showing one hundred $95\%$ confidence intervals for the mean, 
generated from samples of size $n = 50$ from a normal
population with $\mu = 10$ and $\sigma = 2$.  
\item[3.]  Explain
what your plot shows.  In particular, how many of the intervals
contain $\mu = 10$ and how many do not?  How does that relate
to the $95\%$ confidence level?  
\item[4.]  Will the plot {\it always} show exactly 95 intervals
containing the population mean $\mu = 10$?  Try calling the function 
several more times if you got exactly 95 the first time.  Does
it make sense to say $95\%$ of the confidence intervals 
produced here contain $\mu = 10$?  In what sense?
\item[5.]  An {\tt R} function can also take \emph{input values}
that are used when the function is called.  The names go in the 
set of parentheses in the first line, and then you supply values
for them when you call the function.  Modify the {\tt confdemo}
function so that you can specify the {\tt sample size} $n$, 
and the confidence level $1 - p$.  
{\bf Hints:} The first line of your new function definition can look like
\begin{verbatim}
confdemo2 <- function(sampsize,conflevel)
\end{verbatim}
and every where you used the sample size $n = 50$ before, now you will
put in the name of the input {\tt sampsize} instead.  Similarly everywhere
that used the $p/2 = .025$ from before, now you will want {\tt conflevel/2}
(this one is a bit trickier -- you will need to recall what the {\tt qnorm}
function does).  If you like, you can really jazz this up so
that the $\mu$ and $\sigma$ can be specified as well.
\item[6.]  Suppose you now use {\tt confdemo}
to study the $95\%$ confidence intervals for the mean, 
generated from samples of the new size $n = 70$ from the same 
normal population with $\mu = 10$ and $\sigma = 2$.   
What will change (apart from the fact that the computation will
take somewhat longer)?  When you check your intuition, 
be sure to look carefully at the horizontal axis scales.  
\item[7.]  Suppose you now use {\tt confdemo}
to study the $99\%$ confidence intervals for the mean, 
generated from samples of  size $n = 50$ from the same 
normal population with $\mu = 10$ and $\sigma = 2$.  What will change?  
When you check your intuition, 
be sure to look carefully at the horizontal axis scales.
\item[8.]  A common {\it misconception} about confidence
intervals can be stated as follows:  ``When you compute
the $95\%$ confidence interval for the mean from a particular 
sample, there's a $95\%$ chance that the population mean is 
contained in your interval.''   This statement (taken literally) is actually 
\emph{meaningless} -- why?  What could you do to modify the statement 
so that it makes sense and is a true statement about confidence 
intervals?
\item[9.]  Another common {\it misconception} about confidence
intervals can be stated as follows: ``When you increase the
sample size $n$, the width of the $(1-p)\times 100\%$
confidence interval always decreases.''  This statement is actually 
false -- why?  What could you do to modify the statement 
so that it makes sense and is a true statement about confidence 
intervals?
\item[10.]  A final common (and tempting) {\it misconception} about
confidence intervals deals with the following situation. Say we are using
the interval to decide whether evidence from samples supports the
hypothesis that a population mean $\mu$ has a particular value
$\mu_0$.  If the value $\mu_0$ is contained in a confidence
interval but is far from the midpoint (even very close to one
endpoint), it is tempting to think 
that the evidence indicates possibly $\mu\ne\mu_0$.  This 
is an {\it incorrect} deduction in this situation.  
Look carefully back at your results.  Explain why concluding
$\mu\ne\mu_0$ on the basis of one confidence interval where
$\mu_0$ is close to an endpoint is {\it not a correct conclusion}.
\end{enumerate}
\vskip 10pt
\subsection*{Assignment}
Lab report containing input, output, and answers to the questions. 
\index{sampling|)}
\index{R@{\tt R} statistical package|)}
\index{confidence interval|)}

\begin{xcb}{Chapter Exercises}
\vskip 5pt
\begin{enumerate}
\item Discuss how you would find or estimate the following standard errors.
\begin{enumerate}
\item The standard error for estimating the proportion if we have
a sample size $n = 400$, and $m_1 = 321$ out of the $400$ have
the specified characteristic.  Discuss how you are determining the SE.
\item The standard error for estimating a population mean with a
sample size $n = 20$ from a normal population with $\sigma = 2.1$.
What if the population mean is not known, but your sample has
SD $S = 1.9$?
\end{enumerate}
\vskip 10pt
\item Following what we said in Example~\ref{PlusOrMinus}, how big a sample
size would we need to take to get a plus or minus 2-SE interval of $\pm 1\%$ around 
the $\hat{p}$ estimate for a proportion?  (Use the conservative estimate for
the standard error.)
\vskip 5pt
\item Find the 2-SE interval estimates for the Mouth and Tube data 
from Table 1 in Chapter 9. 
\vskip 5pt
\item Find the $95\%$ and $98\%$ confidence intervals for the Mouth and then 
the Tube data from Table 1 in Chapter 9.  Follow the method illustrated in 
Example~\ref{FirstMeanCI} in the text.
\vskip 5pt
\item Assume the data of trout Length and Weight measurements given in Table
3 of Chapter 5 come from a random sample of the population of trout in some area.
\vskip 5pt
\begin{enumerate}
\item Determine $90\%$ and $95\%$ confidence intervals for the population  
average length.
\vskip 5pt
\item Determine $90\%$ and $95\%$ confidence intervals for the population
average weight.
\end{enumerate}
\vskip 5pt
\item Use the method of normal approximations to binomial probabilities 
discussed in Example~\ref{NormalApproxBinomial} to estimate the following
binomial probabilities.  Compare with the exact values computed using {\tt R}
or other suitable sofware.
\vskip 5pt

\begin{enumerate}
\item[(a)]  $P(Y = 12)$ for a binomial random variable $Y$ with $n = 35$ and $p = .27$.
\vskip 5pt
\item[(b)]  $P(10 \le Y \le 15)$ for a binomial random variable $Y$ with $n = 27$ and $p = .46$.
\vskip 5pt
\item[(c)]  $P(Y > 20)$ for a binomial random variable $Y$ with $n = 50$ and $p = .64$.  
\end{enumerate}
\vskip 5pt
\item Suppose a random sample of $2000$ voters are asked their voting preference
in an upcoming election.   Of those sampled, $1213$ favor candidate A.
Give $95\%$ and $98\%$ confidence intervals for the proportion of voters
favoring A in the whole population of voters.  Use the percentage points from
the standard normal (the last row in the $t$-table).  
\vskip 5pt
\item This exercise discusses conditions under which we would expect 
the normal approximation to a binomial probability to be reasonably close.
This often happens for $n$ much smaller than the $n \ge 30$ we would 
expect from the CLT.  The idea is that we would expect the normal
approximation to relatively good if a 3-SE interval for $p$ is entirely
contained in the interval $(0,1)$, that is
$$0 < p - 3\sqrt{\frac{pq}{n}} \quad {\rm and} \quad p + 3\sqrt{\frac{pq}{n}} < 1.$$
(If this were not true, then a significant portion 
of the area under a normal curve approximating the
binomial probability histogram would fall outside the range of possible values 
for $p$.)
\begin{enumerate}
\item By manipulating the inequality algebraically, 
show that $0 < p - 3\sqrt{\frac{pq}{n}}$ is true exactly when $n > 9\left(\frac{p}{q}\right)$.
\vskip 5pt
\item Similarly, show that $p + 3\sqrt{\frac{pq}{n}} < 1$ is true exactly when 
$n > \left(\frac{q}{p}\right)$.  
\end{enumerate}
The two parts of this exercise can be combined to give the rule of thumb 
that we expect the normal approximation to the binomial to yield good results whenever
$$n > 9\left(\frac{{\rm larger\ of\ } p,q}{{\rm smaller\ of\ } p,q}\right)$$
\vskip 5pt
\item The median age of residents of a certain country is $29$ years.  What is the probability
that at least $55$ out of a random sample of $n = 100$ residents will be under
the age of $29$ years?
\vskip 5pt
\item (For readers who know calculus)  
\begin{enumerate}
\item How would you determine 
the value of $c$ in \eqref{eq:ChiSqPDF} to make the total area
under the graph of $f(y)$ equal to 1 in case $\nu$ is even?
\vskip 5pt
\item Determine the values of $c$ when $\nu = 2,4,6$.
\vskip 5pt
\item When $\nu$ is odd, we need to introduce an important special function
called the gamma-function to describe the values of $c$:
$$\Gamma(x) = \int_0^\infty t^{x-1} e^{-t}\ dt.$$
Show that this function satisfies the functional equation 
$\Gamma(x+1) = x\Gamma(x)$ and $\Gamma(1) = 1$, so $\Gamma(x) = (x-1)!$
when $x$ is an integer.  
\vskip 5pt
\item Show 
$$c = \frac{1}{2^{\nu/2} \Gamma(\nu/2)}$$ 
for all integers $\nu \ge 1$.
The value $\Gamma(1/2) = \sqrt{\pi}$.  Knowing that and the functional
\index{gamma function}
equation from part(c), explain how to determine the value of $c$
for all positive integers.  
\end{enumerate}
\end{enumerate}
\end{xcb}
\endinput


