\documentclass[10pt,envcountsect]{beamer}

\mode<presentation> {
  \usetheme{Warsaw}
}

\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage{pstricks,pstricks-add,pst-math,pst-xkey}
\usepackage{multicol}

\newcommand{\R}{\bf R}
\newcommand{\Q}{\bf Q}
\newcommand{\Z}{\bf Z}
\newcommand{\N}{\bf N}
\newcommand{\D}{\bf D}


\begin{document}

\title{Episode 05 -- A statistics exercise}
\subtitle{Chapter 2 -- Statistics}
\author{European section, season 1}
\date{}

\large


\begin{frame}
  \titlepage
\end{frame}


\begin{frame}

In a casino game, people can win between $0$ and $20$ pounds. The fee to play this game is $10$ pounds.
A study has been carried over 200 people, each playing 1 game.
Their winnings after the games are shown in the table below. The
first line gives the possible winnings, gathered in intervals. The
second line shows the number of people whose winnings at the end of the game was in each
interval.

\begin{center}
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline W. & $[0;4[$ & $[4;6[$ & $[6;8[$ & $[8;10[$ & $[10;14[$
& $[14;20[$ \\
\hline A.F. & $38$ & $50$ & $54$ & $46$ & $10$ & $2$ \\
\hline
\end{tabular}
\end{center}

For all computations, whenever necessary, the middle of each
interval will be used.

\end{frame}


\begin{enumerate}

\begin{frame}
\item Histogram.

\begin{center}
\newrgbcolor{zzttqq}{0.6 0.2 0}
\psset{xunit=1.0cm,yunit=1cm}
\begin{pspicture*}(-1,-1)(12,6)
\psgrid[subgriddiv=0,gridlabels=0,gridcolor=gray,subgriddiv=5,subgridcolor=lightgray](0,0)(10,6)
\psset{xunit=0.5cm,yunit=0.1cm,algebraic=true,dotstyle=*,dotsize=3pt 0,linewidth=0.8pt,arrowsize=3pt 2,arrowinset=0.25}
\psaxes[labelFontSize=\scriptstyle,xAxis=true,yAxis=true,Dx=2,Dy=10,ticksize=-2pt 0,subticks=2]{->}(0,0)(-1,-6)(21,57)
\psframe[linecolor=zzttqq,fillcolor=zzttqq,fillstyle=solid,opacity=0.1](0,0)(4,38)
\psframe[linecolor=zzttqq,fillcolor=zzttqq,fillstyle=solid,opacity=0.1](4,0)(6,50)
\psframe[linecolor=zzttqq,fillcolor=zzttqq,fillstyle=solid,opacity=0.1](6,0)(8,54)
\psframe[linecolor=zzttqq,fillcolor=zzttqq,fillstyle=solid,opacity=0.1](8,0)(10,46)
\psframe[linecolor=zzttqq,fillcolor=zzttqq,fillstyle=solid,opacity=0.1](10,0)(14,10)
\psframe[linecolor=zzttqq,fillcolor=zzttqq,fillstyle=solid,opacity=0.1](14,0)(20,2)
\end{pspicture*}
\end{center}
\end{frame}

\begin{frame}
\setcounter{enumi}{0}
\item Histogram.

\begin{center}
\psset{xunit=1.0cm,yunit=1cm}
\begin{pspicture*}(-1,-1)(12,6)
\psgrid[subgriddiv=0,gridlabels=0,gridcolor=gray,subgriddiv=5,subgridcolor=lightgray](0,0)(10,6)
\psset{xunit=0.5cm,yunit=0.1cm,algebraic=true,dotstyle=*,dotsize=3pt 0,linewidth=0.8pt,arrowsize=3pt 2,arrowinset=0.25}
\psaxes[labelFontSize=\scriptstyle,xAxis=true,yAxis=true,Dx=2,Dy=10,ticksize=-2pt 0,subticks=2]{->}(0,0)(-1,-6)(21,57)
\psframe[linecolor=zzttqq,fillcolor=zzttqq,fillstyle=solid,opacity=0.1](0,0)(4,19)
\psframe[linecolor=zzttqq,fillcolor=zzttqq,fillstyle=solid,opacity=0.1](4,0)(6,50)
\psframe[linecolor=zzttqq,fillcolor=zzttqq,fillstyle=solid,opacity=0.1](6,0)(8,54)
\psframe[linecolor=zzttqq,fillcolor=zzttqq,fillstyle=solid,opacity=0.1](8,0)(10,46)
\psframe[linecolor=zzttqq,fillcolor=zzttqq,fillstyle=solid,opacity=0.1](10,0)(14,10)
\psframe[linecolor=zzttqq,fillcolor=zzttqq,fillstyle=solid,opacity=0.1](14,0)(20,0.6)
\psframe[linecolor=zzttqq,fillcolor=zzttqq,fillstyle=solid,opacity=0.1](14,40)(16,50)
\rput(18,45){10 people}
\end{pspicture*}
\end{center}
\end{frame}

\begin{frame}
\setcounter{enumi}{1}
\item Compute the average of these data and represent it as a blue
vertical line on the histogram.\\ \bigskip\pause
\begin{eqnarray*}
&& \frac{2\times 38+5\times 50+7\times 54+9\times 46+12\times 10+17\times 2}{200} \\
&=& 6.36 \\
\end{eqnarray*}
\pause
\begin{center}
\scalebox{0.5}{
\psset{xunit=1.0cm,yunit=1cm}
\begin{pspicture*}(-1,-1)(12,6)
\psgrid[subgriddiv=0,gridlabels=0,gridcolor=gray,subgriddiv=5,subgridcolor=lightgray](0,0)(10,6)
\psset{xunit=0.5cm,yunit=0.1cm,algebraic=true,dotstyle=*,dotsize=3pt 0,linewidth=0.8pt,arrowsize=3pt 2,arrowinset=0.25}
\psaxes[labelFontSize=\scriptstyle,xAxis=true,yAxis=true,Dx=2,Dy=10,ticksize=-2pt 0,subticks=2]{->}(0,0)(-1,-6)(21,57)
\psframe[linecolor=zzttqq,fillcolor=zzttqq,fillstyle=solid,opacity=0.1](0,0)(4,19)
\psframe[linecolor=zzttqq,fillcolor=zzttqq,fillstyle=solid,opacity=0.1](4,0)(6,50)
\psframe[linecolor=zzttqq,fillcolor=zzttqq,fillstyle=solid,opacity=0.1](6,0)(8,54)
\psframe[linecolor=zzttqq,fillcolor=zzttqq,fillstyle=solid,opacity=0.1](8,0)(10,46)
\psframe[linecolor=zzttqq,fillcolor=zzttqq,fillstyle=solid,opacity=0.1](10,0)(14,10)
\psframe[linecolor=zzttqq,fillcolor=zzttqq,fillstyle=solid,opacity=0.1](14,0)(20,0.6)
\psframe[linecolor=zzttqq,fillcolor=zzttqq,fillstyle=solid,opacity=0.1](14,40)(16,50)
\rput(18,45){10 people}
\psline[linecolor=blue](6.36,0)(6.36,57)
\end{pspicture*}}
\end{center}

\end{frame}

\begin{frame}
\item Compute the median and the quartile of these data and represent it as a red
vertical line on the histogram.\\ \pause\setcounter{enumi}{2}
\vspace{0.7cm}
\begin{itemize}
\item There are 200 values.\pause\setcounter{enumi}{2}
\item It's an even number so the median is between the 100th and the 101st value.\pause\setcounter{enumi}{2}
\item The first quartile is the $\dfrac{200}{4}=50$th value.\pause\setcounter{enumi}{2}
\item The third quartile is the $\dfrac{3\times200}{4}=150$th value.\pause\setcounter{enumi}{2}
\end{itemize}
%First, let's decompose the total number of value.\\
% $$200=100+100=50+50+50+50$$\pause
% \begin{itemize}
%     \item The median is between the 100th and the 101st values ;
%     \item The first quartile is between the 50th and the 51st values ;
%     \item The third quartile is between the 150th and the 151st values.
%    \end{itemize}\pause
To find the actual values, we need the cumulative absolute frequencies. \pause\setcounter{enumi}{2}
\begin{center}
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline W. & $[0;4[$ & $[4;6[$ & $[6;8[$ & $[8;10[$ & $[10;14[$
& $[14;20[$ \\
\hline A.F. & $38$ & $50$ & $54$ & $46$ & $10$ & $2$ \\
\hline C.A.F. & $38$ & $88$ & $142$ & $188$ & $198$ & $200$ \\
\hline
\end{tabular}
\end{center}\pause\setcounter{enumi}{2}
So, finally,
$$Med=[6;8[\textrm{ ; }Q_1=[4;6[\textrm{ and }Q_3=[8;10[.$$
or 
$$Med=7\textrm{ ; }Q_1=5\textrm{ and }Q_3=9.$$

\end{frame}

\end{enumerate}



\begin{frame}
\begin{center}
\psset{xunit=1.0cm,yunit=1cm}
\begin{pspicture*}(-1,-1)(12,6)
\psgrid[subgriddiv=0,gridlabels=0,gridcolor=gray,subgriddiv=5,subgridcolor=lightgray](0,0)(10,6)
\psset{xunit=0.5cm,yunit=0.1cm,algebraic=true,dotstyle=*,dotsize=3pt 0,linewidth=0.8pt,arrowsize=3pt 2,arrowinset=0.25}
\psaxes[labelFontSize=\scriptstyle,xAxis=true,yAxis=true,Dx=2,Dy=10,ticksize=-2pt 0,subticks=2]{->}(0,0)(-1,-6)(21,57)
\psframe[linecolor=zzttqq,fillcolor=zzttqq,fillstyle=solid,opacity=0.1](0,0)(4,19)
\psframe[linecolor=zzttqq,fillcolor=zzttqq,fillstyle=solid,opacity=0.1](4,0)(6,50)
\psframe[linecolor=zzttqq,fillcolor=zzttqq,fillstyle=solid,opacity=0.1](6,0)(8,54)
\psframe[linecolor=zzttqq,fillcolor=zzttqq,fillstyle=solid,opacity=0.1](8,0)(10,46)
\psframe[linecolor=zzttqq,fillcolor=zzttqq,fillstyle=solid,opacity=0.1](10,0)(14,10)
\psframe[linecolor=zzttqq,fillcolor=zzttqq,fillstyle=solid,opacity=0.1](14,0)(20,0.6)
\psframe[linecolor=zzttqq,fillcolor=zzttqq,fillstyle=solid,opacity=0.1](14,40)(16,50)
\rput(18,45){10 people}
\psline[linecolor=blue](6.36,0)(6.36,57)
\psline[linecolor=red](7,0)(7,57)
\end{pspicture*}
\end{center}
\end{frame}




\begin{frame}
Another study has been carried over 500 other people. The results are shown in the table below.

\begin{center}
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|}
\hline
Winning & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
\hline
Frequency & 27 & 34 & 37 & 34 & 42 & 41 & 39 & 41 & 35 & 29 \\
\hline
\hline
Winning & 10 & 11 & 12 & 13 & 14 & 15 & 16 & 17 & 18 & 19 \\
\hline
Frequency & 25 & 23 & 24 & 17 & 12 & 9 & 11 & 8 & 5 & 7 \\
\hline
\end{tabular}
\end{center}
\end{frame}

\begin{enumerate}\setcounter{enumi}{3}
\begin{frame}
\item Find out the minimum, maximum and range (or spreading) of these $500$ values :\\ \bigskip \pause
\begin{itemize}\setcounter{enumi}{3}
\item The minimum is $0$.
\item The maximum is $19$.
\item The range is $19-0=19$.
\end{itemize}
\end{frame}

\begin{frame}\setcounter{enumi}{4}
\item Compute the average winnings of these $500$ values :\pause\setcounter{enumi}{4}
$$\dfrac{0\times27+1\times34+\cdots+19\times7}{500}=6.99$$
The average is $6.99$.
\end{frame}

\begin{frame}\setcounter{enumi}{5}
\item Find out the median of these values and show all the steps in your method.\\ \bigskip\pause\setcounter{enumi}{5}
There are 500 values. It's an even number so the median is between the 250th and the 251st value.
Using the C.A.F. (cumulative absolute frequencies) we see that the median is $6$.
\end{frame}


\begin{frame}\setcounter{enumi}{6}
\item According to these results, would you play this game ?\\ \bigskip\pause\setcounter{enumi}{6}
Why not, but it's more likely to lose money than to win, as the fee is 10 pounds and the average winnings after 500
games only amounts to $6,99$ pounds.
\end{frame}



\begin{frame}\setcounter{enumi}{7}
\item Use the two averages to compute the average of the $700$ values. Show your computation.\\ \bigskip\pause\setcounter{enumi}{7}
In this computation, we have to consider the fact that there are $200$ values in the first set of data and $500$ in
the second. So the global mean is $$\frac{200\times 6.36+500\times 6.99}{700}=6.81.$$

\end{frame}

\begin{frame}\pause\setcounter{enumi}{8}
\item Can you deduce in the same way the median of the $700$ values ? If so, do it. If not, explain why.\\
\bigskip\pause\setcounter{enumi}{8}
We can't find the value of the median, as in one case the data is gathered in intervals, and in the second it's
just listed.\pause We could gather the 700 values in classes, but it wouldn't be very accurate.
\end{frame}


\end{enumerate}


\end{document}
