Logistic map

In [1]:
# Invoke with "ipython notebook --pylab=inline", then open logistic_jim from dashboard.

def logistic(a, n=20, skip=100, x=0.43):
    """ Return list of values for the logistic map"""
    result = []
    for i in xrange(n + skip):
        if i > skip:
            result.append(x)
        x = a*x*(1.0-x)
    return result

def bifurcation(a_min=2.6, a_max=3.8, acount=200):
    """ Return list of points for bifurcation plot """
    a_values = []
    x_values = []
    for a in arange(a_min, a_max, (a_max-a_min)/acount):
        for x in logistic(a):
            a_values.append(a)
            x_values.append(x)
    return a_values, x_values
In [4]:
plot(logistic(3.8, skip=0))
Out[4]:
[<matplotlib.lines.Line2D at 0x111986810>]
In [5]:
a, x = bifurcation(a_min=2.6, a_max = 3.8)
plot(a, x, ',')
Out[5]:
[<matplotlib.lines.Line2D at 0x111a48310>]
In [3]: