ayusef/step-1
# random walk set.seed(1) # set up nine directions dirs <- matrix(c(rep(seq(-1, 1), 3), rep(seq(-1, 1), each=3)), ncol=2, byrow=T) # start in the center cpos <- matrix(c(0, 0), ncol=2) # set full screen par(mar=c(0,0,0,0)) # take 200 steps for(i in seq(200)) { plot(cpos, type="p", col="gray80", xlim=c(-20, 20), ylim=c(-20,20), yaxt="n", ann=FALSE, xaxt="n", bty="n") cpos <- rbind(cpos, cpos[nrow(cpos), ] + dirs[sample(1:9, 1), ]) points(cpos[nrow(cpos), 1], cpos[nrow(cpos), 2], type="p", pch=16, col="red") Sys.sleep(0.1) } # reset screen back to default par(mar=c(5.1,4.1,4.1,2.1)) Jacobs, Jay, and Rudis, Bob. Data-Driven Security : Analysis, Visualization and Dashboards (1). Somerset, US: Wiley, 2014. ProQuest ebrary. Web. 17 July 2016. Copyright © 2014. Wiley. All rights reserved.
# random walk set.seed(1) # set up nine directions dirs <- matrix(c(rep(seq(-1, 1), 3), rep(seq(-1, 1), each=3)), ncol=2, byrow=T) # start in the center cpos <- matrix(c(0, 0), ncol=2) # set full screen par(mar=c(0,0,0,0)) # take 200 steps for(i in seq(200)) { plot(cpos, type="p", col="gray80", xlim=c(-20, 20), ylim=c(-20,20), yaxt="n", ann=FALSE, xaxt="n", bty="n") cpos <- rbind(cpos, cpos[nrow(cpos), ] + dirs[sample(1:9, 1), ]) points(cpos[nrow(cpos), 1], cpos[nrow(cpos), 2], type="p", pch=16, col="red") Sys.sleep(0.1) } # reset screen back to default par(mar=c(5.1,4.1,4.1,2.1)) Jacobs, Jay, and Rudis, Bob. Data-Driven Security : Analysis, Visualization and Dashboards (1). Somerset, US: Wiley, 2014. ProQuest ebrary. Web. 17 July 2016. Copyright © 2014. Wiley. All rights reserved.
Read full text or abstract (792 characters)
Cite this record
MLA
"ayusef/step-1." Software Heritage origin index (GitHub origins), n.d., https://git.go-v.org/record/ayusef%2Fstep-1.
Chicago
"ayusef/step-1." Software Heritage origin index (GitHub origins). n.d.. https://git.go-v.org/record/ayusef%2Fstep-1.
APA
Software Heritage origin index (GitHub origins). (n.d.). ayusef/step-1. https://git.go-v.org/record/ayusef%2Fstep-1