在 python 中创建分叉图
Creating a bifurcation diagram in python
我正在尝试编写一个代码,使我能够绘制周期倍增分叉的图表。
我正在使用方程 x = rx − 1(1 − x)
,并尝试使用 r 值从 0.5 到 4 对其建模。这是我正在使用的代码
startr = 0.5
finalr = 4
max_time = 200
x = [0.1]
r= np.linspace(.5,4,200)
for n in range(0,200):
x = np.append(r * x[n] * (1-x[n]))
plt.plot(x, label='x');
plt.xlabel('t');
这一直被踢出去
TypeError: append() missing 1 required positional argument: 'values'
numpy.append()
的两个绝对必要的参数,取自 Numpy reference.
arr : array_like Values are appended to a copy of this array.
values :
array_like These values are appended to a copy of arr. It must be of
the correct shape (the same shape as arr, excluding axis). If axis is
not specified, values can be any shape and will be flattened before
use.
因此,请尝试使用
np.append(x, r * x[n] * (1-x[n]))
在你的循环中。
Logistic Map
Save file and run, png image file of graph will save in the same folder
import numpy as np
import matplotlib.pyplot as plt
Many =50000
x = np.random.rand(Many)
r = np.linspace(0,4.0, num= Many)
for i in range(1, 54):
x_a = 1-x
Data= np.multiply(x,r)
Data= np.multiply(Data, x_a)
x = Data
plt.title(r'Logistic map: $x_{n+1} = r x_{n} (1-x_{n}).$ n = '+ str(i) )
plt.ylabel('x-Random number')
plt.xlabel('r-Rate')
plt.scatter(r, Data, s=0.1, c='k')
plt.show()
plt.savefig(str(i) + " Logistic Map.png", dpi = 300)
plt.clf()
我正在尝试编写一个代码,使我能够绘制周期倍增分叉的图表。
我正在使用方程 x = rx − 1(1 − x)
,并尝试使用 r 值从 0.5 到 4 对其建模。这是我正在使用的代码
startr = 0.5
finalr = 4
max_time = 200
x = [0.1]
r= np.linspace(.5,4,200)
for n in range(0,200):
x = np.append(r * x[n] * (1-x[n]))
plt.plot(x, label='x');
plt.xlabel('t');
这一直被踢出去
TypeError: append() missing 1 required positional argument: 'values'
numpy.append()
的两个绝对必要的参数,取自 Numpy reference.
arr : array_like Values are appended to a copy of this array.
values : array_like These values are appended to a copy of arr. It must be of the correct shape (the same shape as arr, excluding axis). If axis is not specified, values can be any shape and will be flattened before use.
因此,请尝试使用
np.append(x, r * x[n] * (1-x[n]))
在你的循环中。
Logistic Map Save file and run, png image file of graph will save in the same folder
import numpy as np
import matplotlib.pyplot as plt
Many =50000
x = np.random.rand(Many)
r = np.linspace(0,4.0, num= Many)
for i in range(1, 54):
x_a = 1-x
Data= np.multiply(x,r)
Data= np.multiply(Data, x_a)
x = Data
plt.title(r'Logistic map: $x_{n+1} = r x_{n} (1-x_{n}).$ n = '+ str(i) )
plt.ylabel('x-Random number')
plt.xlabel('r-Rate')
plt.scatter(r, Data, s=0.1, c='k')
plt.show()
plt.savefig(str(i) + " Logistic Map.png", dpi = 300)
plt.clf()