Skip to content

Instantly share code, notes, and snippets.

@cybernar
Created January 21, 2019 19:01
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 cybernar/8d8909318d42399ab37d8dc4d465ea34 to your computer and use it in GitHub Desktop.
Save cybernar/8d8909318d42399ab37d8dc4d465ea34 to your computer and use it in GitHub Desktop.
# random walk
f_point_in_circle <- function(x_from, y_from, step_dist=10, step_number=100) {
angle <- runif(step_number, 0, 360)
x_diff <- step_dist * cos(angle)
y_diff <- step_dist * sin(angle)
x_pos <- x_from + cumsum(x_diff)
y_pos <- y_from + cumsum(y_diff)
cbind(x=x_pos, y=y_pos)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment