#note Population Genetics A Concise Guide (14)

This is a note for the book Population Genetics: A Concise Guide (Second Edition).

Page 28

Problem 2.5 Graph simultaneously both Formula 2.4 and Formula 2.5 as a function of N for N from 1 to 100. Is the approximation to your liking?

Formula 2.4

    \[t_{1/2}=\frac{-ln(2)}{ln(1-1/2N)}\]

Formula 2.5

    \[t_{1/2}\approx 2Nln(2)\]

Code:

import numpy as np
from matplotlib import pyplot as plt
import math

def f(t):
   return (-math.log(2))/(math.log(1-1/(2*t)))

def g(t):
   return 2*t*math.log(2)

fig = plt.figure(figsize=(24, 12))
f2 = np.vectorize(f)
plt.plot(t, f2(t) , color='red')
plt.plot(t, g(t) , color='green')
plt.xlabel('population size')
plt.ylabel('t1/2')
plt.show()

Output:

Figure 1: The red one is Formula 2.4, the green one is Formula 2.5.

So we can trust that Formula 2.5 can be seen as an approximation of Formula 2.4.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top