Created
March 3, 2013 01:35
-
-
Save alg0trader/5074085 to your computer and use it in GitHub Desktop.
Implementation of simple chaotic function.
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
# 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