View source: R/gen-random-normal-walk-drift.R
random_normal_drift_walk | R Documentation |
This function generates a specified number of random walks, each consisting of a specified number of steps. The steps are generated from a normal distribution with a given mean and standard deviation. An additional drift term is added to each step to introduce a consistent directional component to the walks.
random_normal_drift_walk(
.num_walks = 25,
.n = 100,
.mu = 0,
.sd = 1,
.drift = 0.1,
.initial_value = 0
)
.num_walks |
Integer. The number of random walks to generate. Default is 25. |
.n |
Integer. The number of steps in each random walk. Default is 100. |
.mu |
Numeric. The mean of the normal distribution used for generating steps. Default is 0. |
.sd |
Numeric. The standard deviation of the normal distribution used for generating steps. Default is 1. |
.drift |
Numeric. The drift term to be added to each step. Default is 0.1. |
.initial_value |
A numeric value indicating the initial value of the walks. Default is 0. |
This function generates multiple random walks with a specified drift. Each walk is generated using a normal distribution for the steps, with an additional drift term added to each step.
A tibble in long format with columns walk_number
, x
(step index),
and y
(walk value). The tibble has attributes for the number of walks,
number of steps, mean, standard deviation, and drift.
Steven P. Sanderson II, MPH
Other Generator Functions:
brownian_motion()
,
discrete_walk()
,
geometric_brownian_motion()
,
random_normal_walk()
set.seed(123)
random_normal_drift_walk(.num_walks = 10, .n = 50, .mu = 0, .sd = 1.2,
.drift = 0.05, .initial_value = 100) |>
visualize_walks()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.