The Azimuth Project
Experiments in discrete stochastic simulation using simplified predator-prey (Rev #1, changes)

Showing changes from revision #0 to #1: Added | Removed | Changed

Experiments in discrete stochastic simulation using simplified predator-prey


Working example for author developing a C++ discrete time simulation framework.

NOTE: these are messing-about experiments so the graphs below don’t have axis ticks labelled correctly.


Incredibly simplified model where both rabbits and foxes live at most 2 years, and essentially reproduce when they turn 1 year old. They hvae fertility rates specified per individual, with no tracking of males/females, and the number of babies produced by the population in total is taken as uniform rather than a more appropriate distribution. It also uses the oversimplified rule that if a fox needs to eat cc rabbits to survive for 1 year, then they “telepathically” arrange so that a fox eats either cc rabbits or no rabbits at all.

no of foxes born this yearf 0f_0
no of 1 year old foxesf 1f_1
half of maximum offspring from pair of foxesf ff_f
no of rabbits a fog needs to eat in a year to survivecc
no of rabbits born this yearr 0r_0
no of 1 year old rabbitsr 1r_1
half of maximum offspring from pair of rabbitsr fr_f
maximum no rabbits vegetation can supportcapRcapR

System equations

Next years values are primed versions of existing years values:

(1)e=clampAbove(c(f 0+f 1),r 0+r 1) e=clampAbove(c (f_0+f_1),r_0+r_1)
(2)r 1=twhent2wheret=r 0clampAbove(er 1,0) r_1'=t \quad when \quad t \geq 2 \quad where \quad t=r_0 - clampAbove (e - r_1 ,0)
(3)f 1=twhent2wheret=clampAbove(e/c,f 0) f_1'=t \quad when \quad t \geq 2 \quad where \quad t=clampAbove (e/c,f_0)
(4)r 0=clampAbove(r fr 1U,capRr 1) r_0'=clampAbove(r_f r_1' U,capR - r_1')
(5)f 0=f ff 1U f_0'=f_f f_1' U

where UU denotes a fresh random variable uniformly distributed on [0,1)[0,1) for each occurrence.

Simulation results

Running the system for 2 222^22 different random simulation runs for various values of fox and rabbit fertility (for fixed cc, capRcapR, etc), the “fox population has not died outd” probabilities after 50 years can be visualised in the below plot (where horizontal axis left to right is increasing fox fertility and vertical axis top to bottom is increasing rabbit fertility):

survival prob

The “reasonably favourable values of fertility” for foxes lie in a range of about [2,2.6][2,2.6], and providing it’s above a minimum value rabbit fertility doesn’t matter.

The surival probabilities taken as a series of slices parallel to the “fox fertility axis”:


This looks like it might be a gamma distribution (speculation: might possibly because the “suviving trajectories” are ones that don’t hit any of the clamping terms, so somehow f rf_r is leading to the closed-form probability arguments). Running a simulation with only 2 162^16 different random simulation runs has “kinks” which one couldn’t tell if are genuinely significant parts of the distribution or are “under-sampling” artifacts:


(The horizontal axis tick labels are correct here: the absolute probability of surviing 50 years is indeed below 0.0060.006.) The surival probabilities taken as a series of slices parallel to the “rabbit fertility axis”:


At least part of the reason why the curves go to a horizontal line is that, with a fixed “rabbit carrying capacity”, above a certain level it’s carrying capacity rather than rabbit fertility that determines the number of rabbits.

Fixed system parametersValue
initial f 0f_0100
initial f 1f_10
initial r 0r_02cf 02 c f_0
initial r 1r_10
capRcapR5cf 05 c f_0


2 222^22 evaluations of this incredibly simple system for a 32×3232 \times 32 grid of system parameter values took about 5 hours on my PC.

category: software