Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@krishnanraman
Created November 30, 2020 18:02
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 krishnanraman/e0aa69ebf67f51668d6691ec68ff6bca to your computer and use it in GitHub Desktop.
Save krishnanraman/e0aa69ebf67f51668d6691ec68ff6bca to your computer and use it in GitHub Desktop.
chaotic_attractor.R
rm(list =ls())
dev.off()
for(j in 1:4) {
n=1000
x=numeric(n)
y=numeric(n)
x[1] = rnorm(1,0,0.2)
y[1] = rnorm(1,0,0.2)
a=0.51
for(i in 1:(n-1)) {
x[i+1] = 1+y[i] - a*abs(x[i])
y[i+1] = -x[i]
}
if (j==1) {
plot(x,y,col='red', xlim=c(-1,2), ylim=c(-2,1))
} else {
points(x,y,col='blue')
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment