Page 24
Problem 2.2 If you know how to program a computer, write a simulation of genetic drift.
Note:
The simulation model:
1.
Choose an allele at random from among the 2N (N is the number of the diploid individuals) alleles in the parent generation.
2.
Make an exact copy of the allele.
3.
Place the copy in the new generation.
For one trial, the algorithm by using Java:
public List<Double> geneDrift(int population, double frequency, int generations){
List<Double> list = new ArrayList<>();
list.add(frequency);
while(generations != 0) {
double currentFrequency = frequency;
long count = DoubleStream.generate(Math::random).limit(population).filter(i -> i < currentFrequency).count();
frequency = (double)count / population;
list.add(frequency);
generations--;
}
return list;
}
By using Spring boot and Highcharts I did the virtualization:


Code: https://github.com/xlinxlin/GeneticDriftSimulationVirtualization