
Generate a Random Displacement Walk in 2D
Source:R/gen-random-displacement-walk.R
random_displacement_walk.Rd
The random_displacement_walk
function generates a single random walk in 2 dimensions (x, y),
where each step is a random displacement in both x and y directions, sampled from the provided
displacement and distance spaces. The walk disregards steps where both x and y displacements are zero.
Arguments
- .num_walks
An integer specifying the number of random walks to generate. Default is 25.
- .seed
An optional value to set the random seed. If NULL, no seed is set. Default is NULL.
- .n
The number of steps in the walk. Must be >= 0. Default is 100.
- .distance_space
A numeric vector of possible step distances. Default is c(0, 1, 2, 3, 4).
- .displacement
A numeric vector of possible step directions. Default is c(-1, 1).
- .dimensions
An integer specifying the number of dimensions (1, 2, or 3). Default is 1.
Value
A tibble with columns depending on the number of dimensions:
step_number
: Step index.y
: If.dimensions = 1
, the value of the walk at each step.x
,y
: If.dimensions = 2
, the values of the walk in two dimensions.x
,y
,z
: If.dimensions = 3
, the values of the walk in three dimensions.
The tibble includes attributes for the function parameters.
See also
Other Generator Functions:
brownian_motion()
,
discrete_walk()
,
geometric_brownian_motion()
,
random_beta_walk()
,
random_binomial_walk()
,
random_cauchy_walk()
,
random_chisquared_walk()
,
random_exponential_walk()
,
random_f_walk()
,
random_gamma_walk()
,
random_geometric_walk()
,
random_hypergeometric_walk()
,
random_logistic_walk()
,
random_lognormal_walk()
,
random_multinomial_walk()
,
random_negbinomial_walk()
,
random_normal_drift_walk()
,
random_normal_walk()
,
random_poisson_walk()
,
random_smirnov_walk()
,
random_t_walk()
,
random_uniform_walk()
,
random_weibull_walk()
,
random_wilcox_walk()
,
random_wilcoxon_sr_walk()
Other Discrete Distribution:
discrete_walk()
,
random_binomial_walk()
,
random_geometric_walk()
,
random_hypergeometric_walk()
,
random_multinomial_walk()
,
random_negbinomial_walk()
,
random_poisson_walk()
,
random_smirnov_walk()
,
random_wilcox_walk()
,
random_wilcoxon_sr_walk()
Examples
random_displacement_walk(.n = 10, .seed = Sys.Date())
#> # A tibble: 275 × 3
#> walk_number step_number y
#> <fct> <dbl> <dbl>
#> 1 1 1 0
#> 2 1 2 1
#> 3 1 3 -2
#> 4 1 4 -5
#> 5 1 5 -9
#> 6 1 6 -7
#> 7 1 7 -10
#> 8 1 8 -6
#> 9 1 9 -2
#> 10 1 10 -3
#> # ℹ 265 more rows