\documentclass[handout]{beamer} 
\usepackage{beamerthemeshadow,color}

\usepackage{color}
\begin{document}

\newcommand{\comb}[2]{\,^{#1}\text{C}_{#2}}
\frame{
\frametitle{Binomial goodness--of--fit test}
\noindent In the next few slides I will work through the prize question at the end of Chapter 4 (Semester 2).  Before you read through these slides, make sure you've got the question in front of you (question 3, page 39).  

\vspace{0.3cm}

\noindent Appropriate distribution: \textbf{Binomial} distribution. Let $X$: Number of trains thrown away.
\begin{eqnarray*}
H_{0}	&:& \textsf{No. thrown away follows a Binomial distribution}	\\
H_{1}	&:& \textsf{No. thrown away \textit{doesn't} follow a Binomial!}
\end{eqnarray*}

We need to use the formula for the binomial distribution to calculate some probabilities (specifically, for $X=0,1,2,3,4,5$). 
}

\frame{
\frametitle{Binomial goodness--of--fit test}
The binomial formula is:
\begin{eqnarray*}
\textsf{Pr}(X=r) &=& \comb{n}{r} \times p^{r} \times (1-p)^{n-r},
\end{eqnarray*}
and we know that $n=5$ and $p=0.25$ (see the question).  So we calculate
\begin{eqnarray*}
\textsf{Pr}(X=0)	&=&\comb{5}{0} \times 0.25^{0}\times 0.75^{5}	\\
			&=&0.2373
\end{eqnarray*}
We need to perform similar calculations for $X=1, 2, 3, 4$ and 5.  The results are shown in the table on the next slide.  \textit{[Note: We did not need to estimate ANY parameters here -- both $n$ and $p$ were given to us!]}
}

\frame{
\frametitle{Binomial goodness--of--fit test}
We now have
\begin{center}
\begin{tabular}{|c| c c |} \hline
$X$	&Probability		&Expected frequency	\\ \hline
0	&0.2373			&12.3396	\\
1	&0.3955			&20.5660	\\
2	&0.2634			&13.6968	\\
3	&0.0879			&4.5708		\\
4	&0.0146			&0.7592		\\
5	&0.0010			&0.0520			\\ \hline
\end{tabular}
\end{center}

\textit{[Hint: multiply the probabilities by the sum of the frequencies -- 52 here -- to get the Expected frequencies!]} 
}

\frame{
\frametitle{Binomial goodness--of--fit test}
Notice we have three expected frequencies less than 5 -- so we need to pool these categories, then we can calculate the test statistic!
\begin{center}
\begin{tabular}{|c| c c |c|} \hline
$X$		&Expected 	&Observed&$\frac{(O-E)^{2}}{E}$	\\ \hline
0		&12.3396	&10	 &0.4436		\\
1		&20.5660	&21	 &0.0092		\\
2		&13.6968	&14	 &0.0067		\\
3--5		&5.3820		&7	 &0.4864		\\ \hline
		&		&	 &\textbf{0.9459}	\\ \hline
\end{tabular}
\end{center}
}

\frame{
\frametitle{Binomial goodness--of--fit test}
The test statistic is $X^{2}=0.9459$.  We need to compare this to tables.  Now
\begin{eqnarray*}
\nu	&=&\textsf{No. of categories -- no. of estimated parameters} - 1	\\
	&=&4 - 0 - 1 = 3
\end{eqnarray*}
\textit{[Although the binomial distribution has two parameters, $n$ and $p$, WE didn't need to estimate any of them -- they were both given to us!]}

\vspace{0.3cm}

From tables, using $\nu=3$, we get:
\begin{center}
\begin{tabular}{|c|c c c|} \hline
$p$--value	&10\%	&5\%	&1\%	\\ \hline
critical val.	&6.25	&7.82	&11.34	\\ \hline
\end{tabular}
\end{center}
So our $p$--value is bigger than 10\%.
}


\frame{
\frametitle{Binomial goodness--of--fit test}
\textbf{Conclusions}
\begin{itemize}
\item No evidence against $H_{0}$
\item Retain $H_{0}$
\item The number of defective trains \textit{does} follow a binomial distribution!
\end{itemize}
}
\end{document}


