discrete_walk {RandomWalker}R Documentation

Discrete Sampled Walk

Description

The discrete_walk function generates multiple random walks over discrete time periods. Each step in the walk is determined by a probabilistic sample from specified upper and lower bounds. This function is useful for simulating stochastic processes, such as stock price movements or other scenarios where outcomes are determined by a random process.

Usage

discrete_walk(
  .num_walks = 25,
  .n = 100,
  .upper_bound = 1,
  .lower_bound = -1,
  .upper_probability = 0.5,
  .initial_value = 100,
  .dimensions = 1
)

Arguments

.num_walks

Total number of simulations.

.n

Total time of the simulation.

.upper_bound

The upper bound of the random walk.

.lower_bound

The lower bound of the random walk.

.upper_probability

The probability of the upper bound. Default is 0.5. The lower bound is calculated as 1 - .upper_probability.

.initial_value

The initial value of the random walk. Default is 100.

.dimensions

The default is 1. Allowable values are 1, 2 and 3.

Details

The function discrete_walk simulates random walks for a specified number of simulations (.num_walks) over a given total time (.n). Each step in the walk is either the upper bound or the lower bound, determined by a probability (.upper_probability). The initial value of the walk is set by the user (.initial_value), and the cumulative sum, product, minimum, and maximum of the steps are calculated for each walk. The results are returned in a tibble with detailed attributes, including the parameters used for the simulation.

Value

A tibble containing the generated random walks with columns depending on the number of dimensions:

The following are also returned based upon how many dimensions there are and could be any of x, y and or z:

Author(s)

Steven P. Sanderson II, MPH

See Also

Other Generator Functions: brownian_motion(), geometric_brownian_motion(), random_normal_drift_walk(), random_normal_walk()

Examples

set.seed(123)
discrete_walk()

set.seed(123)
discrete_walk(.dimensions = 3) |>
  head() |>
  t()


[Package RandomWalker version 0.3.0 Index]