Personal tools

A Python program to compute a plot of the logistic map invariant measures. — Python Source, 0Kb

File contents

# This program will compute the iterates of the logistic map, and histogram
# them in a two-dimensional (r,x) grid.
# can choose to plot on screen or save as a png. 

from pylab import *
screen = True

# The size of the grid in the R and X dimensions, and the range of r
RDIM = 1000
XDIM = 1000
rmin = 3.0
rmax = 4.0

# Get started. Initialize histogram
h = zeros((RDIM,XDIM))

# Will compute all values of r in parallel. So we will have RDIM copies of x, r
x=rand(RDIM) # might want to start from the maximum 0.5, or from random 
r= rmin+(rmax-rmin)*arange(RDIM)/(RDIM-1)
in0 = range(RDIM)

# iterate until the transients decay. 
for i in range(10000):

# iterate and histogram
for i in range(5000):
    ind = floor( x*(XDIM-1) ).astype(int)
    h[in0,ind] += 1

# plot according to choice above. 
if( screen ):
Document Actions