-- Introduction au Pyhon --

Logistic and Gaussian map

Mise en évidence et application

-

simon.marie@lecnam.net
In [1]:
import numpy as np
from numba import jit
import matplotlib.pyplot as plt
%matplotlib inline

Mise en évidence

In [5]:
@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
In [6]:
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()
Out[6]:
<matplotlib.legend.Legend at 0x7fb121489750>
In [7]:
fig=plt.figure(figsize=(16,6))
plt.plot(logist(2.4,100))
Out[7]:
[<matplotlib.lines.Line2D at 0x7fb11db03790>]
In [5]:
fig=plt.figure(figsize=(16,6))
plt.plot(logist(3.,100))
Out[5]:
[<matplotlib.lines.Line2D at 0x14f1505c7c88>]
In [6]:
fig=plt.figure(figsize=(16,6))
plt.plot(logist(3.5,100))
Out[6]:
[<matplotlib.lines.Line2D at 0x14f150756748>]

Influence du paramètre $\mu$

Fonction $f(x)=x(1-x)$

In [21]:
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()
In [22]:
fig=plt.figure(figsize=(16,6))
plt.plot(mut,l,'.r')
plt.plot(mut,m,'--k')
Out[22]:
[<matplotlib.lines.Line2D at 0x7fb11a248610>]
In [23]:
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)
Out[23]:
(0.7, 1)

Fonction $f(x)=sin(x/\pi)$

In [12]:
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()
In [13]:
fig=plt.figure(figsize=(16,6))
plt.plot(mut,l,'.r')
plt.plot(mut,m,'--k')
#plt.xlim(1,2)
Out[13]:
[<matplotlib.lines.Line2D at 0x7fb11db95410>]

Fonction $f(x)=\mu e^{-10(x-0.5)^2}$

In [18]:
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()
In [19]:
fig=plt.figure(figsize=(16,6))
plt.plot(mut,l,'.r')
plt.plot(mut,m,'--k')
#plt.xlim(1,2)
Out[19]:
[<matplotlib.lines.Line2D at 0x7fb11ac52650>]

Fonction $f(x)=e^{-\mu(x-0.5)^2}$

In [28]:
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()
In [29]:
fig=plt.figure(figsize=(16,6))
plt.plot(mut,l,'.r')
plt.plot(mut,m,'--k')
#plt.xlim(1,2)
Out[29]:
[<matplotlib.lines.Line2D at 0x14c3353d9748>]
In [2]:
from IPython.core.display import HTML
style=open('notebooks.css', "r").read()
HTML(style)
Out[2]: