# to go from 10% to 90% of the population
# is a log difference of 4.5
import numpy as np
import pandas as pd
logdiff990 = np.log(9/.1)
logdiff990
4.499809670330265
# at a 1% survival advantage per generation with 100%
# assortative mating and a 25-year generation takes...
time990_1percent = logdiff990/.01 * 25
time990_1percent
11249.524175825663
Reproductive_Advantage = [.0005, .001, .002, .005, .01, .02, .05, .10, .20]
Time_990 = []
for i in range(9):
Time_990 = Time_990 + [25 * logdiff990/Reproductive_Advantage[i]]
Scratch = (Reproductive_Advantage, Time_990)
Rep_Adv_array = np.array(Scratch)
Scratch = pd.DataFrame(Rep_Adv_array)
Rep_Adv_df = Scratch.transpose()
Rep_Adv_df.columns=['Reproductive Advantage', 'Time to Go from 9 to 90 Percent']
Rep_Adv_df
Reproductive Advantage | Time to Go from 9 to 90 Percent | |
---|---|---|
0 | 0.0005 | 224990.483517 |
1 | 0.0010 | 112495.241758 |
2 | 0.0020 | 56247.620879 |
3 | 0.0050 | 22499.048352 |
4 | 0.0100 | 11249.524176 |
5 | 0.0200 | 5624.762088 |
6 | 0.0500 | 2249.904835 |
7 | 0.1000 | 1124.952418 |
8 | 0.2000 | 562.476209 |
# Suppose we start out with a 7.4-fold difference—exp(2), that is,
# between population X and Y...
# for how long a duration of time will the frequency for X be greater
# than 50% and the frequency for Y be less than 50%?
#
# the answer, where r is the generational reproductive advantage
# and g is the length of a generation, is: g * ln(2)/r
Reproductive_Advantage = [.0005, .001, .002, .005, .01, .02, .05, .10, .20]
Duration = []
for i in range(9):
Duration = Duration + [25 * np.log(2)/Reproductive_Advantage[i]]
Scratch = (Reproductive_Advantage, Duration)
Duration_array = np.array(Scratch)
Scratch = pd.DataFrame(Duration_array)
Duration_df = Scratch.transpose()
Duration_df.columns=['Reproductive Advantage', 'Duration']
Duration_df
Reproductive Advantage | Duration | |
---|---|---|
0 | 0.0005 | 34657.359028 |
1 | 0.0010 | 17328.679514 |
2 | 0.0020 | 8664.339757 |
3 | 0.0050 | 3465.735903 |
4 | 0.0100 | 1732.867951 |
5 | 0.0200 | 866.433976 |
6 | 0.0500 | 346.573590 |
7 | 0.1000 | 173.286795 |
8 | 0.2000 | 86.643398 |
# Time to grow from 1% to 50%
Reproductive_Advantage = [.0005, .001, .002, .005, .01, .02, .05, .10, .20]
Time_to_Grow_from_1_Percent = []
for i in range(9):
Time_to_Grow_from_1_Percent = Time_to_Grow_from_1_Percent + [25 * np.log(50)/Reproductive_Advantage[i]]
Scratch = (Reproductive_Advantage, Time_to_Grow_from_1_Percent)
Time_to_Grow_from_1_Percent_array = np.array(Scratch)
Scratch = pd.DataFrame(Time_to_Grow_from_1_Percent_array)
Time_to_Grow_from_1_Percent_df = Scratch.transpose()
Time_to_Grow_from_1_Percent_df.columns=['Reproductive Advantage', 'Time to Grow from 1 Percent']
Time_to_Grow_from_1_Percent_df
Reproductive Advantage | Time to Grow from 1 Percent | |
---|---|---|
0 | 0.0005 | 195601.150271 |
1 | 0.0010 | 97800.575136 |
2 | 0.0020 | 48900.287568 |
3 | 0.0050 | 19560.115027 |
4 | 0.0100 | 9780.057514 |
5 | 0.0200 | 4890.028757 |
6 | 0.0500 | 1956.011503 |
7 | 0.1000 | 978.005751 |
8 | 0.2000 | 489.002876 |