Skip to content

Instantly share code, notes, and snippets.

@alg0trader
Created March 3, 2013 01:35
Show Gist options
  • Save alg0trader/5074085 to your computer and use it in GitHub Desktop.
Save alg0trader/5074085 to your computer and use it in GitHub Desktop.
Implementation of simple chaotic function.
# chaotic_func.py
# A simple program that illustrates chaotic behavior.
import numpy as np
import matplotlib.pyplot as plt
def chaos(x):
while True:
yield x
x = 3.9 * x * (1 - x)
x = input("Enter a number between 0 and 1: ")
n = input("Enter n'th iteration: ")
myGen = chaos(x)
data = [myGen.next() for i in xrange(n)]
# Render graph
plt.plot(data, 'o-')
plt.title("Chaos Function (x = %0.2f, n = %d)" % (x, n))
plt.xlabel('Iteration Number')
plt.ylabel('Output (0 - 1)')
plt.grid()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment