Created
February 22, 2019 00:12
-
-
Save Miladiouss/8ce1b0944521f19c471121da8e5990ff to your computer and use it in GitHub Desktop.
Simple code for bifurcation of logistic map
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
# Library import for plotting | |
import matplotlib.pyplot as plt | |
%matplotlib inline | |
# Define Logistic Map | |
def f(x, r): | |
return r * x * (1 - x) | |
# Define history and parameters | |
history = [0.5] | |
num_iter = 400 | |
# ========================= | |
# Try 3.4, 3.5, 3.6, 3.7 | |
r = 3.4 | |
# ========================= | |
# Iterate | |
for n in range(400): | |
x_old = history[-1] | |
x_new = f(x_old, r) | |
history.append(x_new) | |
# Plot | |
plt.scatter(range(num_iter + 1), history) | |
plt.ylim((0, 1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment