Created
February 21, 2020 17:04
-
-
Save wviechtb/f4989ac0559dbe924a0d74d88d136d60 to your computer and use it in GitHub Desktop.
Bifurcation diagram for the 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
iters <- 1000 | |
ns <- iters - 500 | |
nl <- iters - ns + 1 | |
rmin <- 2.4 | |
rmax <- 4 | |
rn <- 5000 | |
x <- rep(0,iters) | |
rs <- seq(rmin, rmax, length=rn) | |
plot(NA, NA, xlim=c(rmin, rmax), ylim=c(0,1), xlab="r", ylab="") | |
for (i in 1:rn) { | |
r <- rs[i] | |
x[1] <- 0.1 | |
for (j in 2:iters) { | |
x[j] <- r*x[j-1]*(1-x[j-1]) | |
} | |
points(rep(r,nl), x[ns:iters], pch=".", col=rgb(0,0,0,0.05)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment