crw | R Documentation |
Simulate a random walk as series of equal-length steps with turning angles drawn from a normal distribution.
crw(
theta = c(0, 5),
stepLen = 10,
initPos = c(0, 0),
initHeading = 0,
nsteps = 10000
)
theta |
A 2-element numeric vector with turn angle parameters
( |
stepLen |
A numeric scalar with total distance moved in each step. |
initPos |
A 2-element numeric vector with nital position ( |
initHeading |
A numeric scalar with initial heading in degrees. |
nsteps |
A numeric scalar with number of steps to simulate. |
First, nsteps turn angles are drawn from a normal distribution. Second, the cumulative sum of the vector of turn angles defines the heading within each step. The x and y component vectors in each are then calculated and summed to obtain the simualted path.
A two-column data frame containing:
x |
x coordinates |
y |
y coordinates |
Adapted from code provided by Tom Binder.
C. Holbrook (cholbrook@usgs.gov)
foo <- crw(
theta = c(0, 5), stepLen = 10, initPos = c(0, 0), initHeading = 0,
nsteps = 10
)
plot(foo, type = "o", pch = 20, asp = c(1, 1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.