I want to plot a diagram for parameter a. For each value of a, I wanna show the trajectory of the map after initial transient, and plot it on the y axis. In the example below I take 200 points in a (parameter that ranges from 1 to 4), run 1000 steps iterations for each a, and plot x after skipping 100 steps. In order to implement this I used two functions (iterate and logistic):
def logistic(x, a):
return(a*x*(1 - x))
def iterate(f, x0, a, steps=1000):
"""x0: initial value
a: parameter to f(x,a)"""
x = np.zeros(steps+1)
x[0] = x0
for k in range(steps):
x[k+1] = f(x[k], a)
return(x)
n = 200 # points in a
a = np.arange(1,4,3/n)
s = 1000 # steps for each a
x = iterate(logistic, 100, a, 1000)
plt(x)
But I get the following error: ValueError: setting an array element with a sequence. Could anybody help?
EDIT
This is the diagram I want to obtain