forked from scienceetonnante/Chaos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path07-logistique.py
64 lines (53 loc) · 1.6 KB
/
07-logistique.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
plt.rcParams['animation.ffmpeg_path'] = r'/Volumes/Data/Youtube/[ffmpeg]/ffmpeg'
FIGSIZE = (16,9)
DPI = 120 # 240 For 4K, 80 for 720p
f = lambda x: 4*x*(1-x)
def simulogi(x0,N):
x = np.zeros(N)
x[0] = x0
for i in range(1,N):
x[i]=f(x[i-1])
return x
epsilon = 0.000000001
K = 100
N = 40
x0A = 0.37
x0listA = np.linspace(x0A-epsilon,x0A+epsilon,K)
resA = [simulogi(x0,N) for x0 in x0listA]
x0B = 0.55
x0listB = np.linspace(x0B-epsilon,x0B+epsilon,K)
resB = [simulogi(x0,N) for x0 in x0listB]
fig = plt.figure(figsize=FIGSIZE,dpi=DPI)
linesA = [plt.plot(x,'k')[0] for x in resA]
linesB = [plt.plot(x,'r')[0] for x in resB]
plt.tight_layout()
plt.savefig("07-logistique mixing.png")
#fig = plt.figure(figsize=FIGSIZE,dpi=DPI)
#linesA = [plt.plot(x,'k')[0] for x in resA]
#linesB = [plt.plot(x,'r')[0] for x in resB]
#
#def init():
# for lineA,xA in zip(linesA,resA):
# lineA.set_data([],[])
# for lineB,xB in zip(linesB,resB):
# lineB.set_data([],[])
# return linesA, linesB
#
#
#def animate(i):
# print("Computing frame",i)
# for lineA,xA in zip(linesA,resA):
# lineA.set_data(np.arange(i),xA[:i])
# for lineB,xB in zip(linesB,resB):
# lineB.set_data(np.arange(i),xB[:i])
# return linesA, linesB
#
#ani = animation.FuncAnimation(fig, animate, np.arange(0, N),init_func = init,
# interval=33, blit=False)
#writer = animation.FFMpegWriter(fps=30, bitrate=5000)
#
#ani.save('07-logistique_mixing.mp4', writer = writer, dpi=DPI)
#plt.show()