Skip to content

Instantly share code, notes, and snippets.

@randompast
Last active April 12, 2018 23:11
Show Gist options
  • Save randompast/0691612db51a51cc65fbf9fc597b6fee to your computer and use it in GitHub Desktop.
Save randompast/0691612db51a51cc65fbf9fc597b6fee to your computer and use it in GitHub Desktop.
This generates a series of images that I turned into a logistic map. (link to gif in comment)
import sys
import matplotlib.pyplot as plt
import numpy as np
def f(a, x):
return a*x*(1 - x)
n = 1000
imgs = 50
for k in np.arange(imgs):
for j in np.arange(n+1):
a = j / 250.0
x = np.arange(n)/(1.0*n)
for i in range(k):
x = f(a, x)
sys.stdout.write("Progress: %d%% - %d%% \r" % (100.0*j/n, 100.0*(k)/imgs))
sys.stdout.flush()
plt.plot(np.ones(len(x))*a, x, "b,")
plt.savefig(("%03d" % (k,))+"_out.png")
plt.clf()
# https://twitter.com/randompast/status/984569577697882112
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment