how to simulate the situation in DNA evolution for finding the minimum population needed and minimum samples selected to mating in order to no extinction in any one of original species and new species
meInvent bbird
jobmattcon at gmail.com
Fri Nov 18 00:55:04 EST 2016
how to simulate the situation in DNA evolution for finding the minimum population needed and minimum samples selected to mating in order to no extinction in any one of original species and new species
assume mating are randomly selected to become a couple,
how to keep species good which means no extinction in original species
i use i+j to get new species,
but i do not know whether there is limit in evolution, i assume
limit is 7, then extra evolution will go back to past species and
cycle again
import matplotlib.pyplot as plt
import random
dict = {}
dist = {}
maxnum = 5
allowedmax = 7
for i in range(1,allowedmax+1):
dist[str(i)] = 0
rr = range (1,maxnum)
for i in range (1,maxnum):
for j in range (1,maxnum):
if i < j:
print("(" +str(i) + "," + str(j) + ")");
dict[str(i) + str(j)] = 1;
dist[str(i+j)] = dist[str(i+j)] + 1
if i+j > max(rr or [0]):
rr = rr + [i+j];
original = rr;
for numberofevolutions in range(1,10):
rr2 = []
samples = random.sample(original, len(original)-2)
print("total rr")
print(str(rr))
print("samples")
print(str(samples))
for i in samples:
for j in samples:
if i < j:
print("(" +str(i) + "," + str(j) + ")");
if i+j > allowedmax:
dict[str(i) + str(j)] = (i+j) % allowedmax;
dist[str((i+j) % allowedmax)] = dist[str((i+j) % allowedmax)] + 1
if ((i+j) % allowedmax) > max(rr2 or [0]):
rr2 = rr2 + [((i+j) % allowedmax)];
else:
dict[str(i) + str(j)] = i+j;
dist[str(i+j)] = dist[str(i+j)] + 1
if i+j > max(rr2 or [0]):
rr2 = rr2 + [i+j];
temp = rr
rr = rr2
rr2 = temp
plt.bar(range(len(dist)), dist.values(), align='center')
plt.xticks(range(len(dist)), dist.keys())
plt.show()
More information about the Python-list
mailing list