Created
March 7, 2014 23:22
-
-
Save sleexyz/9422259 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/bin/env python | |
import numpy as np | |
import sys | |
import matplotlib.pyplot as plt | |
#Todo: add slider, make bifurication diagram | |
# | |
# An investigation into the Logistic map, and an introduction to matplotlib | |
#r = 2: 1 attractor | |
#r = 3: 2 attractors | |
#r = 3.449490: 4 attractors | |
# | |
# This phenonmenon is called period doubling, or bifurication. As we increase r, the periods will bifuricate, until we reach | |
# r = 3.569945672, or Feigenbaum's Constant: the brink of chaos | |
# This r gives the limiting accumulation of bifurications, the limit of of order, predictability. Beyond Feigenbaum's constant our logistical map falls to chaos | |
# map becomes chaotic, culminating in r = 4 | |
def logistic(seed, r, times): | |
y = [] | |
def quad_recur(seed, r, times): | |
if times > 0: | |
y.append(seed) | |
new_seed = r*seed*(1 - seed) | |
quad_recur(new_seed, r, times -1) | |
quad_recur(seed, r,times) | |
return y | |
def main(argv): | |
iterations = int(argv[2]) | |
t = np.arange(0,iterations) | |
y = logistic(float(argv[0]), float(argv[1]), iterations); | |
plt.plot(t,y) | |
plt.ylabel('some numbers') | |
plt.show() | |
if __name__ == '__main__': | |
main(sys.argv[1:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment