Finally, we would like to trace the lineages back to their common ancestor. As we have just seen, once the number of ancestral lineages is much smaller than the population size, any further reduction in lineages takes many generations on average. To simulate exactly how many, wrap the code in trace2.awk in a while loop that repeats until the number of lineages is 1; in other words, until the most recent common ancestor of n genes has been reached.
Save this as trace3.awk and plot the number of lineages as a function of the number of generations for N = 100 and n = 100.