October 26, 2006
I thought I’d write a bit about how evolution is modeled, or at least how I model it.
Most models will start out with a verbal version; a plain English explanation of the mechanism.
Unfortunately, I found that many of the more mathematical models missed this bit out. It seems that mathematical types understand a lot just by looking at equations. I’m not a mathematical type (despite being able to write simulations). I need the verbal model.
So I’ll first make two definitions:
- A Model is a mathematical function. Given the same parameters it will always give the same answers.
- A Simulation is an actual reproduction of a simplified system. Simulations normally use some random numbers to determine probabilities of what will happen next. Given the same parameters a simulation may give wildly different answers each time.
So what’s the point of a simulation if it always gives different answers? What you do with a simulation is to run it a number of times. Each run is called a replicate. When you have enough replicates you will analyse the results as a group and look for trends and patterns.
Simulations are often called Monte-Carlo models. This refers to the random number element — it’s supposed to be like gambling at a Monte-Carlo casino. I’ve never been to Monte-Carlo, or gambled at a casino. This is a stupid name. Before computers were available some simulations were done by throwing dice for randomness. They should have called it D&D modeling.
I don’t do models. Actually, I can’t do models. Like I said, I’m not very mathematical (I’ve tried to learn calculus three times, and I still find it tough going).
What I understand and am going to write about are simulations.
So what’s the basis for the simulations I write?
Firstly there’s the probability stuff. You decide on the probability of a particular event happening. Then you generate a random number between 0 and 1 and if that number of less that your probability, then the event happens.
Pretty simple really.
To simulate a coin tossing, you would write:
if(randomNumber < 0.5)
You would then do this a few hundred (or even thousand) times and see that the coin comes down Heads half the time.
But we’re not simulating coin tossing, we’re simulating evolution.
Evolution is defined as ‘ any net change in the genetic makeup of a population’. So were going to need a population and some genetics.
In the last post I showed the three types of heterozygous gene possible: aa, aA and AA.
So that’s a gene. Put some of these into a structure and we have an individual . Make an array of these and we have a population with some genetics. All we need to evolve the population is some selection pressure and a big, repeating loop.
The flow of a simulation program is often like this:
- Initialise population with random genes.
- Kill off some of the individuals based on their genetics and a probability-based function.
- Allow some of the individuals to breed — the probability of breeding will also be a probability-based function.
- Record the genetics of the population
- Go to 2
This is a simulation with overlapping generations. Some simpler simulations will simply allow the old population to reproduce into a new, empty population of the same size and then destroy the parent population. It depends on the type of animal your are basing your simulations on.
The probability-based functions that decide who dies and who breeds are the selection pressure in the model. Selection pressure makes populations evolve as they try to maxmise their fitness.
What’s fitness? I’ll tell you next time, it’s getting late.
If you’re interested in writing software, check out my other blog: Coding at The Coal Face