% SIMIODETemplate-TeacherORStudent.tex and simiode.cls for LaTeX2e
% Version 29 July 2015.
% 
% This class (simiode.cls) is a modification of that used by 
% the journal PRIMUS - Problems, Resources, and Issues in 
% Mathematics Undergraduate Studies. 
% 
% See http://www.tandfonline.com/loi/upri .
% 
% The class was developed by  Marc Frantz with suggestions of the 
% PRIMUS Editorial Board, especially John Thoo.
%
% This template is to be used with the  class file "simiode.cls". 
%  
% The latest version of this class and template files 
% can be found at
% 
%       <http://www.SIMIODE.org> in the Author section.
%
% A "Quick Start Guide" appears below.
%
% This file must be processed with version LaTeX2e or higher.
%
\documentclass{simiode}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% With this version of the tex file and the associated SIMIODE.cls file you can produce BOTH a Student Version and a Teacher Version of your modeling scenario or technique narrative.
%
% Basically the Student Version contains the title STUDENT VERSION along with the NAME OF SCENARIO, with no abstract, no keywords, no tags, no author identifiers, and no COMMENTS section. The Student Version contains only the STATEMENT of the modeling scenario with appropriate figures, data, instructions, and perhaps a bibliography appropriate for student resourcing, but nothing in the bibliography which would "give away" the nature of the modeling scenario, etc.
%
%The Teacher Version contains the material in the Student Version, namely the title NAME OF SCENARIO, now headed with   TEACHER VERSION, but also full author  identification, abstract, key words, tag words, and, following the STATEMENT, a section of COMMENTS which can be discussion of presentation  ideas, "solutions," techniques, etc.
%
% Authors can prepare a full Teacher Version using the notions immediately below  to create a pdf for review (but in review please eliminate all information about the author as we use a double-blind referee system. Such information will be restored when accepted and published in SIMIODE at www.simiode.org.
%
%***********   Toggle the following line to turn the teacher version on (1) or off (0). ***********
%
%
\def\TeacherEdition{0} % Toggle this line's value.
\newcommand{\teacher}[1]{\ifnum\TeacherEdition=1 #1 \fi}
%
%
% The \teacher{ } command wraps any text that will appear only in the teacher version of
% the document. See this file for examples. This has been done for you in the document below.   
% Rename the pdf after you compile each final version.
% This option was created  by Eric Sullivan, Carroll College, Helena MT.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{amsmath,amssymb}
\usepackage{color}
\usepackage{graphicx}
\usepackage{hyperref}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% NOTE regarding double spacing %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Manuscripts should be submitted doubled spaced.  This is 
% accomplished via the \baselinestretch command below.
% However, you may obtain an idea of how your article will 
% look in final form, so that you can better plan your 
% presentation.  To see your manuscript formatted very 
% similarly to the on-line published format of  SIMIODE, 
% comment the following line out by inserting a percent sign % (%) at its beginning.

\renewcommand{\baselinestretch}{1.3}

%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% NOTE regarding macros %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Any macros defined for your paper should be contained in 
% the top matter. Likewise, any environment definitions such 
% as \newtheorem or \newenvironment should also go in the 
% top matter. 
% 
% Do not \input your macros as separate files within your 
% final version because more files make it harder for the 
% editors and users to keep track of and/or modify and 
% append your paper.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Top matter is above and 
% the beginning of the document below.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\newpage
% You only need to change the NAME OF SCENARIO in the next line and delete the footnote. See above for instructions on toggling from Teacher Version to Student Version.
\title{\ifnum\TeacherEdition=1 TEACHER VERSION  \else STUDENT VERSION \fi\\Class M\&M Death and Immigration Simulation }





\markboth{Class M\&M Death and Immigration Simulation }{Class M\&M Death and Immigration Simulation }





\author{Brian Winkel,
Director SIMIODE\\ 
Chardon OH 44024 USAUSA\\
BrianWinkel@simiode.org
}
\makeStitlePDFLaTex



\begin{abstract}
We offer students an opportunity to generate unique data for their team on a death and immigration model using m\&m's and then pass on the data to another student team for analysis with a model they built. The key is to recover the parameters and try to explain how the simulation was conducted. 
\end{abstract}


\section*{SCENARIO DESCRIPTION}

This activity is much like that in \cite{Paper2015} except that individual students or teams of students will determine the parameters of their own simulation, run the simulation, and then share the data with other students so the latter students can model and estimate parameters unique to the simulation used to generate the data. 

\subsection*{Early Simulation}

Each team will generate data from one simulation. Teams will need 1 bag of regular m\&m's containing roughly 55 m\&m's, two small cup containers (1 Action cup and 1 Holding cup), one paper plate or confining area in which to safely toss m\&m's and then collect m\&m data, one six sided die, and one sheet of paper for writing down the parameters used and their simulation results.

Each team should count out 20 m\&m's and put them in the Action cup, i.e. the one from which we will toss m\&m's onto the  plate for each generation. If possible try to avoid m\&m's which are yellow as it is sometimes hard to detect the ``m" on the piece. Put the remaining m\&m's in the second cup, a Holding cup.

We are going to toss the m\&m's from the Action cup (gently toss!) onto the  plate and then softly move the  plate around to be sure the m\&m's are settled out and laying flat, not braced on one another.

In the simulations of \cite{Paper2015} we would note which m\&m's had an ``m" facing up and these would die. We would remove them from the population and then immigrate 10 m\&m's back from the Holding cup onto the paper plate. Then we would count and note the number of m\&m's  on the plate and place all these m\&m's into the Action cup for our next generational toss. Each toss would be called a {\it generation\/}. So generation 0 would have 20 m\&m's. We would note the generation and the number of m\&m's in our living population by $m(n)$.  Then we would toss these m\&m's into the plate, noting which m\&m's had ``m" facing up, kill these off into the Holding cup, and then immigrate 10 m\&m's into our population for the next generation. 

Thus if we had $m(0) = 20$ and upon tossing these 20 m\&m's from our Action cup onto the paper plate we saw 7 m\&m's with ``m" facing up we would remove 7 m\&m's from our plate (leaving 13 m\&m's on the plate) into the Holding cup, but then immigrate 10 m\&m's from the Holding cup so that our next generation, $m(1)$, would have $m(1) = 23$ m\&m's. We would continue in this manner, noting our generational data.

\subsection*{New Simulation}

In this new simulation we do everything the same EXCEPT that for each m\&m with an ``m" facing up we further make a decision about death. Using a six-sided fair die we establish a {\it RULE\/} to determine if each 
m\&m with an ``m" facing up really does die. For example, for each m\&m with an ``m" facing up toss the die and if a 3, 4, 5 or 6 faces up THEN the m\&m actually does die and can be removed; otherwise this m\&m lives. We do this for each potential death for an m\&m. We continue to immigrate after death and then note down generation and population size at each generation.

Now you decide your {\it RULE\/} before proceeding with your generating data. For example you could be beneficent to the m\&m population and use this {\it RULE\/}:  For each m\&m if the die comes up 1 then that m\& dies, otherwise the m\&m is given a second chance and lives.  A second part of your {\it RULE\/} will be to determine just how many m\&m's (keep this number constant throughout the simulation, though) will immigrate from the Holding cup to your paper plate before recording generational data. Originally we suggested 10 m\&m's would immigrate, but you can make that any reasonable constant immigration you wish.

Let us go through the steps of our New Simulation.  Keep your {\it RULE\/} on a separate sheet from your data sheet and NEVER share that rule with anyone until your instructor asks you to do so.

\begin{enumerate}
  \item Place 20 m\&m's into our Action cup. Note that $m(0) = 20$, i.e. we have 20 m\&m's in our population at generation 0. There is nothing sacred about the number of m\&m's you use initially except that if you are working with one standard bag of m\&m's you probably have a maximum of 55 m\&m's to play with, so think about how high your m\&m population might go with your rule for death and immigration.
  \item Toss the m\&m's (gently!) from the Action cup onto the  plate and softly move the plate around so the m\&s are somewhat separated and clearly facing ``up" or ``down."
  \item For each m\&m on the  plate with an ``m" facing up toss a six-sided die and if a 3, 4, 5 or 6 comes up that m\&m actually does die and is removed from the  plate and placed in the Holding cup. However, you are to apply your own {\it RULE\/} you determined here.
  \item  After determining deaths then immigrate 10 m\&m's from the Holding cup to the paper plate.  Be sure to use your {\it RULE\/}, though. Again, nothing is sacred about the immigration amount, but realize you are probably going to be limited by the initial size of the m\&m supply from one bag, about 55 m\&m's in total, so you might not want to have an immigration level of, say 25.
  \item Note the generation and the population on a chart.  You should have Generation $n$ and Population $m(n)$ for each generation $n = 0, 1, 2, 3, \ldots .$ See Table~\ref{table:BD}.
  \item Go to Step  (2) and continue until told to stop by your instructor or something obvious happens.
\end{enumerate}


Once each team has completed their simulation they should put their Team Name on their data sheet (should look like Table~\ref{table:BD} with Team name at top)  and exchange data sheets with other teams in the class so that no team has their own data sheet.

\begin{table}[h]

\begin{center}
\begin{tabular}{|c|c|} \hline\hline
\multicolumn{2}{|c|}{Modeling Death and Immigration of m\&m's} \\ \hline\hline
Iteration & \# M\&Ms at start of iteration\\ \hline\hline
0 & \\ \hline
1 & \\ \hline
2 & \\ \hline
3 & \\ \hline
4 & \\ \hline
5 & \\ \hline
6 & \\ \hline
7 & \\ \hline
8 & \\ \hline
9 & \\ \hline
10 & \\ \hline
11 & \\ \hline
12 & \\ \hline
13& \\ \hline
14 & \\ \hline
15 & \\ \hline
\end{tabular}
\caption{\label{table:BD} Modeling death and immigration of m\&m's.}
\end{center}
\end{table}

\section*{Analysis - Activity}

Each team should have a set of generational data received from another team and their job is to create a mathematical model for 
$m(n)$, the number of m\&m's alive at generation $n$.

In effect, each team needs to build a mathematical model which contains a ``death" term and an ``immigration" term and then estimate these parameters as best they can. Indeed, they should be able to recover the {\it RULE\/} used in each case. Perhaps they cannot recover whether the set of outcomes on the die toss which governs whether an m\&m with ``m" facing up actually lives was 
$\{1,2,3\}$ or $\{2,4,6\}$, but they should be able to estimate the size of this set. 


Once the receiving team has estimated the parameters they can then check in with the data generation team to see how well their model is.


If you cannot run this experiment with ``equipment" of your  own then we   offer  data we generated in  a separate Excel file (one for each of  5 runs (A) - (E) of the simulation in  1-101-S-Excel-DeathImmigrationS.xls).

\subsection*{Additional Activities}


You are to model each simulation ((A) - (E)), estimate the parameters involved in your model, and then indicate what you  believe the  {\it RULE\/} was for each (or at least one) run (A) - (E) found in the Excel file, 1-101-S-DeathImmigrationS.xls, as best you can with justification. We enclose in Table~\ref{table:A} the complete generating set of data for simulation (A). All other data sets have the generation data reported only in the spreadsheet.

\begin{table}[t]
\begin{center}
\begin{tabular}{|c|c|c|c|c|c|} \hline
Generation & \# m\&m's & \# with & \# ``m"  & \# m\&m's & add 7.\\
& & ``m" up& really die& to survive  &\\ \hline
0 & 20 & 10 & 3 & 17 & 24\\ \hline
1 & 24 & 10 & 7 & 17 & 24 \\ \hline
2 & 24 & 12 & 7 & 17 & 24\\ \hline
3 & 24 & 10 & 4 & 20 & 27 \\ \hline        
4 & 27 & 15 & 5 & 22 & 29\\ \hline
5 & 29 & 12 & 8 & 21 & 28\\ \hline
6 & 28 & 14 & 4 & 24 & 31\\ \hline
7 & 31 & 14 & 6 & 25 & 32 \\ \hline
8 & 32 & 18 & 9 & 23 & 30 \\ \hline
9 & 30 & 15 & 7 & 23 & 30 \\ \hline
10 & 30 & 15 & 8 & 22 & 29 \\ \hline
11 & 29 & 10 & 6 & 23 & 30 \\ \hline
12 & 30 & 12 & 10 & 20 & 27 \\ \hline
13 & 27 & 12 & 5 & 22 & 29 \\ \hline
14 & 29 & 18 & 8 & 21 & 28 \\ \hline
15 & 28 & 17 & 6 & 22 & 29 \\ \hline
16 & 29 & 12 & 5 & 24 & 31 \\ \hline
\end{tabular}

\caption{\label{table:A} The data from simulation (A) .}
\end{center}
\end{table} 




\begin{thebibliography}{98}



\bibitem{Paper2015} Author. 2015. 1-001-S-MandMDeathAndImmigration. 


\end{thebibliography}

\teacher{
\section*{NOTES FOR TEACHERS}


Complete analyses for the original simpler model are offered in \cite{Winkel2015}, but the point of this activity is to have students generate data for one team's approach to the simulation and then have other teams recover the parameters in the model; in particular, to have the discovery team determine how the simulation was conducted in the recovery of the parameters.


I was struck by a simulation we did at a SIMIODE MAA-PREP workshop in which participants got to decide how fishing would take place in a population simulation and it seemed reasonable to make this original m\&m simulation \cite{Winkel2015} one in which one group would set the simulation rule while a follow-on group would estimate the parameters and discover the rule used.


With our hint we are encouraging a model of the form (\ref{eq:genmodel}),
\begin{equation}\label{eq:genmodel}
m(n+1) = 0.5 \cdot m(n) + a \cdot m(n) + b = 0.5 \cdot m(n) + 0.5\cdot p\cdot m(n) + b\, ,
\end{equation}
 where $a$ is the product of two numbers, 0.5 for the probability that a given m\&m does NOT turn up an ``m", and $p$, where $p$ is the probability that our {\it RULE\/} permits this m\&m which was previously doomed to die by virtue of having its ``m" face up in the original toss the death rate, to actually live.   This is followed by an analysis  in an Excel spreadsheet using the Solver feature to minimize the sum of square errors between a model (with a specific $a$ and $b$ parameters) and the data. Once the entire coefficient of $m(n)$, $0.5  + 0.5\cdot p$,  is estimated in the model then from this, one can give a rough estimate of $p$ and hence recover the {\it RULE\/}.

\section*{Sample Simulation Runs with Rules}



We offer an  Excel file (one for each of  5 runs (A) - (E) of the simulation in  1-101-T-Excel-DeathImmigration.xls) in which we use a difference equation model and Excel's Solver capabilities to build our model and estimate the parameters for a number of {\it RULE\/}s.

We outline the data sets and the {\it RULE\/} for each. We offer student data in  a separate Excel file, one for each of  5 runs (A) - (E) of the simulation in  1-101-S-Excel-DeathImmigrationS.xls for Students and 1-101-T-Excel-DeathImmigrationS.xls  for Teachers. The latter contain the commands using Solver to minimize the sum of square errors between the data and a model.

\begin{itemize}
  \item [A)] We generated the data with this {\it RULE\/}. $m(0) = 20$. Upon tossing the m\&m's if we have $k$ m\&m's with the ``m"  facing up then for each of the $k$ such  m\&m's we toss a six-sided fair die. If a 2, 4, or 6, shows on top then that ``m" actually does die. The set determining whether an m\&m selected for death by virtue of ``m" facing up on the original toss is, $\{2, 4, 6\}$. The remaining m\&m's selected to die  by virtue of ``m" facing up on the original toss  are allowed to live.  We total the number of surviving m\&m's and add 7 immigrants to form our new generation. See Table~\ref{table:A} for all the data collected.

 \item [B)] We generated the data with this {\it RULE\/}. $m(0) = 25$. Upon tossing the m\&m's if we have $k$ m\&m's with the ``m"  facing up then for each of the $k$ such  m\&m's we toss a six-sided fair die. If a 5 or 6, shows on top then that ``m" actually does die. The set determining whether an m\&m selected for death by virtue of ``m" facing up on the original toss is, $\{5, 6\}$. The remaining m\&m's selected to die  by virtue of ``m" facing up on the original toss  are allowed to live.  We total the number of surviving m\&m's and add 8 immigrants to form our new generation. 
\item [C)] We generated the data with this {\it RULE\/}. $m(0) = 50$. Upon tossing the m\&m's if we have $k$ m\&m's with the ``m"  facing up then for each of the $k$ such  m\&m's we toss a six-sided fair die. If a 2, 3, 4, 5, or 6, shows on top then that ``m" actually does die. The set determining whether an m\&m selected for death by virtue of ``m" facing up on the original toss is, $\{2,3,4, 5, 6\}$. The remaining m\&m's selected to die  by virtue of ``m" facing up on the original toss  are allowed to live.  We total the number of surviving m\&m's and add 7 immigrants to form our new generation. 
\item [D)] We generated the data with this {\it RULE\/}. $m(0) = 20$. Upon tossing the m\&m's if we have $k$ m\&m's with the ``m"  facing up then for each of the $k$ such  m\&m's we toss a six-sided fair die. If a 2, 3, 4, 5, or 6, shows on top then that ``m" actually does die. The set determining whether an m\&m selected for death by virtue of ``m" facing up on the original toss is, $\{2,3,4, 5, 6\}$. The remaining m\&m's selected to die  by virtue of ``m" facing up on the original toss  are allowed to live.  We total the number of surviving m\&m's and add 7 immigrants to form our new generation. 
\item [E)] We generated the data with this {\it RULE\/}. $m(0) = 30$. Upon tossing the m\&m's if we have $k$ m\&m's with the ``m"  facing up then for each of the $k$ such  m\&m's we toss a six-sided fair die. If a 6, shows on top then that ``m" actually does die. The set determining whether an m\&m selected for death by virtue of ``m" facing up on the original toss is, $\{6\}$. The remaining m\&m's selected to die  by virtue of ``m" facing up on the original toss  are allowed to live.  We total the number of surviving m\&m's and add 7 immigrants to form our new generation. 
 \end{itemize}


\subsection*{Technology Use}

One alternative to actually tossing a die many times in each generation to see which m\&m witih an ``m" facing up after the initial toss actually does die is to use a random number generator.  

In Mathematica the following code:

\centerline{\tt j[n\_] := Table[RandomInteger[\{1, 6\}], \{i, 1, n\}]} 

\noindent will generate $n$ random integers between 1 and 6. {\tt j[16]} will generate a random set of 16 integers between 1 and 6, $\{2, 4, 3, 6, 3, 2, 6, 5, 4, 6, 4, 6, 5, 1, 4, 6\}$, which can be used for a given rule to determine which of, say 16, m\&m's will survive.


\section*{Differential Equation Model Approach}



We also offer a differential equation model approach using Mathematica in a Mathematica notebook, 1-101-T-Mma-ClassDeathImmigrationT.nb and 1-101-T-Mma-ClassDeathImmigrationT.pdf for those who cannot read Mathematica

One can move the difference equation (\ref{eq:difEqDev}) to a differential equation  (\ref{eq:firstEq}) by chopping up time into smaller and smaller pieces as well as the actions into small pieces of time or generational  size $\Delta n$ in (\ref{eq:difEqDev}) as follows: 

\begin{eqnarray}\label{eq:difEqDev}
m(n+1) &=& 0.5 \cdot m(n) + a \cdot m(n) + b = 0.5 \cdot m(n) + 0.5\cdot p\cdot m(n) + b\\ \nonumber
m(n+1) - m(n) & = & -0.5 \cdot m(n) + a\cdot m(n) + b = -0.5 \cdot m(n) + 0.5\cdot p\cdot m(n) + b
\end{eqnarray}

\noindent to a differential equation (\ref{eq:firstEq}) by chopping up time into smaller and smaller pieces as well as the actions into small pieces of size $\Delta n$ as follows:



\begin{equation}\label{eq:firstEq}
m(n+\Delta n) - m(n) = -0.5 \cdot m(n)\cdot \Delta n + 0.5\cdot p\cdot m(n)\cdot \Delta n + b\cdot \Delta n\, .
\end{equation}

After dividing both sides of (\ref{eq:firstEq}) by $\Delta n$ and then  letting $\Delta n\to 0$ this yields the differential equation (\ref{eq:DIFF}) (we change $n$ to $t$ for notational familiarity) with initial condition for our situation:

\begin{equation}\label{eq:DIFF}
m'(t) =  -0.5 \cdot m(t) + 0.5\cdot p\cdot m(t) + b = (-0.5 + 0.5\cdot p)m(t) + b \, , \quad y(0) =y_0\, .
\end{equation}


There is a  complete analysis in a Mathematica noebtook 1-101-T-Mma-ClassDeathImmigrationT.nb and 1-101-T-Mma-ClassDeathImmigrationT.pdf for those who cannot read Mathematica using a parameter estimation approach based on finding the parameters $a$ and $b$ which minimize the sum of square errors between model and data. We obtain a comparable model using the continuous differential equations approach as we did in the discrete difference equation approach.

\begin{thebibliography}{99}



\bibitem{Winkel2015} Winkel, B. 2015. 1-001-S-MandMDeathAndImmigration.



\end{thebibliography}
}





\end{document}
