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,
.dimensions = 1
)
.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. |
.dimensions |
The default is 1. Allowable values are 1, 2 and 3. |
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 containing the generated random walks with columns depending on the number of dimensions:
walk_number: Factor representing the walk number.
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 following are also returned based upon how many dimensions there are and could be any of x, y and or z:
cum_sum: Cumulative sum of dplyr::all_of(.dimensions).
cum_prod: Cumulative product of dplyr::all_of(.dimensions).
cum_min: Cumulative minimum of dplyr::all_of(.dimensions).
cum_max: Cumulative maximum of dplyr::all_of(.dimensions).
cum_mean: Cumulative mean of dplyr::all_of(.dimensions).
Steven P. Sanderson II, MPH
Other Generator Functions:
brownian_motion(),
discrete_walk(),
geometric_brownian_motion(),
random_beta_walk(),
random_binomial_walk(),
random_cauchy_walk(),
random_chisquared_walk(),
random_displacement_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_walk(),
random_poisson_walk(),
random_smirnov_walk(),
random_t_walk(),
random_uniform_walk(),
random_weibull_walk(),
random_wilcox_walk(),
random_wilcoxon_sr_walk()
Other Continuous Distribution:
brownian_motion(),
geometric_brownian_motion(),
random_beta_walk(),
random_cauchy_walk(),
random_chisquared_walk(),
random_exponential_walk(),
random_f_walk(),
random_gamma_walk(),
random_logistic_walk(),
random_lognormal_walk(),
random_normal_walk(),
random_t_walk(),
random_uniform_walk(),
random_weibull_walk()
set.seed(123)
random_normal_drift_walk()
set.seed(123)
random_normal_drift_walk(.dimensions = 3) |>
head() |>
t()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.