To put this observation into practice, we can cut down on the
number of iterations of the main loop in `build_next_generation`

.
The unoptimized code is

limit = n * r; for (i = 0; i < limit; i++) { mom = random() % n; dad = random() % n; mate(g[mom],g[dad],ng[nkids]); nm = poisson(mu); if (survivor(g[nkids]),nm) { add_mutations(g[nkids],nm); nkids += 1; if (nkids == K) break; } }Since we know that some portion of the new offspring will die from fixed mutations, we can use a smaller value for

The technique is to draw a random number from a binomial distribution with and number of trials equal to :

limit = binomial(pow(1-2*s,nf),n*r); for (i = 0; i < limit; i++) { mom = random() % n; ... }The binomial number generator is used in situations like this where we want to estimate the number of occurrences of

`n*r`

(the number
of offspring created) and the probability that any one
survives
Since the effects of fixed mutations are already taken into
account when setting the value of limit, they need to be taken
out of the fitness function in calls to ` survivior()`. In
other words, we need to edit the fitness function so it
uses , the health according to segregating mutations. Note
that this is simply the original fitness function before we
introduced the ``garbage collection'' optimization and the use
of the ` nf` counter.