python入門: 遺伝的浮動のシミュレーション
# 遺伝的浮動のシミュレーション import numpy as np n=100 # number of individuals (population) timesteps=1000 x=np.zeros(n) x[0:np.int(n/2)]=1 p=[x.mean()] for i in range(timesteps): x=x[np.random.randint(0, n, n)] p+=[x.mean()] import matplotlib.pyplot as plt plt.plot(p) plt.show()
Keyword(s):
References:[python入門]