Genetic drift is an important part of understanding evolution. Genetic drift is the mechanism by which, absent of any external factors, a gene (or more accurately allele) pool starts to homogenize itself, by converging on one particular allele due to random chance. Because of this importance, and also the difficulties in studying this mechanism in the wild due to both the long time evolution takes to be visible, alongside the near absence of external factors in the wild, I have decided I would design, run, and share some computational models for genetic drift simulation.
The homogenization coefficient is the value used for measuring the homogeneity of the gene pool, in my simulations’ case, the pixel colors, of a population, in my simulations’ case, the pixels themselves. It is calculated, at least in my simulations, as the average of the euclidean distance between each element in the color array, and then represented as a number between 0 and 1. I then view a color map as successfully “homogenized”, when the homogenization coefficient surpasses .90.
In this simulation, a 2D screen with dimensions nXn is initialized, and the pixels are each given a random color. Then, during each update, the pixel chooses a random pixel, possibly itself, to set its color as. Overtime, we see the homogenization of the colors. This acts as a valid model for genetic drift, as it shows how, over time, traits will naturally start to homogenize, without any selective force acting on them, as shown with the unweightedness of the randomness of the selection of the pixels for reproduction.
When initializing each pixel with a randomly chosen RGB color from the list Red, Blue, or Green, and a screen size of 50x50, it took, averaged over 100 repetitions, ~805 steps of reproduction for the homogenization coefficient to surpass .90. When using completely random RGB values, without a selection from a list, averaged over 100 repetitions, it took ~1022 steps of reproduction. I would also just like to say I find it surprising that, even though there where much, much more starting colors in the second version of this simulation, the difference in average length was one ~200 rounds, meaning that a large part of the majority end of both simulations was most probably just 2 colors competing at 50/50.
This simulation has a 2D screen identical to the previous simulation. There are two versions of this simulation, and each of those versions has its own two versions, one with a preset color list and another. In the broad scheme explanation of this simulation pixel colors are chosen by averaging together the color of two pixels. In the first version of this simulation, each pixel is averaged with itself and a randomly selected pixel (which could also be itself). In the second version, however, each pixel is averaged with two randomly selected pixels (either or both of which could be itself), however the pixel is not explicitly averaged with its own color. These two methods form as a successful model for genetic drift, as they are able to essentially simulate dual parent incomplete dominant allele spread, through the viewing of phenotypes. This compares to the previous, or succeeding, simulations, by representing phenotypes, rather than specific alleles in a genotype.
In the first simulation, with averaging itself, and with the colors chosen from a list of Red, Green, or Blue, I found that it takes, on average, on a 50x50 screen, with a 100 round sample size, ~21 reproduction steps for the phenotypes to homogenize themselves. Without a list of colors and the same above other prerequisites, I found that it takes ~14 reproduction steps for the phenotypes to homogenize themselves. The fact that, as the color variety increase, the homogenization speed increases with this simulation I find very interesting, as it wasn’t what I initially expected, however, I believe that, looking at it a second time, it makes perfect sense, as the pixels start off closer to each other, average wise, than the in the version with the list of polar opposite pixels.
In the second simulation, with averaging of two other pixels, essentially creating offspring of two parents, I found that, with the above configuration for screen size, round sample size, etc. it took ~14 reproduction steps for the phenotypes to reach a highly homogenized state, when using a preset color list. When repeating the experiment without a preset color list, it also took ~14 reproduction steps to reach a highly homogenized state. This is an interesting result, which I believe can be explained as the averages of the entire map, at all moments, are going to be perfectly homogeneous, and this simulation, with a disregard of the pixel’s individual color, reaches peak homogeneity almost instantaneously, by generating the average of the whole color map as a whole.
“Sorry if I messed up my saying of some things and switched terms around – my bad. Code is at codeberg