Created
November 30, 2020 18:02
-
-
Save krishnanraman/e0aa69ebf67f51668d6691ec68ff6bca to your computer and use it in GitHub Desktop.
chaotic_attractor.R
This file contains hidden or 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
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