import numpy as np
from numba import jit
import matplotlib.pyplot as plt
%matplotlib inline
@jit
def funk(x,mu,kind=0):
if kind==0:
return mu*x*(1-x)
elif kind==1:
return mu*np.sin(x*np.pi)
elif kind==2:
return np.exp(-mu*(x-0.5)**2)
elif kind==3:
return mu*np.exp(-10*(x-0.5)**2)
def logist(mu,n,kind=0):
x=np.empty(n+1)
x[0]=0.5
for i in np.arange(n):
x[i+1]=funk(x[i],mu,kind)
return x
x0=np.arange(0,1,0.001)
plt.plot(x0,funk(x0,2),label='logistic')
plt.plot(x0,funk(x0,2,1),label='sin')
plt.plot(x0,funk(x0,2,2),label='gauss')
plt.plot(x0,funk(x0,2,3),label='10gauss')
plt.legend()
fig=plt.figure(figsize=(16,6))
plt.plot(logist(2.4,100))
fig=plt.figure(figsize=(16,6))
plt.plot(logist(3.,100))
fig=plt.figure(figsize=(16,6))
plt.plot(logist(3.5,100))
Nt=1000
mut=np.arange(1,4.,0.01)
l=np.zeros((len(mut),int(Nt/2)))
m=np.zeros(len(mut))
for j,mu in enumerate(mut):
x=logist(mu,Nt)
l[j,:]=x[-int(Nt/2):]
m[j]=x[-int(Nt/2):].mean()
fig=plt.figure(figsize=(16,6))
plt.plot(mut,l,'.r')
plt.plot(mut,m,'--k')
fig=plt.figure(figsize=(16,6))
plt.plot(mut,l,'.r')
plt.plot(mut,m,'--k')
plt.xlim(3.4,3.9)
plt.ylim(0.7,1)
Nt=1000
mut=np.arange(0,5,0.01)
l=np.zeros((len(mut),int(Nt/2)))
m=np.zeros(len(mut))
for j,mu in enumerate(mut):
x=logist(mu,Nt,kind=1)
l[j,:]=x[-int(Nt/2):]
m[j]=x[-int(Nt/2):].mean()
fig=plt.figure(figsize=(16,6))
plt.plot(mut,l,'.r')
plt.plot(mut,m,'--k')
#plt.xlim(1,2)
Nt=500
mut=np.arange(0,20,0.01)
l=np.zeros((len(mut),int(Nt/2)))
m=np.zeros(len(mut))
for j,mu in enumerate(mut):
x=logist(mu,Nt,kind=3)
l[j,:]=x[-int(Nt/2):]
m[j]=x[-int(Nt/2):].mean()
fig=plt.figure(figsize=(16,6))
plt.plot(mut,l,'.r')
plt.plot(mut,m,'--k')
#plt.xlim(1,2)
Nt=500
mut=np.arange(0,20,0.01)
l=np.zeros((len(mut),int(Nt/2)))
m=np.zeros(len(mut))
for j,mu in enumerate(mut):
x=logist(mu,Nt,kind=2)
l[j,:]=x[-int(Nt/2):]
m[j]=x[-int(Nt/2):].mean()
fig=plt.figure(figsize=(16,6))
plt.plot(mut,l,'.r')
plt.plot(mut,m,'--k')
#plt.xlim(1,2)
from IPython.core.display import HTML
style=open('notebooks.css', "r").read()
HTML(style)