Skip to content

Instantly share code, notes, and snippets.

@wviechtb
Created February 21, 2020 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wviechtb/f4989ac0559dbe924a0d74d88d136d60 to your computer and use it in GitHub Desktop.
Save wviechtb/f4989ac0559dbe924a0d74d88d136d60 to your computer and use it in GitHub Desktop.
Bifurcation diagram for the logistic map
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