I am trying to understand the following code for image of logistic map,but I am stuck on the point where
ys = [ ]
rs = numpy.linspace(0, 4, 400)
What does rs mean?
What i in range() mean?
I would really appreciate your help!
def f(x, r):
"""Discrete logistic equation with parameter r"""
return r*x*(1-x)
if __name__ == '__main__':
# initial condition for x
ys = []
rs = numpy.linspace(0, 4, 400)
for r in rs:
x = 0.1
for i in range(500):
x = f(x, r)
for i in range(50):
x = f(x, r)
ys.append([r, x])
ys = numpy.array(ys)
pylab.plot(ys[:,0], ys[:,1], '.')
pylab.show()
creates a numpy array with 400 values equal-spaced between 0 and 4 (including the end-points).
Here are some smaller examples:
for i in range(50)is explained in the Python tutorial (section 4.2 and 4.3).Here are some comments to help explain the code.