This Mathematica notebook gives an overview of what can be done with my cellular automaton and correlation dynamics packages.
More info on the pages on correlation dynamics on my personal website.
Put the packages in Mathematica's preferred locations or place them together with the notebook. Modify the following so that Mathematica operates in the right directory
In[1]:=
In[2]:=
Out[2]=
In[3]:=
Out[3]=
We are going to define a model where every site is either empty, occupied by a healthy (sus) or an infected (inf) host:
In[4]:=
Out[4]=
The events that change the states of sites are
In[5]:=
which represent reproduction, mortality, infection and movement.
In[6]:=
some definitions for displaying things:
In[7]:=
some simulation specifications
In[10]:=
In[11]:=
Out[11]=
In[12]:=
Out[12]=
In[13]:=
Out[13]//TableForm=
In[14]:=
In[15]:=
In[16]:=
In[17]:=
Out[17]=
In[18]:=
Global densities
In[21]:=
Out[21]=
Densities as `seen' by the parasite
In[22]:=
Out[22]=
In[23]:=
Out[23]=
In[24]:=
Out[24]=
In[25]:=
Out[25]=
In[26]:=
Out[26]=
In[27]:=
Out[27]=
These equations can be worked a bit more to look like proper correlation dynamics equations, but Mathematica remains rather limited in its capacity to represent symbolic output.
Define temporal...
In[28]:=
... and spatial aspects of the simulation
In[33]:=
where to store the results
In[36]:=
... and put together parameter files instructing the external module simpca
In[37]:=
In[38]:=
Out[38]=
(This takes a long time, but using Mathematica for this kind of simulation is like using a gun to kill a mosquito, whatever its original author might say)
Global and local densities:
In[39]:=
Out[39]=
In[40]:=
Out[40]=
In[41]:=
Where to store the results
In[42]:=
... and put together parameter files instructing the external module simpca
In[43]:=
In[44]:=
In[45]:=
The following two commands read from file the simulation results
In[46]:=
In[47]:=
Global and local densities
In[48]:=
Out[48]=
In[49]:=
Out[49]=
with mean field model
In[50]:=
Out[50]=
with correlation dynamics model
In[51]:=
Out[51]=
Now, compare predictions about the local environment of parasites
In[52]:=
Out[52]=
In[53]:=
In[55]:=
Out[55]=
In[56]:=
Out[56]=
In[57]:=
To show how vital rates can be density dependent, let us introduce an Allee effect
In[58]:=
here it is assumed that birth rates increase with double the square of local density (phi is one over the number of neighbours)
In[59]:=
Global densities
In[62]:=
Out[62]=
Densities as `seen' by the parasite
In[63]:=
Out[63]=
In[64]:=
In[65]:=
In[66]:=
In[67]:=
In[68]:=
In[69]:=
Results
In[70]:=
Out[70]=
In[71]:=
Out[71]=
In[72]:=
Out[72]=
In[73]:=
Out[73]=
In[74]:=
Out[74]=
Converted by Mathematica (February 8, 2005)