From: Hal Fulton Date: 2004-12-07T10:25:01+09:00 Subject: Ruby (quiz?) simulation idea This is just off the top of my head. I thought I'd post it instead of emailing, in case people want to discuss it and/or think about it. This is "life" in a sense, but not John Horton Conway. Imagine you have N lifeforms to start with, each with a certain genotype. For simplicity, we could assume simple dominance, no sex-linked traits, and panmictic mating (probability of mating is random based on the population). Purists out there: Please don't flame any slight misuse of terms unless it's really relevant. Flashback to the first day of Genetics 101: AA = homozygous dominant Aa = heterozygous aa = homozygous recessive The population's genotype frequencies are obviously pAA + pAa + paa = 1 A few seconds of thought should show that the gene frequencies are pA = pAA + 0.5pAa pa = paa + 0.5paa and also pA + pa = 1 I imagine modeling each individual as an object running in a thread. For the heck of it, give each individual a location in a grid. Let them wander around. When a nature male bumps into a mature female, a probability function determines whether they mate and how many offspring they have. Assume each individual has a known average lifespan and a typical mating age. (I'd favor expressing these in millisec for purposes of the simulation). Let the "children" have certain probabilities of surviving to mating age: qAA, qAa, and qaa. Typically, these are all near 1.0 -- in many situations, the heterozygote will be a little less likely to survive, and the homozygote least of all. (This is the trivial case in which "A" is good or healthy and "a" is bad or unhealthy.) All things being equal, such a population will eventually reach what is called Hardy-Weinberg equilibrium, in which the genotype frequencies reach a constant and stay there (for a suitable value of epsilon). Run the simulation with large numbers of individuals. Sample the population once in awhile and check the numbers. Watch for equilibrium. Write a pure deterministic (algebraic) model that will predict when equilibrium occurs. See how well it matches your simulation. An iteration in the deterministic model is simply a "generation" -- I think we can consider that equal to a lifespan (or perhaps, hmm, the lifespan minus the mating age?). Just a thought... Hal