\documentclass[12pt]{article}
\usepackage{latexsym,amsmath,epsfig}
\newcommand{\ds}{\displaystyle}
\newcommand{\vp}{$\vphantom{\big|}$}

\newcommand{\R}{\textbf{R}}
\newcommand{\Item}{\item{$\Box$}\quad}

\newcommand{\Answer}[1]{$\phantom{.}$\hfill
        #1\quad\fboxsep 20pt \fbox{$\phantom{\Big|Answer}$}} 

\newcommand{\MyTallAnswer}[2]{$\phantom{.}$\hfill
        #1\quad\fboxsep 20pt\fbox{$\vphantom{\Big|}#2$}}

\newcommand{\MyAnswer}[2]{$\phantom{.}$\hfill
        #1\quad\fboxsep 5pt\fbox{$\vphantom{\Big|}#2$}}

\newcommand{\soln}{\paragraph{Solution}}
\newcommand{\sep}{{\medskip\hrule\bigskip}}
\newcommand{\blank}{\underline{$\phantom{A blank}$}}

\setlength{\textwidth}{6.5in}
\setlength{\topmargin}{-0.5in}
\setlength{\oddsidemargin}{0in}
\setlength{\textheight}{9.0in}
\begin{document}

\begin{center}
MONT 101N -- Analyzing Environmental Data\\
Chapter 9 Project -- {\it writeups due: Monday, February 26}
\end{center}

The descriptive statistics we have introduced in this chapter are important tools, 
but they are not the end of the 
story.  The basic goal of statistics is to analyze the information that is contained in a data set and
to make inferences from that information.  The data sets used in environmental questions might
come from sampling some larger population of organisms.  Even when that is not the case, we can 
use the idea of sampling from a larger population of all possible measurements as a way to 
conceptualize how the data was generated.  

To understand some of the statistical topics we will look at starting in the next chapter, 
it will be good to have some more intuitive understanding of the process of taking samples 
(random or otherwise) from a population, and the variability that is 
built into the process of computing statistics that are produced by that sampling process.  
This may seem counterintuitive at first -- after all, there is just one mean or SD (for 
instance) associated to any particular sample from a larger population. 
There is no variation or uncertainty in dealing with any one data set.  
But the idea is that those sample means and SDs and other statistics produced from 
\emph{different} sample data sets 
\emph{can vary a lot} and we need to have a good working understanding of several 
aspects of that sort of variation.  

We will also practice with some additional features of Excel that may be useful for your work 
on larger assignments for this and other courses.  Unlike some of the other chapter projects, 
this project will not focus on an environmental data set, but instead will use synthetic data 
produced in different ways.   Most of your work for this will 
be contained in a spreadsheet file.

\subsection*{Constructing a First ``Population'' and Sampling From It}
Open a new Excel spreadsheet and enter the formula  {\tt =RAND()}  in cell A1.  This function computes a random value from a uniform 
distribution on the interval $0$ to $1$.\footnote{Technical note: The outputs of {\tt RAND} are called \emph{random numbers}, but they are produced using
a definite algorithm, as is true for essentially everything done with computer software.   
So a better name would be \emph{pseudo-random numbers}.  They are only random in the 
sense that they have no apparent patterns and if you compute a large collection of them, their distribution will be approximately uniform over the interval from $0$ to $1$.}   Copy and paste 
that into all the cells in the block extending from column A through column J and row 
1 through row 20 (200 cells in all).  Show 3 decimal places in all of the numbers.  You now have a random sample of size 200 from that uniform distribution.   

Because of a ``quirk'' of the way Excel deals with spreadsheets containing this {\tt RAND()} function in formulas, you will see that if you now 
enter a formula in another cell of the spreadsheet and calculate that other value, all of the numbers in this block will be recomputed too.  
To turn that feature off (it's annoying and it will mean your results are constantly changing!)  highlight the whole block and from the tool 
bar select Edit/Copy.  Then Edit/PasteSpecial, highlight only the option for Values  
(or Numbers in Libre Office), then OK.  If you examine 
the contents of the cells in the block now, you should see just numbers, not the formulas that generated them. 

\subsection*{First Calculations}
Now perform the following calculations:
\begin{enumerate}
\item[(A)]  Compute the average (mean) and the SD of the 200 numbers.  Compute the 
five-number summary and construct a box plot (by hand or with Excel, 
if you are feeling adventurous and confident).  
\item[(B)]  Next compute the data needed for a \emph{frequency histogram} showing the distribution of this population of 200 numbers (look back at Chapter 6
if you need a refresher on this).  Here's a ``shortcut'' Excel method for doing this.   Since all the numbers are between $0$ and $1$ and we have 
a relatively large data set with $N = 200$,  we can use 
$10$ equal bins with upper boundaries at $0.1, 0.2, \ldots, 1.0$.  
Enter those numbers into cells in one column in the spreadsheet at least three rows below the block of 200 cells above
 (say in column {\tt A} and rows 31 to 40).   Then in the parallel column {\tt B}, highlight the squares in all 10 rows next to the bin boundaries 
 (cells {\tt B31:B40}). In the last cell at the bottom enter the command: 
 {\tt =FREQUENCY(A1:J20,A31:A41)}, and press {\tt SHIFT-CTRL-ENTER} (all together) (or {\tt F2} then {\tt SHIFT-CTRL-RETURN} on a Mac)
 all together.  The whole frequency table should be computed and displayed in the selected cells.
\item[(C)]  Generate a frequency histogram using the computed frequencies with the bins as above.
\item[(D)]  Now, we consider sampling from this ``population.''  Notice that the block {\tt A1:J20} can be thought of as either: 
 \begin{itemize}
\item	$20$ rows (horizontal) with $10$ cells in each, or as 
\item $10$ columns (vertical)  of $20$ cells each.
 \end{itemize}  
We will think of those as two different groups of samples from the population consisting of all $200$ of the numbers--one group of 
$10$ samples of size $20$ from the columns, and as second group of $20$ samples of size $10$ from the rows.  (These are not 
really random samples, of course, since they are constructed in this systematic way.  However the whole block was computed by 
processes that produce random-looking results, so it will do no harm to think of them as random.)
\begin{enumerate} 
\item[(1)] Compute the averages of each of the $20$ rows and put those averages in the cells {\tt L1:L20} (i.e. in the cells in column {\tt L} 
parallel to the block)
\item [(2)] Find the mean and SD of the 20 row averages from part 1.  Generate a frequency histogram for those $20$ values using $5$ bins.  
(You will need to decide on appropriate bin boundaries by examining the values you get.)
\item[(3)] Compute the averages of each of the $10$ columns and put those averages in the cells {\tt A22:J22} (i.e. in the cells in row 22 under the block).
\item[(4)]  Find the mean and SD of the $10$ column averages from step 3.  Since we 
only have 10 of these, making a frequency 
histogram is not too meaningful, so you do not need to do that.  
\end{enumerate}
\end{enumerate}

\subsection*{Constructing a Second Population and Sampling From It}
Open a second tab (sheet) in your spreadsheet and enter the formula 
\vskip 5pt
\centerline{\tt =SQRT(-2*LN(1-RAND()))*COS(RAND()*2*PI())}
\vskip 5pt
\noindent
in cell {\tt A1}.  (This might be tricky -- if you get an error message, check the parentheses carefully and make sure they are exactly as above.)  
Copy and paste that into all the cells in the block extending from column {\tt A} through column {\tt J} and row 1 through row 20 (200 cells in all).  
Show 3 decimal places in all of the numbers.    Repeat parts A -- D above for this new data set, except that you will need to decide on appropriate 
bin boundaries for the histograms.     (Don't worry about exactly what the formula means.  The only thing you need to know for now is that 
it's designed to produce different random values from the ones you used in the first section.)

\subsection*{Further Questions}
\begin{enumerate}
\item[(E)]  Note that {\tt RAND()} appears in both formulas you used to generate both of the ``population data sets?  above.     
Again, this is a built-in Excel formula that generates random (more precisely ``pseudo-random'') numbers in the interval from $0$ to $1$.  
Looking at your population histogram from the first data set, what can you say about the distribution of those numbers?  Do they seem to be 
reasonably uniformly distributed?    What about the second data set where you used the ``black magic'' formula?  How is that one different?
How do the two population box plots compare?
\item[(F)]  What about the distributions of the row and column averages in both cases: what did the distributions look like there?   
Did it depend which data set they came from?
\item[(G)]  What can you say about the SD's of the original population, the SD's of the averages of the samples of size 20, 
and the SD's of the averages of the samples of size 10?  In particular, was one of these consistently the largest and one consistently 
the smallest?  If the pattern was not entirely consistent, was there a general trend?
\item[(H)]  If we redid these computations with any fixed rule for computing the ``population'' values, would it always be true that the average 
of the row means is the same as the population mean?  Similarly for the average of the column means?  (Hint: algebra!)
\item[(I)]  What would truly random samples of sizes 10 or 20 from these populations look like?  Suggest a way to generate such samples.  
\item[(J)]  If we had 20 truly random samples of size 10 from either of these populations, would the average of the sample means be the same 
as the population mean?  (This is the same question as H above, but for a different way of producing the samples.)  Explain your answer.
\end{enumerate}

\subsection*{Assignment} Submit your spreadsheet and your answers to questions E - J in a separate document.  
\end{document}
