diff --git a/NEWS.md b/NEWS.md index b89671b..07542d3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,14 +1,17 @@ # RandomWalker (development version) ## Breaing Changes -None +1. Fix #107 - This change allows for the generation of random walks with up to 3 dimensions. +Due to this what was the `x` column is now called `step_number` for all random walk +functions including rw30(). The `x` column is now the first dimension of a 2d/3d random walk. ## New Features 1. Fix #105 - Add internal function `rand_walk_column_names()` to generate column names for random walks. ## Minor Fixes and Improvements -1. +1. Fix #107 - Add `.dimensions` parameter to random walk functions to allow for +the generation of random walks with up to 3 dimensions. # RandomWalker 0.2.0 diff --git a/R/00_global_variables.R b/R/00_global_variables.R index 22668cb..1f3f2e7 100644 --- a/R/00_global_variables.R +++ b/R/00_global_variables.R @@ -1,5 +1,6 @@ globalVariables( names = c( - "walk_number","x","y","value","name", "cum_sum","cum_prod",".tooltip" + "walk_number","x","y","value","name", "cum_sum","cum_prod",".tooltip", + "step_number","" ) ) diff --git a/R/auto-rw30.R b/R/auto-rw30.R index 947a612..495fcc8 100644 --- a/R/auto-rw30.R +++ b/R/auto-rw30.R @@ -64,7 +64,8 @@ rw30 <- function() { ) |> dplyr::mutate(walk_number = factor(walk_number, levels = 1:num_walks)) |> dplyr::select(walk_number, x, y) |> - dplyr::arrange(walk_number, x) + dplyr::arrange(walk_number, x) |> + dplyr::rename(step_number = x) attr(walks_long, "num_walks") <- num_walks attr(walks_long, "num_steps") <- num_steps diff --git a/R/gen-brown-motion-geometric.R b/R/gen-brown-motion-geometric.R index 8e79672..091b839 100644 --- a/R/gen-brown-motion-geometric.R +++ b/R/gen-brown-motion-geometric.R @@ -39,19 +39,37 @@ #' @param .initial_value Integer representing the initial value. #' @param .mu Expected return #' @param .sigma Volatility -#' @param .return_tibble The default is TRUE. If set to FALSE then an object -#' of class matrix will be returned. +#' @param .dimensions The default is 1. Allowable values are 1, 2 and 3. #' #' @examples +#' #' set.seed(123) #' geometric_brownian_motion() #' #' set.seed(123) -#' geometric_brownian_motion(.num_walks = 5) |> -#' visualize_walks() +#' geometric_brownian_motion(.dimensions = 3) |> +#' head() |> +#' t() +#' +#' @return A tibble containing the generated random walks with columns depending +#' on the number of dimensions: +#' \itemize{ +#' \item `walk_number`: Factor representing the walk number. +#' \item `step_number`: Step index. +#' \item `y`: If `.dimensions = 1`, the value of the walk at each step. +#' \item `x`, `y`: If `.dimensions = 2`, the values of the walk in two dimensions. +#' \item `x`, `y`, `z`: If `.dimensions = 3`, the values of the walk in three dimensions. +#' } #' -#' @return -#' A tibble/matrix +#' The following are also returned based upon how many dimensions there are and +#' could be any of x, y and or z: +#' \itemize{ +#' \item `cum_sum`: Cumulative sum of `dplyr::all_of(.dimensions)`. +#' \item `cum_prod`: Cumulative product of `dplyr::all_of(.dimensions)`. +#' \item `cum_min`: Cumulative minimum of `dplyr::all_of(.dimensions)`. +#' \item `cum_max`: Cumulative maximum of `dplyr::all_of(.dimensions)`. +#' \item `cum_mean`: Cumulative mean of `dplyr::all_of(.dimensions)`. +#' } #' #' @name geometric_brownian_motion NULL @@ -63,7 +81,7 @@ geometric_brownian_motion <- function(.num_walks = 25, .n = 100, .mu = 0, .sigma = 0.1, .initial_value = 100, .delta_time = 0.003, - .return_tibble = TRUE) { + .dimensions = 1) { # Tidyeval ---- # Thank you to https://robotwealth.com/efficiently-simulating-geometric-brownian-motion-in-r/ @@ -73,15 +91,8 @@ geometric_brownian_motion <- function(.num_walks = 25, .n = 100, sigma <- as.numeric(.sigma) initial_value <- as.numeric(.initial_value) delta_time <- as.numeric(.delta_time) - return_tibble <- as.logical(.return_tibble) # Checks ---- - if (!is.logical(return_tibble)){ - rlang::abort( - message = "The paramter `.return_tibble` must be either TRUE/FALSE", - use_cli_format = TRUE - ) - } if (!is.numeric(num_sims) | !is.numeric(t) | !is.numeric(mu) | !is.numeric(sigma) | !is.numeric(initial_value) | !is.numeric(delta_time)){ @@ -107,28 +118,54 @@ geometric_brownian_motion <- function(.num_walks = 25, .n = 100, use_cli_format = TRUE ) } + if (!.dimensions %in% c(1, 2, 3)) { + rlang::abort("Number of dimensions must be 1, 2, or 3.", use_cli = TRUE) + } + + # Define dimension names + dim_names <- switch(.dimensions, + `1` = c("y"), + `2` = c("x", "y"), + `3` = c("x", "y", "z")) # matrix of random draws - one for each day for each simulation - rand_matrix <- matrix(stats::rnorm(t * num_sims), ncol = num_sims, nrow = t) - colnames(rand_matrix) <- 1:num_sims + generate_gbm <- function(num_sims){ + rand_steps <- purrr::map( + dim_names, + ~ exp((mu - sigma * sigma / 2) * delta_time + sigma * stats::rnorm(t) * sqrt(delta_time)) |> + cumprod() + ) - # get GBM and convert to price paths - res <- exp((mu - sigma * sigma / 2) * delta_time + sigma * rand_matrix * sqrt(delta_time)) - res <- apply(rbind(rep(initial_value, num_sims), res), 2, cumprod) + # Set column names + # rand_steps <- stats::setNames(rand_steps, dim_names) + # rand_steps <- purrr::map(rand_steps, \(x) dplyr::as_tibble(x)) |> + # purrr::list_cbind() + # colnames(rand_steps) <- dim_names + # rand_steps <- purrr::map( + # rand_steps, \(x) x |> + # unlist(use.names = FALSE)) |> + # dplyr::as_tibble() + # + # # Combine into a tibble + # dplyr::tibble( + # walk_number = factor(num_sims), + # step_number = 1:t + # ) |> + # dplyr::bind_cols(rand_steps) + rand_walk_column_names(rand_steps, dim_names, num_sims, t) + } + + res <- purrr::map(1:num_sims, ~ generate_gbm(.x)) |> + dplyr::bind_rows() |> + dplyr::select(walk_number, step_number, dplyr::all_of(dim_names)) |> + dplyr::mutate(walk_number = factor(walk_number, levels = 1:num_sims)) |> + dplyr::group_by(walk_number) |> + std_cum_min_augment(.value = dplyr::all_of(dim_names), .initial_value = initial_value) |> + std_cum_max_augment(.value = dplyr::all_of(dim_names), .initial_value = initial_value) |> + std_cum_mean_augment(.value = dplyr::all_of(dim_names), .initial_value = initial_value) |> + dplyr::ungroup() # Return - if (return_tibble){ - res <- res |> - dplyr::as_tibble() |> - dplyr::mutate(t = 1:(t+1)) |> - tidyr::pivot_longer(-t) |> - dplyr::select(name, t, value) |> - purrr::set_names("walk_number", "x", "y") |> - dplyr::mutate(walk_number = factor(walk_number, levels = 1:num_sims)) |> - dplyr::arrange(walk_number, x) |> - rand_walk_helper(.value = initial_value) |> - dplyr::select(-cum_sum, -cum_prod) - } attr(res, "n") <- .n attr(res, "num_walks") <- .num_walks @@ -136,9 +173,8 @@ geometric_brownian_motion <- function(.num_walks = 25, .n = 100, attr(res, "sigma") <- .sigma attr(res, "initial_value") <- .initial_value attr(res, "delta_time") <- .delta_time - attr(res, "return_tibble") <- .return_tibble attr(res, "fns") <- "geometric_brownian_motion" - attr(res, "dimension") <- 1 + attr(res, "dimension") <- .dimensions return(res) } diff --git a/R/gen-brown-motion.R b/R/gen-brown-motion.R index a351f94..b9a62a3 100644 --- a/R/gen-brown-motion.R +++ b/R/gen-brown-motion.R @@ -28,19 +28,34 @@ #' @param .num_walks Total number of simulations. #' @param .delta_time Time step size. #' @param .initial_value Integer representing the initial value. -#' @param .return_tibble The default is TRUE. If set to FALSE then an object -#' of class matrix will be returned. +#' @param .dimensions The default is 1. Allowable values are 1, 2 and 3. #' #' @examples #' set.seed(123) #' brownian_motion() #' #' set.seed(123) -#' brownian_motion(.num_walks = 5) |> -#' visualize_walks() +#' brownian_motion(.dimensions = 3) |> +#' head() |> +#' t() #' -#' @return -#' A tibble/matrix +#' @return A tibble containing the generated random walks with columns depending on the number of dimensions: +#' \itemize{ +#' \item `walk_number`: Factor representing the walk number. +#' \item `step_number`: Step index. +#' \item `y`: If `.dimensions = 1`, the value of the walk at each step. +#' \item `x`, `y`: If `.dimensions = 2`, the values of the walk in two dimensions. +#' \item `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: +#' \itemize{ +#' \item `cum_sum`: Cumulative sum of `dplyr::all_of(.dimensions)`. +#' \item `cum_prod`: Cumulative product of `dplyr::all_of(.dimensions)`. +#' \item `cum_min`: Cumulative minimum of `dplyr::all_of(.dimensions)`. +#' \item `cum_max`: Cumulative maximum of `dplyr::all_of(.dimensions)`. +#' \item `cum_mean`: Cumulative mean of `dplyr::all_of(.dimensions)`. +#' } #' #' @name brownian_motion NULL @@ -49,14 +64,13 @@ NULL #' @rdname brownian_motion brownian_motion <- function(.num_walks = 25, .n = 100, .delta_time = 1, - .initial_value = 0, .return_tibble = TRUE) { + .initial_value = 0, .dimensions = 1) { # Tidyeval ---- num_sims <- as.numeric(.num_walks) t <- as.numeric(.n) initial_value <- as.numeric(.initial_value) delta_time <- as.numeric(.delta_time) - return_tibble <- as.logical(.return_tibble) # Checks if (!is.numeric(num_sims) | !is.numeric(t) | !is.numeric(initial_value) | @@ -83,43 +97,62 @@ brownian_motion <- function(.num_walks = 25, .n = 100, .delta_time = 1, ) } - if (!is.logical(return_tibble)){ - rlang::abort( - message = "The parameter `.return_tibble` must be either TRUE/FALSE", - use_cli_format = TRUE - ) + if (!.dimensions %in% c(1, 2, 3)) { + rlang::abort("Number of dimensions must be 1, 2, or 3.", use_cli = TRUE) } - # Matrix of random draws - one for each simulation - rand_matrix <- matrix(stats::rnorm(t * num_sims, mean = 0, sd = sqrt(delta_time)), - ncol = num_sims, nrow = t) - colnames(rand_matrix) <- 1:num_sims + # Define dimension names + dim_names <- switch(.dimensions, + `1` = c("y"), + `2` = c("x", "y"), + `3` = c("x", "y", "z")) - # Get the Brownian Motion and convert to price paths - res <- apply(rbind(rep(initial_value, num_sims), rand_matrix), 2, cumsum) + # Matrix of random draws - one for each simulation + generate_brownian_motion <- function(num_sims) { + rand_steps <- purrr::map( + dim_names, + ~ stats::rnorm(t, mean = 0, sd = sqrt(delta_time)) + ) - # Return - if (return_tibble){ - res <- res |> - dplyr::as_tibble() |> - dplyr::mutate(t = 1:(t+1)) |> - tidyr::pivot_longer(-t) |> - dplyr::select(name, t, value) |> - purrr::set_names("walk_number", "x", "y") |> - dplyr::mutate(walk_number = factor(walk_number, levels = 1:num_sims)) |> - dplyr::arrange(walk_number, x) |> - rand_walk_helper(.value = initial_value) |> - dplyr::select(-cum_sum, -cum_prod) + # Set column names + # rand_steps <- stats::setNames(rand_steps, dim_names) + # rand_steps <- purrr::map(rand_steps, \(x) dplyr::as_tibble(x)) |> + # purrr::list_cbind() + # colnames(rand_steps) <- dim_names + # rand_steps <- purrr::map( + # rand_steps, \(x) x |> + # unlist(use.names = FALSE)) |> + # dplyr::as_tibble() + # + # # Combine into a tibble + # dplyr::tibble( + # walk_number = factor(num_sims), + # step_number = 1:t + # ) |> + # dplyr::bind_cols(rand_steps) + rand_walk_column_names(rand_steps, dim_names, num_sims, t) } + # Get the Brownian Motion and convert to price paths + res <- purrr::map(1:num_sims, ~ generate_brownian_motion(.x)) |> + dplyr::bind_rows() |> + dplyr::select(walk_number, step_number, dplyr::any_of(dim_names)) |> + dplyr::mutate(walk_number = factor(walk_number, levels = 1:num_sims)) |> + dplyr::group_by(walk_number) |> + std_cum_sum_augment(.value = dplyr::all_of(dim_names), .initial_value = initial_value) |> + std_cum_prod_augment(.value = dplyr::all_of(dim_names), .initial_value = initial_value) |> + std_cum_min_augment(.value = dplyr::all_of(dim_names), .initial_value = initial_value) |> + std_cum_max_augment(.value = dplyr::all_of(dim_names), .initial_value = initial_value) |> + std_cum_mean_augment(.value = dplyr::all_of(dim_names), .initial_value = initial_value) |> + dplyr::ungroup() + # Return ---- attr(res, "n") <- .n attr(res, "num_walks") <- .num_walks attr(res, "delta_time") <- .delta_time attr(res, "initial_value") <- .initial_value - attr(res, "return_tibble") <- .return_tibble attr(res, "fns") <- "brownian_motion" - attr(res, "dimension") <- 1 + attr(res, "dimension") <- .dimensions return(res) } diff --git a/R/gen-discrete-walk.R b/R/gen-discrete-walk.R index 13ee1ca..5aefa01 100644 --- a/R/gen-discrete-walk.R +++ b/R/gen-discrete-walk.R @@ -25,21 +25,36 @@ #' @param .upper_probability The probability of the upper bound. Default is 0.5. #' The lower bound is calculated as 1 - .upper_probability. #' @param .initial_value The initial value of the random walk. Default is 100. +#' @param .dimensions The default is 1. Allowable values are 1, 2 and 3. #' #' @examples -#' library(ggplot2) -#' #' set.seed(123) #' discrete_walk() #' #' set.seed(123) -#' discrete_walk(.num_walks = 10, .n = 250, .upper_probability = 0.51, -#' .initial_value = 100) |> -#' visualize_walks() +#' discrete_walk(.dimensions = 3) |> +#' head() |> +#' t() +#' +#' @return A tibble containing the generated random walks with columns depending +#' on the number of dimensions: +#' \itemize{ +#' \item `walk_number`: Factor representing the walk number. +#' \item `step_number`: Step index. +#' \item `y`: If `.dimensions = 1`, the value of the walk at each step. +#' \item `x`, `y`: If `.dimensions = 2`, the values of the walk in two dimensions. +#' \item `x`, `y`, `z`: If `.dimensions = 3`, the values of the walk in three dimensions. +#' } #' -#' @return -#' A tibble containing the simulated walks, with columns for the walk number, -#' time period, and various cumulative metrics (sum, product, min, max). +#' The following are also returned based upon how many dimensions there are and +#' could be any of x, y and or z: +#' \itemize{ +#' \item `cum_sum`: Cumulative sum of `dplyr::all_of(.dimensions)`. +#' \item `cum_prod`: Cumulative product of `dplyr::all_of(.dimensions)`. +#' \item `cum_min`: Cumulative minimum of `dplyr::all_of(.dimensions)`. +#' \item `cum_max`: Cumulative maximum of `dplyr::all_of(.dimensions)`. +#' \item `cum_mean`: Cumulative mean of `dplyr::all_of(.dimensions)`. +#' } #' #' @name discrete_walk NULL @@ -48,16 +63,17 @@ NULL discrete_walk <- function(.num_walks = 25, .n = 100, .upper_bound = 1, .lower_bound = -1, .upper_probability = 0.5, - .initial_value = 100) { + .initial_value = 100, .dimensions = 1) { # Variables num_walks <- as.integer(.num_walks) - periods <- as.integer(.n) + t <- as.integer(.n) upper_bound <- as.numeric(.upper_bound) lower_bound <- as.numeric(.lower_bound) upper_probability <- as.numeric(.upper_probability) lower_probability <- 1 - upper_probability initial_value <- as.numeric(.initial_value) + dimensions <- as.integer(.dimensions) # Checks if (!is.integer(num_walks) | num_walks < 1) { @@ -67,7 +83,7 @@ discrete_walk <- function(.num_walks = 25, .n = 100, .upper_bound = 1, ) } - if (!is.integer(periods) | periods < 1) { + if (!is.integer(t) | t < 1) { rlang::abort( message = "The number of periods must be an integer greater than 0.", use_cli_format = TRUE @@ -78,53 +94,112 @@ discrete_walk <- function(.num_walks = 25, .n = 100, .upper_bound = 1, rlang::abort( message = "The upper bound must be a numeric value.", use_cli_format = TRUE - ) + ) } if (!is.numeric(lower_bound)) { rlang::abort( message = "The lower bound must be a numeric value.", use_cli_format = TRUE - ) + ) } if (!is.numeric(upper_probability) | upper_probability < 0 | upper_probability > 1) { rlang::abort( message = "The upper probability must be a numeric value between 0 and 1.", use_cli_format = TRUE - ) + ) } if (!is.numeric(initial_value)) { rlang::abort( message = "The initial value must be a numeric value.", use_cli_format = TRUE + ) + } + + if (!is.integer(dimensions) | dimensions < 1 | dimensions > 3) { + rlang::abort( + message = "The number of dimensions must be an integer between 1 and 3.", + use_cli_format = TRUE + ) + } + + if (!.dimensions %in% c(1, 2, 3)) { + rlang::abort( + message = "The number of dimensions must be an integer between 1 and 3.", + use_cli_format = TRUE + ) + } + + # Define dimension names + dim_names <- switch(.dimensions, + `1` = c("y"), + `2` = c("x", "y"), + `3` = c("x", "y", "z")) + + # Generate walks for each dimension + single_discrete_walk <- function(t, upper_bound, lower_bound, + upper_probability, lower_probability){ + rand_steps <- purrr::map( + dim_names, + ~ replicate( + n = t, + sample( + x = c(upper_bound, lower_bound), + size = 1, + prob = c(upper_probability, lower_probability)) ) + ) + + # Set Column Names + # rand_steps <- stats::setNames(rand_steps, dim_names) + # rand_steps <- purrr::map(rand_steps, \(x) dplyr::as_tibble(x)) |> + # purrr::list_cbind() + # colnames(rand_steps) <- dim_names + # rand_steps <- purrr::map( + # rand_steps, \(x) x |> + # unlist(use.names = FALSE)) |> + # dplyr::as_tibble() + # + # # Combine into a tibble + # dplyr::tibble( + # walk_number = factor(num_walks), + # step_number = 1:t + # ) |> + # dplyr::bind_cols(rand_steps) + rand_walk_column_names(rand_steps, dim_names, num_walks, t) } - res <- tidyr::expand_grid(walk_number = factor(1:num_walks), x = 1:periods) |> + # Generate walks + walks <- purrr::map( + 1:num_walks, + ~ single_discrete_walk(t, upper_bound, lower_bound, + upper_probability, lower_probability) + ) + + # Create a tibble with all walks for all dimensions + res <- dplyr::bind_rows(walks, .id = "walk_number") |> + dplyr::mutate(walk_number = factor(walk_number, levels = 1:num_walks)) |> dplyr::group_by(walk_number) |> - dplyr::mutate(y = replicate( - n = periods, - sample( - x = c(upper_bound, lower_bound), - size = 1, - prob = c(upper_probability, lower_probability)) - ) - ) |> - dplyr::ungroup() |> - rand_walk_helper(.value = initial_value) + dplyr::select(walk_number, step_number, dplyr::all_of(dim_names)) |> + std_cum_sum_augment(.value = dplyr::all_of(dim_names), .initial_value = initial_value) |> + std_cum_prod_augment(.value = dplyr::all_of(dim_names), .initial_value = initial_value) |> + std_cum_min_augment(.value = dplyr::all_of(dim_names), .initial_value = initial_value) |> + std_cum_max_augment(.value = dplyr::all_of(dim_names), .initial_value = initial_value) |> + std_cum_mean_augment(.value = dplyr::all_of(dim_names), .initial_value = initial_value) |> + dplyr::ungroup() # Attributes - attr(res, "n") <- periods - attr(res, "num_walks") <- .num_walks + attr(res, "n") <- t + attr(res, "num_walks") <- num_walks attr(res, "upper_bound") <- upper_bound attr(res, "lower_bound") <- lower_bound attr(res, "upper_probability") <- upper_probability attr(res, "lower_probability") <- lower_probability attr(res, "initial_value") <- initial_value attr(res, "fns") <- "discrete_walk" - attr(res, "dimension") <- 1 + attr(res, "dimension") <- dimensions # Return return(res) diff --git a/R/gen-random-normal-walk-drift.R b/R/gen-random-normal-walk-drift.R index 1502044..38a629e 100644 --- a/R/gen-random-normal-walk-drift.R +++ b/R/gen-random-normal-walk-drift.R @@ -22,24 +22,44 @@ #' @param .sd Numeric. The standard deviation of the normal distribution used for generating steps. Default is 1. #' @param .drift Numeric. The drift term to be added to each step. Default is 0.1. #' @param .initial_value A numeric value indicating the initial value of the walks. Default is 0. +#' @param .dimensions The default is 1. Allowable values are 1, 2 and 3. #' #' @examples #' 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() +#' random_normal_drift_walk() #' -#' @return 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. +#' set.seed(123) +#' random_normal_drift_walk(.dimensions = 3) |> +#' head() |> +#' t() +#' +#' @return A tibble containing the generated random walks with columns depending +#' on the number of dimensions: +#' \itemize{ +#' \item `walk_number`: Factor representing the walk number. +#' \item `step_number`: Step index. +#' \item `y`: If `.dimensions = 1`, the value of the walk at each step. +#' \item `x`, `y`: If `.dimensions = 2`, the values of the walk in two dimensions. +#' \item `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: +#' \itemize{ +#' \item `cum_sum`: Cumulative sum of `dplyr::all_of(.dimensions)`. +#' \item `cum_prod`: Cumulative product of `dplyr::all_of(.dimensions)`. +#' \item `cum_min`: Cumulative minimum of `dplyr::all_of(.dimensions)`. +#' \item `cum_max`: Cumulative maximum of `dplyr::all_of(.dimensions)`. +#' \item `cum_mean`: Cumulative mean of `dplyr::all_of(.dimensions)`. +#' } #' #' @name random_normal_drift_walk NULL #' @rdname random_normal_drift_walk #' @export -random_normal_drift_walk <- function(.num_walks = 25, .n = 100, .mu = 0, - .sd = 1, .drift = 0.1, .initial_value = 0) { +random_normal_drift_walk <- function(.num_walks = 25, .n = 100, .mu = 0, .sd = 1, + .drift = 0.1, .initial_value = 0, .dimensions = 1) { # Convert inputs to appropriate types num_walks <- as.integer(.num_walks) @@ -48,92 +68,91 @@ random_normal_drift_walk <- function(.num_walks = 25, .n = 100, .mu = 0, sd <- as.numeric(.sd) drift <- as.numeric(.drift) initial_value <- as.numeric(.initial_value) - dr <- seq(from = drift, to = drift * num_steps, length.out = num_steps) # Checks if (num_walks <= 0) { - rlang::abort( - message = "Number of walks must be a positive integer.", - use_cli = TRUE - ) + rlang::abort("Number of walks must be a positive integer.", use_cli = TRUE) } - if (num_steps <= 0) { - rlang::abort( - message = "Number of steps must be a positive integer.", - use_cli = TRUE - ) + rlang::abort("Number of steps must be a positive integer.", use_cli = TRUE) } - if (sd <= 0) { - rlang::abort( - message = "Standard deviation must be a positive number.", - use_cli = TRUE - ) + rlang::abort("Standard deviation must be a positive number.", use_cli = TRUE) } - if (is.na(mu)) { - rlang::abort( - message = "Mean must be a number.", - use_cli = TRUE - ) + rlang::abort("Mean must be a number.", use_cli = TRUE) } - if (is.na(drift)) { - rlang::abort( - message = "Drift must be a number.", - use_cli = TRUE - ) + rlang::abort("Drift must be a number.", use_cli = TRUE) } - if (is.na(initial_value)) { - rlang::abort( - message = "Initial value must be a number.", - use_cli = TRUE - ) + rlang::abort("Initial value must be a number.", use_cli = TRUE) } - - # Function to generate a single random walk - single_random_walk_with_drift <- function(num_steps, mu, sd, drift) { - wn <- stats::rnorm(n = num_steps, mean = mu, sd = sd) - rw <- cumsum(stats::rnorm(n = num_steps, mean = mu, sd = sd)) - res <- wn + rw + dr - return(res) + if (!.dimensions %in% c(1, 2, 3)) { + rlang::abort("Number of dimensions must be 1, 2, or 3.", use_cli = TRUE) } - # Generate the walks - walks <- replicate( - num_walks, - single_random_walk_with_drift(num_steps, mu, sd, drift), - simplify = FALSE + # Create drift sequences for each dimension + dr <- purrr::map( + 1:.dimensions, + ~ seq(from = drift, to = drift * num_steps, length.out = num_steps) ) - # Create a tibble with the walks - walks_tibble <- dplyr::tibble( - x = 1:num_steps, - !!!stats::setNames(walks, 1:num_walks) + # Define dimension names + dim_names <- switch(.dimensions, + `1` = c("y"), + `2` = c("x", "y"), + `3` = c("x", "y", "z")) + + # Function to generate a single random walk with drift for multiple dimensions + single_random_walk_with_drift <- function(num_steps, mu, sd, dr) { + walks_per_dim <- purrr::map2(dr, dim_names, function(drift_seq, dim) { + wn <- stats::rnorm(n = num_steps, mean = mu, sd = sd) + rw <- cumsum(wn) + res <- wn + rw + drift_seq + res + }) + + # Set Column Names + # rand_steps <- stats::setNames(walks_per_dim, dim_names) + # rand_steps <- purrr::map(rand_steps, \(x) dplyr::as_tibble(x)) |> + # purrr::list_cbind() + # colnames(rand_steps) <- dim_names + # rand_steps <- purrr::map( + # rand_steps, \(x) x |> + # unlist(use.names = FALSE)) |> + # dplyr::as_tibble() + rand_walk_column_names(walks_per_dim, dim_names, num_walks, num_steps) + } + + # Generate all walks for each dimension + walks <- purrr::map( + 1:num_walks, + ~ single_random_walk_with_drift(num_steps, mu, sd, dr) ) - # Pivot the tibble longer - walks_long <- tidyr::pivot_longer( - walks_tibble, - cols = -x, - names_to = "walk_number", - values_to = "y" - ) |> + + # Create a tibble with all walks for all dimensions + res <- dplyr::bind_rows(walks, .id = "walk_number") |> dplyr::mutate(walk_number = factor(walk_number, levels = 1:num_walks)) |> - dplyr::select(walk_number, x, y, dplyr::everything()) |> - dplyr::arrange(walk_number, x) |> - dplyr::ungroup() |> - rand_walk_helper(.value = initial_value) + dplyr::group_by(walk_number) |> + dplyr::mutate(step_number = 1:num_steps) |> + dplyr::select(walk_number, step_number, dplyr::all_of(dim_names)) |> + std_cum_sum_augment(.value = dplyr::all_of(dim_names), .initial_value = initial_value) |> + std_cum_prod_augment(.value = dplyr::all_of(dim_names), .initial_value = initial_value) |> + std_cum_min_augment(.value = dplyr::all_of(dim_names), .initial_value = initial_value) |> + std_cum_max_augment(.value = dplyr::all_of(dim_names), .initial_value = initial_value) |> + std_cum_mean_augment(.value = dplyr::all_of(dim_names), .initial_value = initial_value) |> + dplyr::ungroup() - attr(walks_long, "n") <- num_steps - attr(walks_long, "num_walks") <- num_walks - attr(walks_long, "mu") <- mu - attr(walks_long, "sd") <- sd - attr(walks_long, "drift") <- drift - attr(walks_long, "fns") <- "random_normal_drift_walk" - attr(walks_long, "dimension") <- 1 + # Add attributes + attr(res, "n") <- num_steps + attr(res, "num_walks") <- num_walks + attr(res, "mu") <- mu + attr(res, "sd") <- sd + attr(res, "drift") <- drift + attr(res, "fns") <- "random_normal_drift_walk" + attr(res, "dimensions") <- .dimensions - return(walks_long) + return(res) } diff --git a/R/gen-random-normal-walk.R b/R/gen-random-normal-walk.R index 643067c..d69cb71 100644 --- a/R/gen-random-normal-walk.R +++ b/R/gen-random-normal-walk.R @@ -1,24 +1,15 @@ -#' Generate Multiple Random Normal Walks +#' Generate Multiple Random Normal Walks in Multiple Dimensions #' #' @family Generator Functions #' #' @author Steven P. Sanderson II, MPH #' -#' @details -#' This function generates multiple random walks, which are sequences of steps -#' where each step is a random draw from a normal distribution. The user can -#' specify the number of walks, the number of steps in each walk, and the -#' parameters of the normal distribution (mean and standard deviation). The -#' function also allows for sampling a proportion of the steps and optionally -#' sampling with replacement. -#' -#' The output tibble includes several computed columns for each walk, such as the -#' cumulative sum, product, minimum, and maximum of the steps. -#' #' @description -#' The `random_normal_walk` function is useful for simulating random processes -#' and can be applied in various fields such as finance, physics, and biology -#' to model different stochastic behaviors. +#' The `random_normal_walk` function generates multiple random walks in 1, 2, or 3 dimensions. +#' Each walk is a sequence of steps where each step is a random draw from a normal distribution. +#' The user can specify the number of walks, the number of steps in each walk, and the +#' parameters of the normal distribution (mean and standard deviation). The function +#' also allows for sampling a proportion of the steps and optionally sampling with replacement. #' #' @param .num_walks An integer specifying the number of random walks to generate. Default is 25. #' @param .n An integer specifying the number of steps in each walk. Default is 100. @@ -28,8 +19,18 @@ #' @param .samp A logical value indicating whether to sample the normal distribution values. Default is TRUE. #' @param .replace A logical value indicating whether sampling is with replacement. Default is TRUE. #' @param .sample_size A numeric value between 0 and 1 specifying the proportion of `.n` to sample. Default is 0.8. +#' @param .dimensions An integer specifying the number of dimensions (1, 2, or 3). Default is 1. #' -#' @return A tibble containing the generated random walks with the following columns: +#' @return A tibble containing the generated random walks with columns depending on the number of dimensions: +#' \itemize{ +#' \item `walk_number`: Factor representing the walk number. +#' \item `step_number`: Step index. +#' \item `y`: If `.dimensions = 1`, the value of the walk at each step. +#' \item `x`, `y`: If `.dimensions = 2`, the values of the walk in two dimensions. +#' \item `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: #' \itemize{ #' \item `walk_number`: Factor representing the walk number. #' \item `x`: Step index. @@ -39,30 +40,22 @@ #' \item `cum_min`: Cumulative minimum of `y`. #' \item `cum_max`: Cumulative maximum of `y`. #' } +#' #' The tibble includes attributes for the function parameters. #' #' @examples -#' library(ggplot2) -#' -#' # Generate 10 random walks with 50 steps each -#' set.seed(123) -#' random_normal_walk(.num_walks = 10, .n = 50) -#' -#' # Generate random walks with different mean and standard deviation #' set.seed(123) -#' random_normal_walk(.num_walks = 10, .n = 50, .samp = FALSE) +#' random_normal_walk() #' #' set.seed(123) -#' random_normal_walk(.num_walks = 2, .n = 100, .initial_value = 100) |> -#' visualize_walks() +#' random_normal_walk(.dimensions = 3) |> +#' head() |> +#' t() #' -#' @name random_normal_walk -NULL -#' @rdname random_normal_walk #' @export -random_normal_walk <- function(.num_walks = 25, .n = 100, .mu = 0, .sd = .1, +random_normal_walk <- function(.num_walks = 25, .n = 100, .mu = 0, .sd = 0.1, .initial_value = 0, .samp = TRUE, .replace = TRUE, - .sample_size = 0.8) { + .sample_size = 0.8, .dimensions = 1) { # Defensive checks if (.num_walks < 0) { @@ -78,7 +71,11 @@ random_normal_walk <- function(.num_walks = 25, .n = 100, .mu = 0, .sd = .1, rlang::abort(".sd cannot be less than 0", use_cli_format = TRUE) } if (.sample_size < 0 || .sample_size > 1) { - rlang::abort(".sample_size cannot be less than 0 or more than 1", use_cli_format = TRUE) + rlang::abort(".sample_size cannot be less than 0 or more than 1", + use_cli_format = TRUE) + } + if (!.dimensions %in% c(1, 2, 3)) { + rlang::abort("Number of dimensions must be 1, 2, or 3.", use_cli = TRUE) } # Variables @@ -90,26 +87,58 @@ random_normal_walk <- function(.num_walks = 25, .n = 100, .mu = 0, .sd = .1, replace <- as.logical(.replace) samp <- as.logical(.samp) samp_size <- round(.sample_size * n, 0) - x <- if (samp) { - 1:samp_size - } else { - 1:n - } - periods <- length(x) + t <- if (samp) samp_size else n - res <- tidyr::expand_grid(walk_number = factor(1:num_walks), x = 1:periods) |> - dplyr::group_by(walk_number) |> - dplyr::mutate( - y = if (samp) { - sample(stats::rnorm(periods, mu, sd), replace = replace, size = samp_size) + # Define dimension names + dim_names <- switch(.dimensions, + `1` = c("y"), + `2` = c("x", "y"), + `3` = c("x", "y", "z")) + + # Function to generate a single random walk + generate_walk <- function(walk_num) { + # Generate random steps for each dimension + rand_steps <- purrr::map( + dim_names, + ~ if (samp) { + sample(stats::rnorm(n, mu, sd), size = t, replace = replace) } else { - stats::rnorm(periods, mu, sd) + stats::rnorm(t, mu, sd) } - ) |> - dplyr::ungroup() |> - rand_walk_helper(.value = initial_value) + ) + + # Set column names + # rand_steps <- stats::setNames(rand_steps, dim_names) + # rand_steps <- purrr::map(rand_steps, \(x) dplyr::as_tibble(x)) |> + # purrr::list_cbind() + # colnames(rand_steps) <- dim_names + # rand_steps <- purrr::map( + # rand_steps, \(x) x |> + # unlist(use.names = FALSE)) |> + # dplyr::as_tibble() + # + # # Combine into a tibble + # dplyr::tibble( + # walk_number = factor(walk_num), + # step_number = 1:periods + # ) |> + # dplyr::bind_cols(rand_steps) + rand_walk_column_names(rand_steps, dim_names, walk_num, t) + } + + # Generate all walks + res <- purrr::map_dfr(1:num_walks, generate_walk) + res <- res |> + dplyr::mutate(walk_number = factor(walk_number, levels = 1:num_walks)) |> + dplyr::group_by(walk_number) |> + std_cum_sum_augment(.value = dplyr::all_of(dim_names), .initial_value = initial_value) |> + std_cum_prod_augment(.value = dplyr::all_of(dim_names), .initial_value = initial_value) |> + std_cum_min_augment(.value = dplyr::all_of(dim_names), .initial_value = initial_value) |> + std_cum_max_augment(.value = dplyr::all_of(dim_names), .initial_value = initial_value) |> + std_cum_mean_augment(.value = dplyr::all_of(dim_names), .initial_value = initial_value) |> + dplyr::ungroup() - # Attributes + # Add attributes attr(res, "n") <- n attr(res, "num_walks") <- num_walks attr(res, "mu") <- mu @@ -118,10 +147,10 @@ random_normal_walk <- function(.num_walks = 25, .n = 100, .mu = 0, .sd = .1, attr(res, "replace") <- replace attr(res, "samp") <- samp attr(res, "samp_size") <- samp_size - attr(res, "periods") <- periods + attr(res, "periods") <- t attr(res, "fns") <- "random_normal_walk" - attr(res, "dimension") <- 1 + attr(res, "dimensions") <- .dimensions - # Return + # Return the result return(res) } diff --git a/R/plt-visualize-walks.R b/R/plt-visualize-walks.R index 846209b..df17c94 100644 --- a/R/plt-visualize-walks.R +++ b/R/plt-visualize-walks.R @@ -107,7 +107,8 @@ visualize_walks <- function(.data, .alpha = 0.7, .interactive = FALSE, .pluck = if (.interactive == FALSE) { # Create a ggplot object - p <- ggplot2::ggplot(.data, ggplot2::aes(x = x, y = get(y_var), color = walk_number)) + + p <- ggplot2::ggplot(.data, ggplot2::aes(x = step_number, y = get(y_var), + color = walk_number)) + # Plot lines with some transparency ggplot2::geom_line(alpha = .alpha) + # Use a minimal theme @@ -127,7 +128,7 @@ visualize_walks <- function(.data, .alpha = 0.7, .interactive = FALSE, .pluck = dplyr::mutate( .tooltip = paste0( "Walk Number: ", walk_number, " | ", - "Step: ", x, " | ", + "Step: ", step_number, " | ", y_label_pretty, ": ", round(get(y_var), digits = 3) ) ) @@ -136,7 +137,7 @@ visualize_walks <- function(.data, .alpha = 0.7, .interactive = FALSE, .pluck = g <- ggplot2::ggplot( .data, ggplot2::aes( - x = x, + x = step_number, y = get(y_var), color = walk_number, group = walk_number, @@ -167,7 +168,7 @@ visualize_walks <- function(.data, .alpha = 0.7, .interactive = FALSE, .pluck = } # Identify variables to plot, excluding 'walk_number' and 'x' - plot_vars <- setdiff(atb$names, c("walk_number", "x")) + plot_vars <- setdiff(atb$names, c("walk_number", "step_number")) # Generate a list of plots for each variable in plot_vars plots <- lapply(plot_vars, generate_plot) diff --git a/R/stats-walk-summary.R b/R/stats-walk-summary.R index 404793b..039039e 100644 --- a/R/stats-walk-summary.R +++ b/R/stats-walk-summary.R @@ -29,7 +29,7 @@ #' walk_data <- random_normal_walk(.initial_value = 100) #' #' # Summarize the walks -#' summarize_walks(walk_data, cum_sum, walk_number) |> +#' summarize_walks(walk_data, cum_sum_y, walk_number) |> #' glimpse() #' summarize_walks(walk_data, y) |> #' glimpse() diff --git a/R/vec-distance.R b/R/vec-distance.R index 2fc701e..7dc6a01 100644 --- a/R/vec-distance.R +++ b/R/vec-distance.R @@ -22,8 +22,8 @@ #' @examples #' set.seed(123) #' df <- rw30() -#' euclidean_distance(df, x, y) -#' euclidean_distance(df, x, y, TRUE) |> head(10) +#' euclidean_distance(df, step_number, y) +#' euclidean_distance(df, step_number, y, TRUE) |> head(10) #' #' @return #' A numeric Vector of ditances diff --git a/docs/articles/getting-started.html b/docs/articles/getting-started.html index 8b74c77..1a5c55b 100644 --- a/docs/articles/getting-started.html +++ b/docs/articles/getting-started.html @@ -144,18 +144,18 @@

Example Usagerw30() |> head(10) #> # A tibble: 10 × 3 -#> walk_number x y -#> <fct> <int> <dbl> -#> 1 1 1 0 -#> 2 1 2 -1.40 -#> 3 1 3 -1.14 -#> 4 1 4 -3.58 -#> 5 1 5 -3.59 -#> 6 1 6 -2.97 -#> 7 1 7 -1.82 -#> 8 1 8 -3.64 -#> 9 1 9 -3.89 -#> 10 1 10 -4.13 +#> walk_number step_number y +#> <fct> <int> <dbl> +#> 1 1 1 0 +#> 2 1 2 -1.40 +#> 3 1 3 -1.14 +#> 4 1 4 -3.58 +#> 5 1 5 -3.59 +#> 6 1 6 -2.97 +#> 7 1 7 -1.82 +#> 8 1 8 -3.64 +#> 9 1 9 -3.89 +#> 10 1 10 -4.13

The output shows the first 10 steps of the random walk. Each step represents the position of the object after moving forward or backward by one unit. The rw30() function takes no parameters and @@ -174,7 +174,7 @@

Attributesatb <- attributes(rw30()) atb[!names(atb) %in% c("row.names")] #> $names -#> [1] "walk_number" "x" "y" +#> [1] "walk_number" "step_number" "y" #> #> $class #> [1] "tbl_df" "tbl" "data.frame" diff --git a/docs/news/index.html b/docs/news/index.html index 9abb244..000c058 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -35,6 +35,18 @@

RandomWalker (development version)

+
+

Breaing Changes

+
  1. Fix #107 - This change allows for the generation of random walks with up to 3 dimensions. Due to this what was the x column is now called step_number for all random walk functions including rw30(). The x column is now the first dimension of a 2d/3d random walk.
  2. +
+
+

New Features

+
  1. Fix #105 - Add internal function rand_walk_column_names() to generate column names for random walks.
  2. +
+
+

Minor Fixes and Improvements

+
  1. Fix #107 - Add .dimensions parameter to random walk functions to allow for the generation of random walks with up to 3 dimensions.
  2. +

RandomWalker 0.2.0

CRAN release: 2024-10-23

diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index c089858..d2475c0 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -3,7 +3,7 @@ pkgdown: 2.1.1 pkgdown_sha: ~ articles: getting-started: getting-started.html -last_built: 2024-10-24T01:54Z +last_built: 2024-11-11T15:28Z urls: reference: https://www.spsanderson.com/RandomWalker/reference article: https://www.spsanderson.com/RandomWalker/articles diff --git a/docs/reference/brownian_motion.html b/docs/reference/brownian_motion.html index 2e0d700..c07fee5 100644 --- a/docs/reference/brownian_motion.html +++ b/docs/reference/brownian_motion.html @@ -45,7 +45,7 @@

Usage .n = 100, .delta_time = 1, .initial_value = 0, - .return_tibble = TRUE + .dimensions = 1 )

@@ -69,15 +69,23 @@

Arguments.return_tibble -

The default is TRUE. If set to FALSE then an object -of class matrix will be returned.

+
.dimensions
+

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

Value

-

A tibble/matrix

-
+

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:

Details

Brownian Motion, also known as the Wiener process, is a @@ -111,25 +119,68 @@

Author<

Examples

set.seed(123)
 brownian_motion()
-#> # A tibble: 2,525 × 6
-#>    walk_number     x      y cum_min cum_max cum_mean
-#>    <fct>       <int>  <dbl>   <dbl>   <dbl>    <dbl>
-#>  1 1               1  0       0       0       0     
-#>  2 1               2 -0.560  -0.560   0      -0.280 
-#>  3 1               3 -0.791  -0.791   0      -0.450 
-#>  4 1               4  0.768  -0.791   0.768  -0.146 
-#>  5 1               5  0.839  -0.791   0.839   0.0511
-#>  6 1               6  0.968  -0.791   0.968   0.204 
-#>  7 1               7  2.68   -0.791   2.68    0.558 
-#>  8 1               8  3.14   -0.791   3.14    0.881 
-#>  9 1               9  1.88   -0.791   3.14    0.992 
-#> 10 1              10  1.19   -0.791   3.14    1.01  
-#> # ℹ 2,515 more rows
+#> # A tibble: 2,500 × 8
+#>    walk_number step_number       y cum_sum_y cum_prod_y cum_min_y cum_max_y
+#>    <fct>             <int>   <dbl>     <dbl>      <dbl>     <dbl>     <dbl>
+#>  1 1                     1 -0.560     -0.560          0    -0.560    -0.560
+#>  2 1                     2 -0.230     -0.791          0    -0.560    -0.230
+#>  3 1                     3  1.56       0.768          0    -0.560     1.56 
+#>  4 1                     4  0.0705     0.839          0    -0.560     1.56 
+#>  5 1                     5  0.129      0.968          0    -0.560     1.56 
+#>  6 1                     6  1.72       2.68           0    -0.560     1.72 
+#>  7 1                     7  0.461      3.14           0    -0.560     1.72 
+#>  8 1                     8 -1.27       1.88           0    -1.27      1.72 
+#>  9 1                     9 -0.687      1.19           0    -1.27      1.72 
+#> 10 1                    10 -0.446      0.746          0    -1.27      1.72 
+#> # ℹ 2,490 more rows
+#> # ℹ 1 more variable: cum_mean_y <dbl>
 
 set.seed(123)
-brownian_motion(.num_walks = 5) |>
-  visualize_walks()
-
+brownian_motion(.dimensions = 3) |>
+  head() |>
+  t()
+#>             [,1]          [,2]          [,3]          [,4]         
+#> walk_number "1"           "1"           "1"           "1"          
+#> step_number "1"           "2"           "3"           "4"          
+#> x           "-0.56047565" "-0.23017749" " 1.55870831" " 0.07050839"
+#> y           "-0.71040656" " 0.25688371" "-0.24669188" "-0.34754260"
+#> z           " 2.1988103"  " 1.3124130"  "-0.2651451"  " 0.5431941" 
+#> cum_sum_x   "-0.5604756"  "-0.7906531"  " 0.7680552"  " 0.8385636" 
+#> cum_sum_y   "-0.7104066"  "-0.4535229"  "-0.7002147"  "-1.0477573" 
+#> cum_sum_z   "2.198810"    "3.511223"    "3.246078"    "3.789272"   
+#> cum_prod_x  "0"           "0"           "0"           "0"          
+#> cum_prod_y  "0"           "0"           "0"           "0"          
+#> cum_prod_z  "0"           "0"           "0"           "0"          
+#> cum_min_x   "-0.5604756"  "-0.5604756"  "-0.5604756"  "-0.5604756" 
+#> cum_min_y   "-0.7104066"  "-0.7104066"  "-0.7104066"  "-0.7104066" 
+#> cum_min_z   " 2.1988103"  " 1.3124130"  "-0.2651451"  "-0.2651451" 
+#> cum_max_x   "-0.5604756"  "-0.2301775"  " 1.5587083"  " 1.5587083" 
+#> cum_max_y   "-0.7104066"  " 0.2568837"  " 0.2568837"  " 0.2568837" 
+#> cum_max_z   "2.19881"     "2.19881"     "2.19881"     "2.19881"    
+#> cum_mean_x  "-0.5604756"  "-0.3953266"  " 0.2560184"  " 0.2096409" 
+#> cum_mean_y  "-0.7104066"  "-0.2267614"  "-0.2334049"  "-0.2619393" 
+#> cum_mean_z  "2.1988103"   "1.7556117"   "1.0820261"   "0.9473181"  
+#>             [,5]          [,6]         
+#> walk_number "1"           "1"          
+#> step_number "5"           "6"          
+#> x           " 0.12928774" " 1.71506499"
+#> y           "-0.95161857" "-0.04502772"
+#> z           "-0.4143399"  "-0.4762469" 
+#> cum_sum_x   " 0.9678513"  " 2.6829163" 
+#> cum_sum_y   "-1.9993759"  "-2.0444036" 
+#> cum_sum_z   "3.374932"    "2.898685"   
+#> cum_prod_x  "0"           "0"          
+#> cum_prod_y  "0"           "0"          
+#> cum_prod_z  "0"           "0"          
+#> cum_min_x   "-0.5604756"  "-0.5604756" 
+#> cum_min_y   "-0.9516186"  "-0.9516186" 
+#> cum_min_z   "-0.4143399"  "-0.4762469" 
+#> cum_max_x   " 1.5587083"  " 1.7150650" 
+#> cum_max_y   " 0.2568837"  " 0.2568837" 
+#> cum_max_z   "2.19881"     "2.19881"    
+#> cum_mean_x  " 0.1935703"  " 0.4471527" 
+#> cum_mean_y  "-0.3998752"  "-0.3407339" 
+#> cum_mean_z  "0.6749865"   "0.4831142"  
 
 
diff --git a/docs/reference/convert_snake_to_title_case.html b/docs/reference/convert_snake_to_title_case.html index 87c3f0f..e7995e2 100644 --- a/docs/reference/convert_snake_to_title_case.html +++ b/docs/reference/convert_snake_to_title_case.html @@ -68,6 +68,7 @@

See also

Other Utility Functions: generate_caption(), get_attributes(), +rand_walk_column_names(), rand_walk_helper(), running_quantile(), std_cum_max_augment(), diff --git a/docs/reference/discrete_walk.html b/docs/reference/discrete_walk.html index 3c8c188..6516a81 100644 --- a/docs/reference/discrete_walk.html +++ b/docs/reference/discrete_walk.html @@ -55,7 +55,8 @@

Usage .upper_bound = 1, .lower_bound = -1, .upper_probability = 0.5, - .initial_value = 100 + .initial_value = 100, + .dimensions = 1 ) @@ -87,12 +88,26 @@

Arguments.initial_value

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

+ +
.dimensions
+

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

+

Value

-

A tibble containing the simulated walks, with columns for the walk number, -time period, and various cumulative metrics (sum, product, min, max).

-
+

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).

  • +

Details

The function discrete_walk simulates random walks for a specified number of simulations @@ -117,30 +132,70 @@

Author<

Examples

-
library(ggplot2)
-
-set.seed(123)
+    
set.seed(123)
 discrete_walk()
 #> # A tibble: 2,500 × 8
-#>    walk_number     x     y cum_sum cum_prod cum_min cum_max cum_mean
-#>    <fct>       <int> <dbl>   <dbl>    <dbl>   <dbl>   <dbl>    <dbl>
-#>  1 1               1    -1      99        0      99      99     99  
-#>  2 1               2     1     100        0      99     101    100  
-#>  3 1               3    -1      99        0      99     101     99.7
-#>  4 1               4     1     100        0      99     101    100  
-#>  5 1               5     1     101        0      99     101    100. 
-#>  6 1               6    -1     100        0      99     101    100  
-#>  7 1               7     1     101        0      99     101    100. 
-#>  8 1               8     1     102        0      99     101    100. 
-#>  9 1               9     1     103        0      99     101    100. 
-#> 10 1              10    -1     102        0      99     101    100. 
+#>    walk_number step_number     y cum_sum_y cum_prod_y cum_min_y cum_max_y
+#>    <fct>             <int> <dbl>     <dbl>      <dbl>     <dbl>     <dbl>
+#>  1 1                     1    -1        99          0        99        99
+#>  2 1                     2     1       100          0        99       101
+#>  3 1                     3    -1        99          0        99       101
+#>  4 1                     4     1       100          0        99       101
+#>  5 1                     5     1       101          0        99       101
+#>  6 1                     6    -1       100          0        99       101
+#>  7 1                     7     1       101          0        99       101
+#>  8 1                     8     1       102          0        99       101
+#>  9 1                     9     1       103          0        99       101
+#> 10 1                    10    -1       102          0        99       101
 #> # ℹ 2,490 more rows
+#> # ℹ 1 more variable: cum_mean_y <dbl>
 
 set.seed(123)
-discrete_walk(.num_walks = 10, .n = 250, .upper_probability = 0.51,
-.initial_value = 100) |>
-visualize_walks()
-
+discrete_walk(.dimensions = 3) |>
+  head() |>
+  t()
+#>             [,1]        [,2]        [,3]        [,4]        [,5]       
+#> walk_number "1"         "1"         "1"         "1"         "1"        
+#> step_number "1"         "2"         "3"         "4"         "5"        
+#> x           "-1"        " 1"        "-1"        " 1"        " 1"       
+#> y           " 1"        "-1"        "-1"        " 1"        "-1"       
+#> z           "-1"        " 1"        " 1"        " 1"        "-1"       
+#> cum_sum_x   " 99"       "100"       " 99"       "100"       "101"      
+#> cum_sum_y   "101"       "100"       " 99"       "100"       " 99"      
+#> cum_sum_z   " 99"       "100"       "101"       "102"       "101"      
+#> cum_prod_x  "0"         "0"         "0"         "0"         "0"        
+#> cum_prod_y  "200"       "  0"       "  0"       "  0"       "  0"      
+#> cum_prod_z  "0"         "0"         "0"         "0"         "0"        
+#> cum_min_x   "99"        "99"        "99"        "99"        "99"       
+#> cum_min_y   "101"       " 99"       " 99"       " 99"       " 99"      
+#> cum_min_z   "99"        "99"        "99"        "99"        "99"       
+#> cum_max_x   " 99"       "101"       "101"       "101"       "101"      
+#> cum_max_y   "101"       "101"       "101"       "101"       "101"      
+#> cum_max_z   " 99"       "101"       "101"       "101"       "101"      
+#> cum_mean_x  " 99.00000" "100.00000" " 99.66667" "100.00000" "100.20000"
+#> cum_mean_y  "101.00000" "100.00000" " 99.66667" "100.00000" " 99.80000"
+#> cum_mean_z  " 99.0000"  "100.0000"  "100.3333"  "100.5000"  "100.2000" 
+#>             [,6]       
+#> walk_number "1"        
+#> step_number "6"        
+#> x           "-1"       
+#> y           " 1"       
+#> z           " 1"       
+#> cum_sum_x   "100"      
+#> cum_sum_y   "100"      
+#> cum_sum_z   "102"      
+#> cum_prod_x  "0"        
+#> cum_prod_y  "  0"      
+#> cum_prod_z  "0"        
+#> cum_min_x   "99"       
+#> cum_min_y   " 99"      
+#> cum_min_z   "99"       
+#> cum_max_x   "101"      
+#> cum_max_y   "101"      
+#> cum_max_z   "101"      
+#> cum_mean_x  "100.00000"
+#> cum_mean_y  "100.00000"
+#> cum_mean_z  "100.3333" 
 
 
diff --git a/docs/reference/euclidean_distance.html b/docs/reference/euclidean_distance.html index 31ce6f9..1496417 100644 --- a/docs/reference/euclidean_distance.html +++ b/docs/reference/euclidean_distance.html @@ -100,22 +100,22 @@

Author<

Examples

set.seed(123)
 df <- rw30()
-euclidean_distance(df, x, y)
+euclidean_distance(df, step_number, y)
 #> # A tibble: 3,000 × 4
-#>    walk_number     x      y distance
-#>    <fct>       <int>  <dbl>    <dbl>
-#>  1 1               1  0        NA   
-#>  2 1               2 -0.560     1.15
-#>  3 1               3 -0.791     1.03
-#>  4 1               4  0.768     1.85
-#>  5 1               5  0.839     1.00
-#>  6 1               6  0.968     1.01
-#>  7 1               7  2.68      1.99
-#>  8 1               8  3.14      1.10
-#>  9 1               9  1.88      1.61
-#> 10 1              10  1.19      1.21
+#>    walk_number step_number      y distance
+#>    <fct>             <int>  <dbl>    <dbl>
+#>  1 1                     1  0        NA   
+#>  2 1                     2 -0.560     1.15
+#>  3 1                     3 -0.791     1.03
+#>  4 1                     4  0.768     1.85
+#>  5 1                     5  0.839     1.00
+#>  6 1                     6  0.968     1.01
+#>  7 1                     7  2.68      1.99
+#>  8 1                     8  3.14      1.10
+#>  9 1                     9  1.88      1.61
+#> 10 1                    10  1.19      1.21
 #> # ℹ 2,990 more rows
-euclidean_distance(df, x, y, TRUE) |> head(10)
+euclidean_distance(df, step_number, y, TRUE) |> head(10)
 #>  [1]       NA 1.146356 1.026149 1.851910 1.002483 1.008323 1.985308 1.101110
 #>  [9] 1.612569 1.213164
 
diff --git a/docs/reference/generate_caption.html b/docs/reference/generate_caption.html
index 623a230..05c232d 100644
--- a/docs/reference/generate_caption.html
+++ b/docs/reference/generate_caption.html
@@ -72,6 +72,7 @@ 

See also

Other Utility Functions: convert_snake_to_title_case(), get_attributes(), +rand_walk_column_names(), rand_walk_helper(), running_quantile(), std_cum_max_augment(), diff --git a/docs/reference/geometric_brownian_motion.html b/docs/reference/geometric_brownian_motion.html index 8894473..3ee2285 100644 --- a/docs/reference/geometric_brownian_motion.html +++ b/docs/reference/geometric_brownian_motion.html @@ -47,7 +47,7 @@

Usage .sigma = 0.1, .initial_value = 100, .delta_time = 0.003, - .return_tibble = TRUE + .dimensions = 1 )

@@ -79,15 +79,25 @@

Arguments.return_tibble -

The default is TRUE. If set to FALSE then an object -of class matrix will be returned.

+
.dimensions
+

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

Value

-

A tibble/matrix

-
+

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).

  • +

Details

Geometric Brownian Motion (GBM) is a statistical method for modeling @@ -126,27 +136,58 @@

Author<

Examples

-
set.seed(123)
+    

+set.seed(123)
 geometric_brownian_motion()
-#> # A tibble: 2,525 × 6
-#>    walk_number     x     y cum_min cum_max cum_mean
-#>    <fct>       <int> <dbl>   <dbl>   <dbl>    <dbl>
-#>  1 1               1 100      200     200      200 
-#>  2 1               2  99.7    200.    200      200.
-#>  3 1               3  99.6    200.    200      200.
-#>  4 1               4 100.     200.    200.     200.
-#>  5 1               5 100.     200.    200.     200.
-#>  6 1               6 101.     200.    201.     200.
-#>  7 1               7 101.     200.    201.     200.
-#>  8 1               8 102.     200.    202.     200.
-#>  9 1               9 101.     200.    202.     201.
-#> 10 1              10 101.     200.    202.     201.
-#> # ℹ 2,515 more rows
+#> # A tibble: 2,500 × 6
+#>    walk_number step_number     y cum_min_y cum_max_y cum_mean_y
+#>    <fct>             <int> <dbl>     <dbl>     <dbl>      <dbl>
+#>  1 1                     1 0.997      101.      101.       101.
+#>  2 1                     2 0.996      101.      101.       101.
+#>  3 1                     3 1.00       101.      101.       101.
+#>  4 1                     4 1.00       101.      101.       101.
+#>  5 1                     5 1.01       101.      101.       101.
+#>  6 1                     6 1.01       101.      101.       101.
+#>  7 1                     7 1.02       101.      101.       101.
+#>  8 1                     8 1.01       101.      101.       101.
+#>  9 1                     9 1.01       101.      101.       101.
+#> 10 1                    10 1.00       101.      101.       101.
+#> # ℹ 2,490 more rows
 
 set.seed(123)
-geometric_brownian_motion(.num_walks = 5) |>
-  visualize_walks()
-
+geometric_brownian_motion(.dimensions = 3) |>
+  head() |>
+  t()
+#>             [,1]        [,2]        [,3]        [,4]        [,5]       
+#> walk_number "1"         "1"         "1"         "1"         "1"        
+#> step_number "1"         "2"         "3"         "4"         "5"        
+#> x           "0.9969199" "0.9956489" "1.0041705" "1.0045433" "1.0052398"
+#> y           "0.9961016" "0.9974891" "0.9961273" "0.9942180" "0.9890345"
+#> z           "1.012101"  "1.019387"  "1.017893"  "1.020910"  "1.018581" 
+#> cum_min_x   "100.9969"  "100.9956"  "100.9956"  "100.9956"  "100.9956" 
+#> cum_min_y   "100.9961"  "100.9961"  "100.9961"  "100.9942"  "100.9890" 
+#> cum_min_z   "101.0121"  "101.0121"  "101.0121"  "101.0121"  "101.0121" 
+#> cum_max_x   "100.9969"  "100.9969"  "101.0042"  "101.0045"  "101.0052" 
+#> cum_max_y   "100.9961"  "100.9975"  "100.9975"  "100.9975"  "100.9975" 
+#> cum_max_z   "101.0121"  "101.0194"  "101.0194"  "101.0209"  "101.0209" 
+#> cum_mean_x  "100.9969"  "100.9963"  "100.9989"  "101.0003"  "101.0013" 
+#> cum_mean_y  "100.9961"  "100.9968"  "100.9966"  "100.9960"  "100.9946" 
+#> cum_mean_z  "101.0121"  "101.0157"  "101.0165"  "101.0176"  "101.0178" 
+#>             [,6]       
+#> walk_number "1"        
+#> step_number "6"        
+#> x           "1.0147121"
+#> y           "0.9887758"
+#> z           "1.015912" 
+#> cum_min_x   "100.9956" 
+#> cum_min_y   "100.9888" 
+#> cum_min_z   "101.0121" 
+#> cum_max_x   "101.0147" 
+#> cum_max_y   "100.9975" 
+#> cum_max_z   "101.0209" 
+#> cum_mean_x  "101.0035" 
+#> cum_mean_y  "100.9936" 
+#> cum_mean_z  "101.0175" 
 
 
diff --git a/docs/reference/get_attributes.html b/docs/reference/get_attributes.html index 8e6e228..ca619be 100644 --- a/docs/reference/get_attributes.html +++ b/docs/reference/get_attributes.html @@ -68,6 +68,7 @@

See also

Other Utility Functions: convert_snake_to_title_case(), generate_caption(), +rand_walk_column_names(), rand_walk_helper(), running_quantile(), std_cum_max_augment(), @@ -85,7 +86,7 @@

Author<

Examples

get_attributes(rw30())
 #> $names
-#> [1] "walk_number" "x"           "y"          
+#> [1] "walk_number" "step_number" "y"          
 #> 
 #> $class
 #> [1] "tbl_df"     "tbl"        "data.frame"
diff --git a/docs/reference/index.html b/docs/reference/index.html
index 18a23ae..18035a6 100644
--- a/docs/reference/index.html
+++ b/docs/reference/index.html
@@ -89,7 +89,7 @@ 

Generator Functionsrandom_normal_walk() -
Generate Multiple Random Normal Walks
+
Generate Multiple Random Normal Walks in Multiple Dimensions

Visualization Functions

diff --git a/docs/reference/rand_walk_column_names.html b/docs/reference/rand_walk_column_names.html new file mode 100644 index 0000000..69209b8 --- /dev/null +++ b/docs/reference/rand_walk_column_names.html @@ -0,0 +1,104 @@ + +Get Column Names — rand_walk_column_names • RandomWalker + Skip to contents + + +
+
+
+ +
+

This function generates the column names of a rand walk +data frame.

+
+ +
+

Usage

+
rand_walk_column_names(.rand_data, .dim_names, .num_sims, .t)
+
+ +
+

Arguments

+ + +
.rand_data
+

A data frame from which column names are to be extracted.

+ + +
.dim_names
+

The dimnames passed from the rand walk function.

+ +
+
+

Details

+

The rand_walk_column_names function takes a data frame as input and +returns the rand walk data with column names.

+
+ +
+

Author

+

Steven P. Sanderson II, MPH

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/rand_walk_helper.html b/docs/reference/rand_walk_helper.html index 8200e22..6c51d6d 100644 --- a/docs/reference/rand_walk_helper.html +++ b/docs/reference/rand_walk_helper.html @@ -77,6 +77,7 @@

See alsoconvert_snake_to_title_case(), generate_caption(), get_attributes(), +rand_walk_column_names(), running_quantile(), std_cum_max_augment(), std_cum_mean_augment(), @@ -101,16 +102,16 @@

Examples#> # A tibble: 750 × 8 #> walk_number x y cum_sum cum_prod cum_min cum_max cum_mean #> <fct> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> -#> 1 1 1 0.551 101. 155. 101. 101. 101. -#> 2 1 2 -2.09 98.5 -169. 97.9 101. 99.2 -#> 3 1 3 -0.0249 98.4 -165. 97.9 101. 99.5 -#> 4 1 4 0.888 99.3 -311. 97.9 101. 99.8 -#> 5 1 5 -0.337 99.0 -206. 97.9 101. 99.8 -#> 6 1 6 -1.03 98.0 6.33 97.9 101. 99.7 -#> 7 1 7 0.431 98.4 9.05 97.9 101. 99.8 -#> 8 1 8 0.209 98.6 10.9 97.9 101. 99.8 -#> 9 1 9 -1.55 97.0 -6.00 97.9 101. 99.7 -#> 10 1 10 -1.17 95.9 1.04 97.9 101. 99.6 +#> 1 1 1 0.406 100. 141. 100. 100. 100. +#> 2 1 2 0.947 101. 274. 100. 101. 101. +#> 3 1 3 2.06 103. 838. 100. 102. 101. +#> 4 1 4 1.35 105. 1972. 100. 102. 101. +#> 5 1 5 0.812 106. 3573. 100. 102. 101. +#> 6 1 6 0.0815 106. 3865. 100. 102. 101. +#> 7 1 7 -1.13 105. -501. 98.9 102. 101. +#> 8 1 8 -0.504 104. -248. 98.9 102. 101. +#> 9 1 9 2.64 107. -904. 98.9 103. 101. +#> 10 1 10 0.595 107. -1442. 98.9 103. 101. #> # ℹ 740 more rows

diff --git a/docs/reference/random_normal_drift_walk.html b/docs/reference/random_normal_drift_walk.html index cadbf8b..40405c0 100644 --- a/docs/reference/random_normal_drift_walk.html +++ b/docs/reference/random_normal_drift_walk.html @@ -58,7 +58,8 @@

Usage .mu = 0, .sd = 1, .drift = 0.1, - .initial_value = 0 + .initial_value = 0, + .dimensions = 1 )

@@ -89,13 +90,26 @@

Arguments.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.

+

Value

-

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.

-
+

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).

  • +

Details

This function generates multiple random walks with a specified drift. @@ -118,10 +132,69 @@

Author<

Examples

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()
-
+random_normal_drift_walk()
+#> # A tibble: 2,500 × 8
+#>    walk_number step_number      y cum_sum_y cum_prod_y cum_min_y cum_max_y
+#>    <fct>             <int>  <dbl>     <dbl>      <dbl>     <dbl>     <dbl>
+#>  1 1                     1 -1.02     -1.02           0     -1.02    -1.02 
+#>  2 1                     2 -0.821    -1.84           0     -1.02    -0.821
+#>  3 1                     3  2.63      0.785          0     -1.02     2.63 
+#>  4 1                     4  1.31      2.09           0     -1.02     2.63 
+#>  5 1                     5  1.60      3.69           0     -1.02     2.63 
+#>  6 1                     6  5.00      8.69           0     -1.02     5.00 
+#>  7 1                     7  4.30     13.0            0     -1.02     5.00 
+#>  8 1                     8  1.41     14.4            0     -1.02     5.00 
+#>  9 1                     9  1.41     15.8            0     -1.02     5.00 
+#> 10 1                    10  1.30     17.1            0     -1.02     5.00 
+#> # ℹ 2,490 more rows
+#> # ℹ 1 more variable: cum_mean_y <dbl>
+
+set.seed(123)
+random_normal_drift_walk(.dimensions = 3) |>
+  head() |>
+  t()
+#>             [,1]           [,2]           [,3]           [,4]          
+#> walk_number "1"            "1"            "1"            "1"           
+#> step_number "1"            "2"            "3"            "4"           
+#> x           "-1.0209513"   "-0.8208306"   " 2.6267635"   " 1.3090720"  
+#> y           "-1.320813127" " 0.003360855" "-0.646906611" "-0.995299932"
+#> z           "4.497621"     "5.023636"     "3.280933"     "4.732466"    
+#> cum_sum_x   "-1.0209513"   "-1.8417819"   " 0.7849816"   " 2.0940535"  
+#> cum_sum_y   "-1.320813"    "-1.317452"    "-1.964359"    "-2.959659"   
+#> cum_sum_z   " 4.497621"    " 9.521257"    "12.802190"    "17.534657"   
+#> cum_prod_x  "0"            "0"            "0"            "0"           
+#> cum_prod_y  "0"            "0"            "0"            "0"           
+#> cum_prod_z  "0"            "0"            "0"            "0"           
+#> cum_min_x   "-1.020951"    "-1.020951"    "-1.020951"    "-1.020951"   
+#> cum_min_y   "-1.320813"    "-1.320813"    "-1.320813"    "-1.320813"   
+#> cum_min_z   "4.497621"     "4.497621"     "3.280933"     "3.280933"    
+#> cum_max_x   "-1.0209513"   "-0.8208306"   " 2.6267635"   " 2.6267635"  
+#> cum_max_y   "-1.320813127" " 0.003360855" " 0.003360855" " 0.003360855"
+#> cum_max_z   "4.497621"     "5.023636"     "5.023636"     "5.023636"    
+#> cum_mean_x  "-1.0209513"   "-0.9208910"   " 0.2616605"   " 0.5235134"  
+#> cum_mean_y  "-1.3208131"   "-0.6587261"   "-0.6547863"   "-0.7399147"  
+#> cum_mean_z  "4.497621"     "4.760628"     "4.267397"     "4.383664"    
+#>             [,5]           [,6]          
+#> walk_number "1"            "1"           
+#> step_number "5"            "6"           
+#> x           " 1.5971390"   " 4.9979813"  
+#> y           "-2.450994467" "-1.489431349"
+#> z           "3.460592"     "3.022439"    
+#> cum_sum_x   " 3.6911926"   " 8.6891739"  
+#> cum_sum_y   "-5.410653"    "-6.900085"   
+#> cum_sum_z   "20.995249"    "24.017688"   
+#> cum_prod_x  "0"            "0"           
+#> cum_prod_y  "0"            "0"           
+#> cum_prod_z  "0"            "0"           
+#> cum_min_x   "-1.020951"    "-1.020951"   
+#> cum_min_y   "-2.450994"    "-2.450994"   
+#> cum_min_z   "3.280933"     "3.022439"    
+#> cum_max_x   " 2.6267635"   " 4.9979813"  
+#> cum_max_y   " 0.003360855" " 0.003360855"
+#> cum_max_z   "5.023636"     "5.023636"    
+#> cum_mean_x  " 0.7382385"   " 1.4481956"  
+#> cum_mean_y  "-1.0821307"   "-1.1500141"  
+#> cum_mean_z  "4.199050"     "4.002948"    
 
 
diff --git a/docs/reference/random_normal_walk.html b/docs/reference/random_normal_walk.html index 20614a4..070219d 100644 --- a/docs/reference/random_normal_walk.html +++ b/docs/reference/random_normal_walk.html @@ -1,9 +1,13 @@ -Generate Multiple Random Normal Walks — random_normal_walk • RandomWalker +Generate Multiple Random Normal Walks in Multiple Dimensions — random_normal_walk • RandomWalker Skip to contents @@ -33,15 +37,17 @@
-

The random_normal_walk function is useful for simulating random processes -and can be applied in various fields such as finance, physics, and biology -to model different stochastic behaviors.

+

The random_normal_walk function generates multiple random walks in 1, 2, or 3 dimensions. +Each walk is a sequence of steps where each step is a random draw from a normal distribution. +The user can specify the number of walks, the number of steps in each walk, and the +parameters of the normal distribution (mean and standard deviation). The function +also allows for sampling a proportion of the steps and optionally sampling with replacement.

@@ -93,10 +100,19 @@

Arguments.sample_size

A numeric value between 0 and 1 specifying the proportion of .n to sample. Default is 0.8.

+ +
.dimensions
+

An integer specifying the number of dimensions (1, 2, or 3). Default is 1.

+

Value

-

A tibble containing the generated random walks with the following columns:

  • walk_number: Factor representing the walk number.

  • +

    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:

    • walk_number: Factor representing the walk number.

    • x: Step index.

    • y: Normal distribution values.

    • cum_sum: Cumulative sum of y.

    • @@ -104,17 +120,6 @@

      Value

      cum_min: Cumulative minimum of y.

    • cum_max: Cumulative maximum of y.

    The tibble includes attributes for the function parameters.

    -
-
-

Details

-

This function generates multiple random walks, which are sequences of steps -where each step is a random draw from a normal distribution. The user can -specify the number of walks, the number of steps in each walk, and the -parameters of the normal distribution (mean and standard deviation). The -function also allows for sampling a proportion of the steps and optionally -sampling with replacement.

-

The output tibble includes several computed columns for each walk, such as the -cumulative sum, product, minimum, and maximum of the steps.

See also

@@ -131,48 +136,70 @@

Author<

Examples

-
library(ggplot2)
-
-# Generate 10 random walks with 50 steps each
-set.seed(123)
-random_normal_walk(.num_walks = 10, .n = 50)
-#> # A tibble: 400 × 8
-#>    walk_number     x        y cum_sum cum_prod cum_min cum_max cum_mean
-#>    <fct>       <int>    <dbl>   <dbl>    <dbl>   <dbl>   <dbl>    <dbl>
-#>  1 1               1  0.125    0.125         0   0.125   0.125   0.125 
-#>  2 1               2  0.172    0.297         0   0.125   0.172   0.148 
-#>  3 1               3 -0.127    0.170         0  -0.127   0.172   0.0568
-#>  4 1               4 -0.0218   0.149         0  -0.127   0.172   0.0371
-#>  5 1               5 -0.0218   0.127         0  -0.127   0.172   0.0254
-#>  6 1               6 -0.0306   0.0962        0  -0.127   0.172   0.0160
-#>  7 1               7  0.0426   0.139         0  -0.127   0.172   0.0198
-#>  8 1               8  0.0498   0.189         0  -0.127   0.172   0.0236
-#>  9 1               9  0.0878   0.276         0  -0.127   0.172   0.0307
-#> 10 1              10  0.00705  0.283         0  -0.127   0.172   0.0283
-#> # ℹ 390 more rows
-
-# Generate random walks with different mean and standard deviation
-set.seed(123)
-random_normal_walk(.num_walks = 10, .n = 50, .samp = FALSE)
-#> # A tibble: 500 × 8
-#>    walk_number     x        y cum_sum cum_prod cum_min cum_max cum_mean
-#>    <fct>       <int>    <dbl>   <dbl>    <dbl>   <dbl>   <dbl>    <dbl>
-#>  1 1               1 -0.0560  -0.0560        0 -0.0560 -0.0560 -0.0560 
-#>  2 1               2 -0.0230  -0.0791        0 -0.0560 -0.0230 -0.0395 
-#>  3 1               3  0.156    0.0768        0 -0.0560  0.156   0.0256 
-#>  4 1               4  0.00705  0.0839        0 -0.0560  0.156   0.0210 
-#>  5 1               5  0.0129   0.0968        0 -0.0560  0.156   0.0194 
-#>  6 1               6  0.172    0.268         0 -0.0560  0.172   0.0447 
-#>  7 1               7  0.0461   0.314         0 -0.0560  0.172   0.0449 
-#>  8 1               8 -0.127    0.188         0 -0.127   0.172   0.0235 
-#>  9 1               9 -0.0687   0.119         0 -0.127   0.172   0.0132 
-#> 10 1              10 -0.0446   0.0746        0 -0.127   0.172   0.00746
-#> # ℹ 490 more rows
+    
set.seed(123)
+random_normal_walk()
+#> # A tibble: 2,000 × 8
+#>    walk_number step_number       y cum_sum_y cum_prod_y cum_min_y cum_max_y
+#>    <fct>             <int>   <dbl>     <dbl>      <dbl>     <dbl>     <dbl>
+#>  1 1                     1  0.125     0.125           0    0.125      0.125
+#>  2 1                     2 -0.0628    0.0626          0   -0.0628     0.125
+#>  3 1                     3 -0.0326    0.0300          0   -0.0628     0.125
+#>  4 1                     4  0.179     0.209           0   -0.0628     0.179
+#>  5 1                     5  0.0435    0.252           0   -0.0628     0.179
+#>  6 1                     6  0.137     0.389           0   -0.0628     0.179
+#>  7 1                     7 -0.0688    0.320           0   -0.0688     0.179
+#>  8 1                     8 -0.0467    0.274           0   -0.0688     0.179
+#>  9 1                     9 -0.0473    0.226           0   -0.0688     0.179
+#> 10 1                    10  0.0448    0.271           0   -0.0688     0.179
+#> # ℹ 1,990 more rows
+#> # ℹ 1 more variable: cum_mean_y <dbl>
 
 set.seed(123)
-random_normal_walk(.num_walks = 2, .n = 100, .initial_value = 100) |>
-  visualize_walks()
-
+random_normal_walk(.dimensions = 3) |>
+  head() |>
+  t()
+#>             [,1]           [,2]           [,3]           [,4]          
+#> walk_number "1"            "1"            "1"            "1"           
+#> step_number "1"            "2"            "3"            "4"           
+#> x           " 0.12538149"  "-0.06279061"  "-0.03259316"  " 0.17869131" 
+#> y           " 0.06365697"  "-0.02153805"  " 0.01192452"  "-0.01194526" 
+#> z           "-0.12586486"  " 0.13785701"  "-0.19927485"  " 0.09590054" 
+#> cum_sum_x   "0.12538149"   "0.06259088"   "0.02999773"   "0.20868904"  
+#> cum_sum_y   " 0.06365697"  " 0.04211892"  " 0.05404344"  " 0.04209818" 
+#> cum_sum_z   "-0.12586486"  " 0.01199215"  "-0.18728270"  "-0.09138216" 
+#> cum_prod_x  "0"            "0"            "0"            "0"           
+#> cum_prod_y  "0"            "0"            "0"            "0"           
+#> cum_prod_z  "0"            "0"            "0"            "0"           
+#> cum_min_x   " 0.12538149"  "-0.06279061"  "-0.06279061"  "-0.06279061" 
+#> cum_min_y   " 0.06365697"  "-0.02153805"  "-0.02153805"  "-0.02153805" 
+#> cum_min_z   "-0.1258649"   "-0.1258649"   "-0.1992748"   "-0.1992748"  
+#> cum_max_x   "0.1253815"    "0.1253815"    "0.1253815"    "0.1786913"   
+#> cum_max_y   "0.06365697"   "0.06365697"   "0.06365697"   "0.06365697"  
+#> cum_max_z   "-0.1258649"   " 0.1378570"   " 0.1378570"   " 0.1378570"  
+#> cum_mean_x  "0.125381492"  "0.031295442"  "0.009999242"  "0.052172260" 
+#> cum_mean_y  " 0.063656967" " 0.021059458" " 0.018014480" " 0.010524545"
+#> cum_mean_z  "-0.125864863" " 0.005996075" "-0.062427566" "-0.022845540"
+#>             [,5]           [,6]          
+#> walk_number "1"            "1"           
+#> step_number "5"            "6"           
+#> x           " 0.04351815"  " 0.13686023" 
+#> y           "-0.06647694"  "-0.02362796" 
+#> z           " 0.03461036"  "-0.02007810" 
+#> cum_sum_x   "0.25220719"   "0.38906742"  
+#> cum_sum_y   "-0.02437876"  "-0.04800672" 
+#> cum_sum_z   "-0.05677180"  "-0.07684990" 
+#> cum_prod_x  "0"            "0"           
+#> cum_prod_y  "0"            "0"           
+#> cum_prod_z  "0"            "0"           
+#> cum_min_x   "-0.06279061"  "-0.06279061" 
+#> cum_min_y   "-0.06647694"  "-0.06647694" 
+#> cum_min_z   "-0.1992748"   "-0.1992748"  
+#> cum_max_x   "0.1786913"    "0.1786913"   
+#> cum_max_y   "0.06365697"   "0.06365697"  
+#> cum_max_z   " 0.1378570"   " 0.1378570"  
+#> cum_mean_x  "0.050441438"  "0.064844570" 
+#> cum_mean_y  "-0.004875753" "-0.008001120"
+#> cum_mean_z  "-0.011354360" "-0.012808317"
 
 
diff --git a/docs/reference/running_quantile.html b/docs/reference/running_quantile.html index b3c2470..65b558b 100644 --- a/docs/reference/running_quantile.html +++ b/docs/reference/running_quantile.html @@ -106,6 +106,7 @@

See alsoconvert_snake_to_title_case(), generate_caption(), get_attributes(), +rand_walk_column_names(), rand_walk_helper(), std_cum_max_augment(), std_cum_mean_augment(), diff --git a/docs/reference/rw30.html b/docs/reference/rw30.html index a40a28c..749e99c 100644 --- a/docs/reference/rw30.html +++ b/docs/reference/rw30.html @@ -69,18 +69,18 @@

Examplesset.seed(123) rw30() #> # A tibble: 3,000 × 3 -#> walk_number x y -#> <fct> <int> <dbl> -#> 1 1 1 0 -#> 2 1 2 -0.560 -#> 3 1 3 -0.791 -#> 4 1 4 0.768 -#> 5 1 5 0.839 -#> 6 1 6 0.968 -#> 7 1 7 2.68 -#> 8 1 8 3.14 -#> 9 1 9 1.88 -#> 10 1 10 1.19 +#> walk_number step_number y +#> <fct> <int> <dbl> +#> 1 1 1 0 +#> 2 1 2 -0.560 +#> 3 1 3 -0.791 +#> 4 1 4 0.768 +#> 5 1 5 0.839 +#> 6 1 6 0.968 +#> 7 1 7 2.68 +#> 8 1 8 3.14 +#> 9 1 9 1.88 +#> 10 1 10 1.19 #> # ℹ 2,990 more rows set.seed(123) diff --git a/docs/reference/std_cum_max_augment.html b/docs/reference/std_cum_max_augment.html index fadfef5..b892601 100644 --- a/docs/reference/std_cum_max_augment.html +++ b/docs/reference/std_cum_max_augment.html @@ -86,6 +86,7 @@

See alsoconvert_snake_to_title_case(), generate_caption(), get_attributes(), +rand_walk_column_names(), rand_walk_helper(), running_quantile(), std_cum_mean_augment(), diff --git a/docs/reference/std_cum_mean_augment.html b/docs/reference/std_cum_mean_augment.html index 7d12255..17a6f85 100644 --- a/docs/reference/std_cum_mean_augment.html +++ b/docs/reference/std_cum_mean_augment.html @@ -86,6 +86,7 @@

See alsoconvert_snake_to_title_case(), generate_caption(), get_attributes(), +rand_walk_column_names(), rand_walk_helper(), running_quantile(), std_cum_max_augment(), diff --git a/docs/reference/std_cum_min_augment.html b/docs/reference/std_cum_min_augment.html index 93f1b96..066baf6 100644 --- a/docs/reference/std_cum_min_augment.html +++ b/docs/reference/std_cum_min_augment.html @@ -86,6 +86,7 @@

See alsoconvert_snake_to_title_case(), generate_caption(), get_attributes(), +rand_walk_column_names(), rand_walk_helper(), running_quantile(), std_cum_max_augment(), diff --git a/docs/reference/std_cum_prod_augment.html b/docs/reference/std_cum_prod_augment.html index 03db4bf..bed162c 100644 --- a/docs/reference/std_cum_prod_augment.html +++ b/docs/reference/std_cum_prod_augment.html @@ -86,6 +86,7 @@

See alsoconvert_snake_to_title_case(), generate_caption(), get_attributes(), +rand_walk_column_names(), rand_walk_helper(), running_quantile(), std_cum_max_augment(), diff --git a/docs/reference/std_cum_sum_augment.html b/docs/reference/std_cum_sum_augment.html index d4ae559..f1e4b4e 100644 --- a/docs/reference/std_cum_sum_augment.html +++ b/docs/reference/std_cum_sum_augment.html @@ -86,6 +86,7 @@

See alsoconvert_snake_to_title_case(), generate_caption(), get_attributes(), +rand_walk_column_names(), rand_walk_helper(), running_quantile(), std_cum_max_augment(), diff --git a/docs/reference/summarize_walks.html b/docs/reference/summarize_walks.html index 866489c..bcde067 100644 --- a/docs/reference/summarize_walks.html +++ b/docs/reference/summarize_walks.html @@ -98,30 +98,29 @@

Exampleswalk_data <- random_normal_walk(.initial_value = 100) # Summarize the walks -summarize_walks(walk_data, cum_sum, walk_number) |> +summarize_walks(walk_data, cum_sum_y, walk_number) |> glimpse() #> Registered S3 method overwritten by 'quantmod': #> method from #> as.zoo.data.frame zoo #> Rows: 25 -#> Columns: 17 +#> Columns: 16 #> $ walk_number <fct> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, … #> $ fns <chr> "random_normal_walk", "random_normal_walk", "random_nor… #> $ fns_name <chr> "Random Normal Walk", "Random Normal Walk", "Random Nor… -#> $ dimensions <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1… -#> $ mean_val <dbl> 100.10659, 99.82922, 99.52922, 98.75850, 100.85864, 100… -#> $ median <dbl> 100.07614, 99.81004, 99.46064, 98.59080, 100.87054, 99.… -#> $ range <dbl> 1.4702499, 0.7206181, 0.9869902, 1.9579304, 1.4119450, … -#> $ quantile_lo <dbl> 99.47986, 99.56809, 99.17375, 98.08058, 100.38400, 99.6… -#> $ quantile_hi <dbl> 100.79633, 100.17122, 100.01265, 99.74580, 101.37084, 1… -#> $ variance <dbl> 0.14913626, 0.02532646, 0.07434017, 0.24369466, 0.10788… -#> $ sd <dbl> 0.3861816, 0.1591429, 0.2726539, 0.4936544, 0.3284642, … -#> $ min_val <dbl> 99.43543, 99.49121, 99.05844, 98.04468, 100.10611, 99.6… -#> $ max_val <dbl> 100.90568, 100.21183, 100.04543, 100.00261, 101.51805, … -#> $ harmonic_mean <dbl> 100.10512, 99.82897, 99.52849, 98.75607, 100.85759, 100… -#> $ geometric_mean <dbl> 100.10585, 99.82910, 99.52885, 98.75728, 100.85812, 100… -#> $ skewness <dbl> 0.18662786, 0.34427100, 0.42980993, 0.41718949, -0.0445… -#> $ kurtosis <dbl> -0.9483369, -0.1798819, -1.1319872, -0.8449953, -0.9673… +#> $ mean_val <dbl> 99.37422, 99.14832, 99.30183, 99.54731, 100.00967, 100.… +#> $ median <dbl> 99.22507, 99.12260, 99.14530, 99.56916, 100.03673, 100.… +#> $ range <dbl> 1.6702035, 1.7192108, 1.3793621, 1.0936667, 0.7246319, … +#> $ quantile_lo <dbl> 98.72405, 98.55386, 98.64469, 98.97943, 99.68817, 99.86… +#> $ quantile_hi <dbl> 100.27413, 100.11414, 99.95320, 100.03119, 100.24455, 1… +#> $ variance <dbl> 0.24567887, 0.14426274, 0.17370115, 0.08828192, 0.02889… +#> $ sd <dbl> 0.4956600, 0.3798194, 0.4167747, 0.2971227, 0.1699798, … +#> $ min_val <dbl> 98.67767, 98.49835, 98.60665, 98.95722, 99.66696, 99.85… +#> $ max_val <dbl> 100.34787, 100.21756, 99.98601, 100.05089, 100.39159, 1… +#> $ harmonic_mean <dbl> 99.37178, 99.14689, 99.30010, 99.54644, 100.00938, 100.… +#> $ geometric_mean <dbl> 99.37300, 99.14760, 99.30096, 99.54688, 100.00952, 100.… +#> $ skewness <dbl> 0.529493030, 0.913117028, 0.180208987, -0.190895194, -0… +#> $ kurtosis <dbl> -1.14650249, 0.87761015, -1.32915687, -0.84946617, -0.7… summarize_walks(walk_data, y) |> glimpse() #> Warning: There was 1 warning in `dplyr::summarize()`. @@ -129,23 +128,22 @@

Examples#> Caused by warning in `log()`: #> ! NaNs produced #> Rows: 1 -#> Columns: 16 +#> Columns: 15 #> $ fns <chr> "random_normal_walk" #> $ fns_name <chr> "Random Normal Walk" -#> $ dimensions <dbl> 1 -#> $ mean_val <dbl> -0.002189823 -#> $ median <dbl> -0.005327023 -#> $ range <dbl> 0.6899619 -#> $ quantile_lo <dbl> -0.1991602 -#> $ quantile_hi <dbl> 0.1989294 -#> $ variance <dbl> 0.01035473 -#> $ sd <dbl> 0.1017582 -#> $ min_val <dbl> -0.3047861 -#> $ max_val <dbl> 0.3851758 -#> $ harmonic_mean <dbl> -0.01258915 +#> $ mean_val <dbl> -0.0005154536 +#> $ median <dbl> 0.002946834 +#> $ range <dbl> 0.6436037 +#> $ quantile_lo <dbl> -0.1943871 +#> $ quantile_hi <dbl> 0.1900136 +#> $ variance <dbl> 0.009756546 +#> $ sd <dbl> 0.09877523 +#> $ min_val <dbl> -0.314552 +#> $ max_val <dbl> 0.3290517 +#> $ harmonic_mean <dbl> -0.04812531 #> $ geometric_mean <dbl> NaN -#> $ skewness <dbl> 0.1464476 -#> $ kurtosis <dbl> 0.09097494 +#> $ skewness <dbl> -0.09677662 +#> $ kurtosis <dbl> -0.07893013 # Example with missing value variable # summarize_walks(walk_data, NULL, group) # This will trigger an error. diff --git a/docs/reference/visualize_walks-3.png b/docs/reference/visualize_walks-3.png index cbfc9a6..8b6f4d0 100644 Binary files a/docs/reference/visualize_walks-3.png and b/docs/reference/visualize_walks-3.png differ diff --git a/docs/reference/visualize_walks-4.png b/docs/reference/visualize_walks-4.png index 309490f..232165a 100644 Binary files a/docs/reference/visualize_walks-4.png and b/docs/reference/visualize_walks-4.png differ diff --git a/docs/reference/visualize_walks.html b/docs/reference/visualize_walks.html index f475ddb..3f37309 100644 --- a/docs/reference/visualize_walks.html +++ b/docs/reference/visualize_walks.html @@ -133,7 +133,7 @@

Examplesrandom_normal_walk(.num_walks = 5, .initial_value = 100) |> visualize_walks(.interactive = TRUE)
- + # Use .pluck to pick just one visualization set.seed(123) random_normal_walk(.num_walks = 5, .initial_value = 100) |> diff --git a/docs/search.json b/docs/search.json index 4922daf..1768b75 100644 --- a/docs/search.json +++ b/docs/search.json @@ -1 +1 @@ -[{"path":"https://www.spsanderson.com/RandomWalker/articles/getting-started.html","id":"random-walks","dir":"Articles","previous_headings":"","what":"Random Walks","title":"Getting Started with RandomWalker","text":"random walk? random walk mathematical concept describing path consisting succession random steps. step independent previous ones, direction distance step determined chance. simplest form random walk one-dimensional walk, object moves either forward backward equal probability step. random walk, average position object NN steps zero, average square distance starting point NN, meaning object typically N\\sqrt{N} steps away start NN steps. concept widely used various fields, including physics, economics, computer science, model phenomena particle diffusion, stock price movements, network topology. finance, random walk theory suggests stock prices move unpredictably, making impossible predict future prices based past movements. theory underpins Efficient Market Hypothesis, posits available information already reflected stock prices, thus making impossible consistently outperform market. higher dimensions, random walks exhibit complex geometric properties can used model intricate systems, behavior particles fluid structure networks. understanding random walks, researchers can gain insights various stochastic processes applications across different scientific practical domains. Now basic understanding concepts, let’s explore can create visualize random walks using RandomWalker package R.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/articles/getting-started.html","id":"installation","dir":"Articles","previous_headings":"","what":"Installation","title":"Getting Started with RandomWalker","text":"can install released version RandomWalker CRAN : can install development version RandomWalker GitHub :","code":"install.packages(\"RandomWalker\") # install.packages(\"devtools\") devtools::install_github(\"spsanderson/RandomWalker\")"},{"path":"https://www.spsanderson.com/RandomWalker/articles/getting-started.html","id":"example-usage","dir":"Articles","previous_headings":"","what":"Example Usage","title":"Getting Started with RandomWalker","text":"Let’s start generating simple random walk using rw30() function RandomWalker package. function generates random walk 30 steps. output shows first 10 steps random walk. step represents position object moving forward backward one unit. rw30() function takes parameters generates 30 random walks 100 steps. uses rnorm() function generate random numbers normal distribution mean 0 standard deviation 1.","code":"rw30() |> head(10) #> # A tibble: 10 × 3 #> walk_number x y #> #> 1 1 1 0 #> 2 1 2 -1.40 #> 3 1 3 -1.14 #> 4 1 4 -3.58 #> 5 1 5 -3.59 #> 6 1 6 -2.97 #> 7 1 7 -1.82 #> 8 1 8 -3.64 #> 9 1 9 -3.89 #> 10 1 10 -4.13"},{"path":"https://www.spsanderson.com/RandomWalker/articles/getting-started.html","id":"attributes","dir":"Articles","previous_headings":"","what":"Attributes","title":"Getting Started with RandomWalker","text":"function RandomWalker package attributes can accessed using attributes() function. example, let’s look attributes rw30() function:","code":"atb <- attributes(rw30()) atb[!names(atb) %in% c(\"row.names\")] #> $names #> [1] \"walk_number\" \"x\" \"y\" #> #> $class #> [1] \"tbl_df\" \"tbl\" \"data.frame\" #> #> $num_walks #> [1] 30 #> #> $num_steps #> [1] 100 #> #> $mu #> [1] 0 #> #> $sd #> [1] 1 #> #> $fns #> [1] \"rw30\" #> #> $dimension #> [1] 1"},{"path":"https://www.spsanderson.com/RandomWalker/articles/getting-started.html","id":"visualizing-random-walks","dir":"Articles","previous_headings":"","what":"Visualizing Random Walks","title":"Getting Started with RandomWalker","text":"visualize random walk generated rw30() function, can use visualize_walks() function. function creates line plot showing path random walk time. plot shows path random walk time, x-axis representing number steps y-axis representing position object. random walk exhibits random pattern movement, object moving forward backward seemingly unpredictable manner.","code":"visualize_walks(rw30())"},{"path":"https://www.spsanderson.com/RandomWalker/articles/getting-started.html","id":"future-direction","dir":"Articles","previous_headings":"","what":"Future Direction","title":"Getting Started with RandomWalker","text":"now RandomWalker supports 1-dimensional random walks. future, plan extend package support higher-dimensional random walks provide additional functionalities analyzing visualizing random walks various contexts. hope vignette provided basic understanding random walks use RandomWalker package R. questions feedback, please feel free reach us.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/articles/getting-started.html","id":"references","dir":"Articles","previous_headings":"","what":"References","title":"Getting Started with RandomWalker","text":"Issues Discussions Random Walks Wikipedia","code":""},{"path":"https://www.spsanderson.com/RandomWalker/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Steven Sanderson. Author, maintainer, copyright holder. Antti Rask. Author, copyright holder.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Sanderson S, Rask (2024). RandomWalker: Generate Random Walks Compatible 'tidyverse'. R package version 0.2.0.9000, https://github.com/spsanderson/RandomWalker, https://www.spsanderson.com/RandomWalker/.","code":"@Manual{, title = {RandomWalker: Generate Random Walks Compatible with the 'tidyverse'}, author = {Steven Sanderson and Antti Rask}, year = {2024}, note = {R package version 0.2.0.9000, https://github.com/spsanderson/RandomWalker}, url = {https://www.spsanderson.com/RandomWalker/}, }"},{"path":"https://www.spsanderson.com/RandomWalker/index.html","id":"randomwalker-","dir":"","previous_headings":"","what":"Generate Random Walks Compatible with the tidyverse","title":"Generate Random Walks Compatible with the tidyverse","text":"goal RandomWalker allow users easily create Random Walks different types compatible tidyverse suite packages. package currently experimental stage development.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Generate Random Walks Compatible with the tidyverse","text":"can install released version {TidyDensity} CRAN : can install development version RandomWalker GitHub :","code":"install.packages(\"RandomWalker\") # install.packages(\"devtools\") devtools::install_github(\"spsanderson/RandomWalker\")"},{"path":"https://www.spsanderson.com/RandomWalker/index.html","id":"example","dir":"","previous_headings":"","what":"Example","title":"Generate Random Walks Compatible with the tidyverse","text":"basic example shows solve common problem: basic visualization Random Walk: basic summary random walks:","code":"library(RandomWalker) ## basic example code rw30() |> head(10) #> # A tibble: 10 × 3 #> walk_number x y #> #> 1 1 1 0 #> 2 1 2 1.52 #> 3 1 3 2.02 #> 4 1 4 1.82 #> 5 1 5 -0.120 #> 6 1 6 0.588 #> 7 1 7 0.412 #> 8 1 8 0.998 #> 9 1 9 1.37 #> 10 1 10 0.826 rw30() |> visualize_walks() rw30() |> summarize_walks(.value = y) #> # A tibble: 1 × 16 #> fns fns_name dimensions mean_val median range quantile_lo quantile_hi #> #> 1 rw30 Rw30 1 -0.670 -0.132 47.4 -18.3 14.2 #> # ℹ 8 more variables: variance , sd , min_val , max_val , #> # harmonic_mean , geometric_mean , skewness , kurtosis rw30() |> summarize_walks(.value = y, .group_var = walk_number) #> # A tibble: 30 × 17 #> walk_number fns fns_name dimensions mean_val median range quantile_lo #> #> 1 1 rw30 Rw30 1 -0.951 0.0447 15.6 -10.5 #> 2 2 rw30 Rw30 1 -0.947 -2.02 13.5 -5.69 #> 3 3 rw30 Rw30 1 -2.91 -3.42 12.9 -8.84 #> 4 4 rw30 Rw30 1 -0.0432 0.299 11.1 -4.63 #> 5 5 rw30 Rw30 1 -4.28 -4.52 12.8 -9.94 #> 6 6 rw30 Rw30 1 -1.77 -1.71 14.6 -9.60 #> 7 7 rw30 Rw30 1 -3.51 -3.43 13.6 -9.47 #> 8 8 rw30 Rw30 1 -4.25 -3.94 20.1 -14.8 #> 9 9 rw30 Rw30 1 1.93 2.16 7.11 -1.46 #> 10 10 rw30 Rw30 1 0.621 1.20 13.7 -5.59 #> # ℹ 20 more rows #> # ℹ 9 more variables: quantile_hi , variance , sd , #> # min_val , max_val , harmonic_mean , geometric_mean , #> # skewness , kurtosis "},{"path":"https://www.spsanderson.com/RandomWalker/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2024 Steven P. Sanderson II, MPH Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/brownian_motion.html","id":null,"dir":"Reference","previous_headings":"","what":"Brownian Motion — brownian_motion","title":"Brownian Motion — brownian_motion","text":"Create Brownian Motion Tibble","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/brownian_motion.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Brownian Motion — brownian_motion","text":"","code":"brownian_motion( .num_walks = 25, .n = 100, .delta_time = 1, .initial_value = 0, .return_tibble = TRUE )"},{"path":"https://www.spsanderson.com/RandomWalker/reference/brownian_motion.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Brownian Motion — brownian_motion","text":".num_walks Total number simulations. .n Total time simulation. .delta_time Time step size. .initial_value Integer representing initial value. .return_tibble default TRUE. set FALSE object class matrix returned.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/brownian_motion.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Brownian Motion — brownian_motion","text":"tibble/matrix","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/brownian_motion.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Brownian Motion — brownian_motion","text":"Brownian Motion, also known Wiener process, continuous-time random process describes random movement particles suspended fluid. named physicist Robert Brown, first described phenomenon 1827. equation Brownian Motion can represented : W(t) Brownian motion time t, W(0) initial value Brownian motion, sqrt(t) square root time, Z standard normal random variable. Brownian Motion numerous applications, including modeling stock prices financial markets, modeling particle movement fluids, modeling random walk processes general. useful tool probability theory statistical analysis.","code":"W(t) = W(0) + sqrt(t) * Z"},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/brownian_motion.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Brownian Motion — brownian_motion","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/brownian_motion.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Brownian Motion — brownian_motion","text":"","code":"set.seed(123) brownian_motion() #> # A tibble: 2,525 × 6 #> walk_number x y cum_min cum_max cum_mean #> #> 1 1 1 0 0 0 0 #> 2 1 2 -0.560 -0.560 0 -0.280 #> 3 1 3 -0.791 -0.791 0 -0.450 #> 4 1 4 0.768 -0.791 0.768 -0.146 #> 5 1 5 0.839 -0.791 0.839 0.0511 #> 6 1 6 0.968 -0.791 0.968 0.204 #> 7 1 7 2.68 -0.791 2.68 0.558 #> 8 1 8 3.14 -0.791 3.14 0.881 #> 9 1 9 1.88 -0.791 3.14 0.992 #> 10 1 10 1.19 -0.791 3.14 1.01 #> # ℹ 2,515 more rows set.seed(123) brownian_motion(.num_walks = 5) |> visualize_walks()"},{"path":"https://www.spsanderson.com/RandomWalker/reference/cgmean.html","id":null,"dir":"Reference","previous_headings":"","what":"Cumulative Geometric Mean — cgmean","title":"Cumulative Geometric Mean — cgmean","text":"function return cumulative geometric mean vector.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cgmean.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cumulative Geometric Mean — cgmean","text":"","code":"cgmean(.x)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/cgmean.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cumulative Geometric Mean — cgmean","text":".x numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cgmean.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cumulative Geometric Mean — cgmean","text":"numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cgmean.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Cumulative Geometric Mean — cgmean","text":"function return cumulative geometric mean vector. exp(cummean(log(.x)))","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/cgmean.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Cumulative Geometric Mean — cgmean","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cgmean.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cumulative Geometric Mean — cgmean","text":"","code":"x <- mtcars$mpg cgmean(x) #> [1] 21.00000 21.00000 21.58363 21.53757 20.93755 20.43547 19.41935 19.98155 #> [9] 20.27666 20.16633 19.93880 19.61678 19.42805 19.09044 18.33287 17.69470 #> [17] 17.50275 18.11190 18.61236 19.17879 19.28342 19.09293 18.90457 18.62961 #> [25] 18.65210 18.92738 19.15126 19.46993 19.33021 19.34242 19.18443 19.25006"},{"path":"https://www.spsanderson.com/RandomWalker/reference/chmean.html","id":null,"dir":"Reference","previous_headings":"","what":"Cumulative Harmonic Mean — chmean","title":"Cumulative Harmonic Mean — chmean","text":"function return cumulative harmonic mean vector.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/chmean.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cumulative Harmonic Mean — chmean","text":"","code":"chmean(.x)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/chmean.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cumulative Harmonic Mean — chmean","text":".x numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/chmean.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cumulative Harmonic Mean — chmean","text":"numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/chmean.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Cumulative Harmonic Mean — chmean","text":"function return cumulative harmonic mean vector. 1 / (cumsum(1 / .x))","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/chmean.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Cumulative Harmonic Mean — chmean","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/chmean.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cumulative Harmonic Mean — chmean","text":"","code":"x <- mtcars$mpg chmean(x) #> [1] 21.0000000 10.5000000 7.1891892 5.3813575 4.1788087 3.3949947 #> [7] 2.7436247 2.4663044 2.2255626 1.9943841 1.7934398 1.6166494 #> [13] 1.4784877 1.3474251 1.1928760 1.0701322 0.9975150 0.9677213 #> [19] 0.9378663 0.9126181 0.8754572 0.8286539 0.7858140 0.7419753 #> [25] 0.7143688 0.6961523 0.6779989 0.6632076 0.6364908 0.6165699 #> [31] 0.5922267 0.5762786"},{"path":"https://www.spsanderson.com/RandomWalker/reference/ckurtosis.html","id":null,"dir":"Reference","previous_headings":"","what":"Cumulative Kurtosis — ckurtosis","title":"Cumulative Kurtosis — ckurtosis","text":"function return cumulative kurtosis vector.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/ckurtosis.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cumulative Kurtosis — ckurtosis","text":"","code":"ckurtosis(.x)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/ckurtosis.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cumulative Kurtosis — ckurtosis","text":".x numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/ckurtosis.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cumulative Kurtosis — ckurtosis","text":"numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/ckurtosis.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Cumulative Kurtosis — ckurtosis","text":"function return cumulative kurtosis vector.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/ckurtosis.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Cumulative Kurtosis — ckurtosis","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/ckurtosis.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cumulative Kurtosis — ckurtosis","text":"","code":"x <- mtcars$mpg ckurtosis(x) #> [1] NaN NaN 1.500000 2.189216 2.518932 1.786006 2.744467 2.724675 #> [9] 2.930885 2.988093 2.690270 2.269038 2.176622 1.992044 2.839430 2.481896 #> [17] 2.356826 3.877115 3.174702 2.896931 3.000743 3.091225 3.182071 3.212816 #> [25] 3.352916 3.015952 2.837139 2.535185 2.595908 2.691103 2.738468 2.799467"},{"path":"https://www.spsanderson.com/RandomWalker/reference/cmean.html","id":null,"dir":"Reference","previous_headings":"","what":"Cumulative Mean — cmean","title":"Cumulative Mean — cmean","text":"function return cumulative mean vector.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cmean.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cumulative Mean — cmean","text":"","code":"cmean(.x)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/cmean.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cumulative Mean — cmean","text":".x numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cmean.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cumulative Mean — cmean","text":"numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cmean.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Cumulative Mean — cmean","text":"function return cumulative mean vector. uses dplyr::cummean() basis function.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/cmean.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Cumulative Mean — cmean","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cmean.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cumulative Mean — cmean","text":"","code":"x <- mtcars$mpg cmean(x) #> [1] 21.00000 21.00000 21.60000 21.55000 20.98000 20.50000 19.61429 20.21250 #> [9] 20.50000 20.37000 20.13636 19.82500 19.63077 19.31429 18.72000 18.20000 #> [17] 17.99412 18.79444 19.40526 20.13000 20.19524 19.98182 19.77391 19.50417 #> [25] 19.49200 19.79231 20.02222 20.39286 20.23448 20.21667 20.04839 20.09062"},{"path":"https://www.spsanderson.com/RandomWalker/reference/cmedian.html","id":null,"dir":"Reference","previous_headings":"","what":"Cumulative Median — cmedian","title":"Cumulative Median — cmedian","text":"function return cumulative median vector.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cmedian.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cumulative Median — cmedian","text":"","code":"cmedian(.x)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/cmedian.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cumulative Median — cmedian","text":".x numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cmedian.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cumulative Median — cmedian","text":"numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cmedian.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Cumulative Median — cmedian","text":"function return cumulative median vector.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/cmedian.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Cumulative Median — cmedian","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cmedian.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cumulative Median — cmedian","text":"","code":"x <- mtcars$mpg cmedian(x) #> [1] 21.00 21.00 21.00 21.20 21.00 21.00 21.00 21.00 21.00 21.00 21.00 20.10 #> [13] 19.20 18.95 18.70 18.40 18.10 18.40 18.70 18.95 19.20 18.95 18.70 18.40 #> [25] 18.70 18.95 19.20 19.20 19.20 19.20 19.20 19.20"},{"path":"https://www.spsanderson.com/RandomWalker/reference/convert_snake_to_title_case.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to convert a snake_case string to Title Case — convert_snake_to_title_case","title":"Helper function to convert a snake_case string to Title Case — convert_snake_to_title_case","text":"Converts snake_case string Title Case.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/convert_snake_to_title_case.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to convert a snake_case string to Title Case — convert_snake_to_title_case","text":"","code":"convert_snake_to_title_case(string)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/convert_snake_to_title_case.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to convert a snake_case string to Title Case — convert_snake_to_title_case","text":"string character string snake_case format.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/convert_snake_to_title_case.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to convert a snake_case string to Title Case — convert_snake_to_title_case","text":"character string converted Title Case.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/convert_snake_to_title_case.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Helper function to convert a snake_case string to Title Case — convert_snake_to_title_case","text":"function useful formatting strings readable way, especially dealing variable names identifiers use snake_case. function takes snake_case string converts Title Case. replaces underscores spaces, capitalizes first letter word, replaces substring \"cum\" \"cumulative\" better readability.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/convert_snake_to_title_case.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Helper function to convert a snake_case string to Title Case — convert_snake_to_title_case","text":"Antti Lennart Rask","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/convert_snake_to_title_case.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to convert a snake_case string to Title Case — convert_snake_to_title_case","text":"","code":"convert_snake_to_title_case(\"hello_world\") # \"Hello World\" #> [1] \"Hello World\" convert_snake_to_title_case(\"this_is_a_test\") # \"This Is A Test\" #> [1] \"This Is A Test\" convert_snake_to_title_case(\"cumulative_sum\") # \"Cumulative Sum\" #> [1] \"Cumulative Sum\""},{"path":"https://www.spsanderson.com/RandomWalker/reference/crange.html","id":null,"dir":"Reference","previous_headings":"","what":"Cumulative Range — crange","title":"Cumulative Range — crange","text":"function return cumulative range vector.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/crange.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cumulative Range — crange","text":"","code":"crange(.x)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/crange.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cumulative Range — crange","text":".x numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/crange.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cumulative Range — crange","text":"numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/crange.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Cumulative Range — crange","text":"function return cumulative range vector. uses max(.x[1:k]) - min(.x[1:k]) basis function.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/crange.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Cumulative Range — crange","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/crange.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cumulative Range — crange","text":"","code":"x <- mtcars$mpg crange(x) #> [1] 0.0 0.0 1.8 1.8 4.1 4.7 8.5 10.1 10.1 10.1 10.1 10.1 10.1 10.1 14.0 #> [16] 14.0 14.0 22.0 22.0 23.5 23.5 23.5 23.5 23.5 23.5 23.5 23.5 23.5 23.5 23.5 #> [31] 23.5 23.5"},{"path":"https://www.spsanderson.com/RandomWalker/reference/csd.html","id":null,"dir":"Reference","previous_headings":"","what":"Cumulative Standard Deviation — csd","title":"Cumulative Standard Deviation — csd","text":"function return cumulative standard deviation vector.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/csd.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cumulative Standard Deviation — csd","text":"","code":"csd(.x)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/csd.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cumulative Standard Deviation — csd","text":".x numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/csd.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cumulative Standard Deviation — csd","text":"numeric vector. Note: first entry always NaN.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/csd.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Cumulative Standard Deviation — csd","text":"function return cumulative standard deviation vector.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/csd.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Cumulative Standard Deviation — csd","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/csd.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cumulative Standard Deviation — csd","text":"","code":"x <- mtcars$mpg csd(x) #> [1] NaN 0.0000000 1.0392305 0.8544004 1.4737707 1.7663522 2.8445436 #> [8] 3.1302385 3.0524580 2.9070986 2.8647069 2.9366416 2.8975233 3.0252418 #> [15] 3.7142967 4.1476098 4.1046423 5.2332053 5.7405452 6.4594362 6.3029736 #> [22] 6.2319940 6.1698105 6.1772007 6.0474457 6.1199296 6.1188444 6.3166405 #> [29] 6.2611772 6.1530527 6.1217574 6.0269481"},{"path":"https://www.spsanderson.com/RandomWalker/reference/cskewness.html","id":null,"dir":"Reference","previous_headings":"","what":"Cumulative Skewness — cskewness","title":"Cumulative Skewness — cskewness","text":"function return cumulative skewness vector.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cskewness.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cumulative Skewness — cskewness","text":"","code":"cskewness(.x)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/cskewness.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cumulative Skewness — cskewness","text":".x numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cskewness.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cumulative Skewness — cskewness","text":"numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cskewness.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Cumulative Skewness — cskewness","text":"function return cumulative skewness vector.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/cskewness.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Cumulative Skewness — cskewness","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cskewness.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cumulative Skewness — cskewness","text":"","code":"x <- mtcars$mpg cskewness(x) #> [1] NaN NaN 0.707106781 0.997869718 -0.502052297 #> [6] -0.258803244 -0.867969171 -0.628239920 -0.808101715 -0.695348960 #> [11] -0.469220594 -0.256323338 -0.091505282 0.002188142 -0.519593266 #> [16] -0.512660692 -0.379598706 0.614549281 0.581410573 0.649357202 #> [21] 0.631855977 0.706212631 0.775750182 0.821447605 0.844413861 #> [26] 0.716010069 0.614326432 0.525141032 0.582528820 0.601075783 #> [31] 0.652552397 0.640439864"},{"path":"https://www.spsanderson.com/RandomWalker/reference/cvar.html","id":null,"dir":"Reference","previous_headings":"","what":"Cumulative Variance — cvar","title":"Cumulative Variance — cvar","text":"function return cumulative variance vector.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cvar.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cumulative Variance — cvar","text":"","code":"cvar(.x)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/cvar.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cumulative Variance — cvar","text":".x numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cvar.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cumulative Variance — cvar","text":"numeric vector. Note: first entry always NaN.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cvar.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Cumulative Variance — cvar","text":"function return cumulative variance vector. exp(cummean(log(.x)))","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/cvar.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Cumulative Variance — cvar","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cvar.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cumulative Variance — cvar","text":"","code":"x <- mtcars$mpg cvar(x) #> [1] NaN 0.000000 1.080000 0.730000 2.172000 3.120000 8.091429 #> [8] 9.798393 9.317500 8.451222 8.206545 8.623864 8.395641 9.152088 #> [15] 13.796000 17.202667 16.848088 27.386438 32.953860 41.724316 39.727476 #> [22] 38.837749 38.066561 38.157808 36.571600 37.453538 37.440256 39.899947 #> [29] 39.202340 37.860057 37.475914 36.324103"},{"path":"https://www.spsanderson.com/RandomWalker/reference/discrete_walk.html","id":null,"dir":"Reference","previous_headings":"","what":"Discrete Sampled Walk — discrete_walk","title":"Discrete Sampled Walk — discrete_walk","text":"discrete_walk function generates multiple random walks discrete time periods. step walk determined probabilistic sample specified upper lower bounds. function useful simulating stochastic processes, stock price movements scenarios outcomes determined random process.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/discrete_walk.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Discrete Sampled Walk — discrete_walk","text":"","code":"discrete_walk( .num_walks = 25, .n = 100, .upper_bound = 1, .lower_bound = -1, .upper_probability = 0.5, .initial_value = 100 )"},{"path":"https://www.spsanderson.com/RandomWalker/reference/discrete_walk.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Discrete Sampled Walk — discrete_walk","text":".num_walks Total number simulations. .n Total time simulation. .upper_bound upper bound random walk. .lower_bound lower bound random walk. .upper_probability probability upper bound. Default 0.5. lower bound calculated 1 - .upper_probability. .initial_value initial value random walk. Default 100.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/discrete_walk.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Discrete Sampled Walk — discrete_walk","text":"tibble containing simulated walks, columns walk number, time period, various cumulative metrics (sum, product, min, max).","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/discrete_walk.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Discrete Sampled Walk — discrete_walk","text":"function discrete_walk simulates random walks specified number simulations (.num_walks) given total time (.n). step walk either upper bound lower bound, determined probability (.upper_probability). initial value walk set user (.initial_value), cumulative sum, product, minimum, maximum steps calculated walk. results returned tibble detailed attributes, including parameters used simulation.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/discrete_walk.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Discrete Sampled Walk — discrete_walk","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/discrete_walk.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Discrete Sampled Walk — discrete_walk","text":"","code":"library(ggplot2) set.seed(123) discrete_walk() #> # A tibble: 2,500 × 8 #> walk_number x y cum_sum cum_prod cum_min cum_max cum_mean #> #> 1 1 1 -1 99 0 99 99 99 #> 2 1 2 1 100 0 99 101 100 #> 3 1 3 -1 99 0 99 101 99.7 #> 4 1 4 1 100 0 99 101 100 #> 5 1 5 1 101 0 99 101 100. #> 6 1 6 -1 100 0 99 101 100 #> 7 1 7 1 101 0 99 101 100. #> 8 1 8 1 102 0 99 101 100. #> 9 1 9 1 103 0 99 101 100. #> 10 1 10 -1 102 0 99 101 100. #> # ℹ 2,490 more rows set.seed(123) discrete_walk(.num_walks = 10, .n = 250, .upper_probability = 0.51, .initial_value = 100) |> visualize_walks()"},{"path":"https://www.spsanderson.com/RandomWalker/reference/euclidean_distance.html","id":null,"dir":"Reference","previous_headings":"","what":"Distance Calculations — euclidean_distance","title":"Distance Calculations — euclidean_distance","text":"function calculate Euclidean distance two vectors.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/euclidean_distance.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Distance Calculations — euclidean_distance","text":"","code":"euclidean_distance(.data, .x, .y, .pull_vector = FALSE)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/euclidean_distance.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Distance Calculations — euclidean_distance","text":".data data frame .x numeric vector .y numeric vector .pull_vector boolean TRUE FALSE. Default FALSE augment distance data frame. TRUE return vector distances return.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/euclidean_distance.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Distance Calculations — euclidean_distance","text":"numeric Vector ditances","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/euclidean_distance.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Distance Calculations — euclidean_distance","text":"function calculate Euclidean distance two vectors. uses formula sqrt((x - lag(x))^2 + (y - lag(y))^2). function uses augments data frame new column called distance.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/euclidean_distance.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Distance Calculations — euclidean_distance","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/euclidean_distance.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Distance Calculations — euclidean_distance","text":"","code":"set.seed(123) df <- rw30() euclidean_distance(df, x, y) #> # A tibble: 3,000 × 4 #> walk_number x y distance #> #> 1 1 1 0 NA #> 2 1 2 -0.560 1.15 #> 3 1 3 -0.791 1.03 #> 4 1 4 0.768 1.85 #> 5 1 5 0.839 1.00 #> 6 1 6 0.968 1.01 #> 7 1 7 2.68 1.99 #> 8 1 8 3.14 1.10 #> 9 1 9 1.88 1.61 #> 10 1 10 1.19 1.21 #> # ℹ 2,990 more rows euclidean_distance(df, x, y, TRUE) |> head(10) #> [1] NA 1.146356 1.026149 1.851910 1.002483 1.008323 1.985308 1.101110 #> [9] 1.612569 1.213164"},{"path":"https://www.spsanderson.com/RandomWalker/reference/generate_caption.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to generate a caption string based on provided attributes — generate_caption","title":"Helper function to generate a caption string based on provided attributes — generate_caption","text":"Generates caption string based provided attributes.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/generate_caption.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to generate a caption string based on provided attributes — generate_caption","text":"","code":"generate_caption(attributes)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/generate_caption.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to generate a caption string based on provided attributes — generate_caption","text":"attributes list containing various attributes may include dimension, num_steps, mu, sd.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/generate_caption.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to generate a caption string based on provided attributes — generate_caption","text":"character string representing generated caption. attributes provided, returns empty string.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/generate_caption.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Helper function to generate a caption string based on provided attributes — generate_caption","text":"function useful creating descriptive captions plots outputs based attributes provided. ensures non-null attributes included caption. function constructs caption string checking various attributes provided list. formats caption based presence specific attributes, dimensions, number steps, statistical parameters like mu standard deviation (sd).","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/generate_caption.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Helper function to generate a caption string based on provided attributes — generate_caption","text":"Antti Lennart Rask","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/generate_caption.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to generate a caption string based on provided attributes — generate_caption","text":"","code":"attrs <- list(dimension = 3, num_steps = 100, mu = 0.5, sd = 1.2) generate_caption(attrs) # \"3 dimensions, 100 steps, mu = 0.5, sd = 1.2.\" #> [1] \"3 dimensions, 100 steps, mu = 0.5, sd = 1.2.\" attrs <- list(dimension = NULL, num_steps = 50, mu = NULL, sd = 2.0) generate_caption(attrs) # \"50 steps, sd = 2.0.\" #> [1] \"50 steps, sd = 2.\""},{"path":"https://www.spsanderson.com/RandomWalker/reference/geometric_brownian_motion.html","id":null,"dir":"Reference","previous_headings":"","what":"Geometric Brownian Motion — geometric_brownian_motion","title":"Geometric Brownian Motion — geometric_brownian_motion","text":"Create Geometric Brownian Motion.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/geometric_brownian_motion.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Geometric Brownian Motion — geometric_brownian_motion","text":"","code":"geometric_brownian_motion( .num_walks = 25, .n = 100, .mu = 0, .sigma = 0.1, .initial_value = 100, .delta_time = 0.003, .return_tibble = TRUE )"},{"path":"https://www.spsanderson.com/RandomWalker/reference/geometric_brownian_motion.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Geometric Brownian Motion — geometric_brownian_motion","text":".num_walks Total number simulations. .n Total time simulation, many n points time. .mu Expected return .sigma Volatility .initial_value Integer representing initial value. .delta_time Time step size. .return_tibble default TRUE. set FALSE object class matrix returned.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/geometric_brownian_motion.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Geometric Brownian Motion — geometric_brownian_motion","text":"tibble/matrix","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/geometric_brownian_motion.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Geometric Brownian Motion — geometric_brownian_motion","text":"Geometric Brownian Motion (GBM) statistical method modeling evolution given financial asset time. type stochastic process, means system undergoes random changes time. GBM widely used field finance model behavior stock prices, foreign exchange rates, financial assets. based assumption asset's price follows random walk, meaning influenced number unpredictable factors market trends, news events, investor sentiment. equation GBM : S price asset, t time, m expected return asset, s volatility asset, dW small random change asset's price. GBM can used estimate likelihood different outcomes given asset, often used conjunction statistical methods make accurate predictions future performance asset. function provides ability simulating estimating parameters GBM process. can used analyze behavior financial assets make informed investment decisions.","code":"dS/S = mdt + sdW"},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/geometric_brownian_motion.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Geometric Brownian Motion — geometric_brownian_motion","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/geometric_brownian_motion.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Geometric Brownian Motion — geometric_brownian_motion","text":"","code":"set.seed(123) geometric_brownian_motion() #> # A tibble: 2,525 × 6 #> walk_number x y cum_min cum_max cum_mean #> #> 1 1 1 100 200 200 200 #> 2 1 2 99.7 200. 200 200. #> 3 1 3 99.6 200. 200 200. #> 4 1 4 100. 200. 200. 200. #> 5 1 5 100. 200. 200. 200. #> 6 1 6 101. 200. 201. 200. #> 7 1 7 101. 200. 201. 200. #> 8 1 8 102. 200. 202. 200. #> 9 1 9 101. 200. 202. 201. #> 10 1 10 101. 200. 202. 201. #> # ℹ 2,515 more rows set.seed(123) geometric_brownian_motion(.num_walks = 5) |> visualize_walks()"},{"path":"https://www.spsanderson.com/RandomWalker/reference/get_attributes.html","id":null,"dir":"Reference","previous_headings":"","what":"Get Attributes — get_attributes","title":"Get Attributes — get_attributes","text":"get_attributes function takes R object input returns attributes, omitting row.names attribute.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/get_attributes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get Attributes — get_attributes","text":"","code":"get_attributes(.data)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/get_attributes.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get Attributes — get_attributes","text":".data R object attributes extracted.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/get_attributes.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get Attributes — get_attributes","text":"list attributes input R object, excluding row.names.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/get_attributes.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Get Attributes — get_attributes","text":"function retrieves attributes given R object, excluding row.names attribute.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/get_attributes.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Get Attributes — get_attributes","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/get_attributes.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get Attributes — get_attributes","text":"","code":"get_attributes(rw30()) #> $names #> [1] \"walk_number\" \"x\" \"y\" #> #> $class #> [1] \"tbl_df\" \"tbl\" \"data.frame\" #> #> $num_walks #> [1] 30 #> #> $num_steps #> [1] 100 #> #> $mu #> [1] 0 #> #> $sd #> [1] 1 #> #> $fns #> [1] \"rw30\" #> #> $dimension #> [1] 1 #> get_attributes(iris) #> $names #> [1] \"Sepal.Length\" \"Sepal.Width\" \"Petal.Length\" \"Petal.Width\" \"Species\" #> #> $class #> [1] \"data.frame\" #> get_attributes(mtcars) #> $names #> [1] \"mpg\" \"cyl\" \"disp\" \"hp\" \"drat\" \"wt\" \"qsec\" \"vs\" \"am\" \"gear\" #> [11] \"carb\" #> #> $class #> [1] \"data.frame\" #>"},{"path":"https://www.spsanderson.com/RandomWalker/reference/kurtosis_vec.html","id":null,"dir":"Reference","previous_headings":"","what":"Compute Kurtosis of a Vector — kurtosis_vec","title":"Compute Kurtosis of a Vector — kurtosis_vec","text":"function takes vector input return kurtosis vector. length vector must least four numbers. kurtosis explains sharpness peak distribution data. ((1/n) * sum(x - mu})^4) / ((()1/n) * sum(x - mu)^2)^2","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/kurtosis_vec.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Compute Kurtosis of a Vector — kurtosis_vec","text":"","code":"kurtosis_vec(.x)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/kurtosis_vec.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Compute Kurtosis of a Vector — kurtosis_vec","text":".x numeric vector length four .","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/kurtosis_vec.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Compute Kurtosis of a Vector — kurtosis_vec","text":"kurtosis vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/kurtosis_vec.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Compute Kurtosis of a Vector — kurtosis_vec","text":"function return kurtosis vector.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/kurtosis_vec.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Compute Kurtosis of a Vector — kurtosis_vec","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/kurtosis_vec.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Compute Kurtosis of a Vector — kurtosis_vec","text":"","code":"set.seed(123) kurtosis_vec(rnorm(100, 3, 2)) #> [1] 2.838947"},{"path":"https://www.spsanderson.com/RandomWalker/reference/name.html","id":null,"dir":"Reference","previous_headings":"","what":"Cumulative Range — name","title":"Cumulative Range — name","text":"function return cumulative range vector.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/name.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cumulative Range — name","text":".x numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/name.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cumulative Range — name","text":"numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/name.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Cumulative Range — name","text":"function return cumulative range vector. uses max(.x[1:k]) - min(.x[1:k]) basis function.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/name.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Cumulative Range — name","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/name.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cumulative Range — name","text":"","code":"x <- mtcars$mpg crange(x) #> [1] 0.0 0.0 1.8 1.8 4.1 4.7 8.5 10.1 10.1 10.1 10.1 10.1 10.1 10.1 14.0 #> [16] 14.0 14.0 22.0 22.0 23.5 23.5 23.5 23.5 23.5 23.5 23.5 23.5 23.5 23.5 23.5 #> [31] 23.5 23.5"},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_drift_walk.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate Multiple Random Walks with Drift — random_normal_drift_walk","title":"Generate Multiple Random Walks with Drift — random_normal_drift_walk","text":"function generates specified number random walks, consisting specified number steps. steps generated normal distribution given mean standard deviation. additional drift term added step introduce consistent directional component walks.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_drift_walk.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate Multiple Random Walks with Drift — random_normal_drift_walk","text":"","code":"random_normal_drift_walk( .num_walks = 25, .n = 100, .mu = 0, .sd = 1, .drift = 0.1, .initial_value = 0 )"},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_drift_walk.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generate Multiple Random Walks with Drift — random_normal_drift_walk","text":".num_walks Integer. number random walks generate. Default 25. .n Integer. number steps random walk. Default 100. .mu Numeric. mean normal distribution used generating steps. Default 0. .sd Numeric. standard deviation normal distribution used generating steps. Default 1. .drift Numeric. drift term added step. Default 0.1. .initial_value numeric value indicating initial value walks. Default 0.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_drift_walk.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate Multiple Random Walks with Drift — random_normal_drift_walk","text":"tibble long format columns walk_number, x (step index), y (walk value). tibble attributes number walks, number steps, mean, standard deviation, drift.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_drift_walk.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Generate Multiple Random Walks with Drift — random_normal_drift_walk","text":"function generates multiple random walks specified drift. walk generated using normal distribution steps, additional drift term added step.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_drift_walk.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Generate Multiple Random Walks with Drift — random_normal_drift_walk","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_drift_walk.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Generate Multiple Random Walks with Drift — random_normal_drift_walk","text":"","code":"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()"},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_walk.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate Multiple Random Normal Walks — random_normal_walk","title":"Generate Multiple Random Normal Walks — random_normal_walk","text":"random_normal_walk function useful simulating random processes can applied various fields finance, physics, biology model different stochastic behaviors.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_walk.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate Multiple Random Normal Walks — random_normal_walk","text":"","code":"random_normal_walk( .num_walks = 25, .n = 100, .mu = 0, .sd = 0.1, .initial_value = 0, .samp = TRUE, .replace = TRUE, .sample_size = 0.8 )"},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_walk.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generate Multiple Random Normal Walks — random_normal_walk","text":".num_walks integer specifying number random walks generate. Default 25. .n integer specifying number steps walk. Default 100. .mu numeric value indicating mean normal distribution. Default 0. .sd numeric value indicating standard deviation normal distribution. Default 0.1. .initial_value numeric value indicating initial value walks. Default 0. .samp logical value indicating whether sample normal distribution values. Default TRUE. .replace logical value indicating whether sampling replacement. Default TRUE. .sample_size numeric value 0 1 specifying proportion .n sample. Default 0.8.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_walk.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate Multiple Random Normal Walks — random_normal_walk","text":"tibble containing generated random walks following columns: walk_number: Factor representing walk number. x: Step index. y: Normal distribution values. cum_sum: Cumulative sum y. cum_prod: Cumulative product y. cum_min: Cumulative minimum y. cum_max: Cumulative maximum y. tibble includes attributes function parameters.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_walk.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Generate Multiple Random Normal Walks — random_normal_walk","text":"function generates multiple random walks, sequences steps step random draw normal distribution. user can specify number walks, number steps walk, parameters normal distribution (mean standard deviation). function also allows sampling proportion steps optionally sampling replacement. output tibble includes several computed columns walk, cumulative sum, product, minimum, maximum steps.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_walk.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Generate Multiple Random Normal Walks — random_normal_walk","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_walk.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Generate Multiple Random Normal Walks — random_normal_walk","text":"","code":"library(ggplot2) # Generate 10 random walks with 50 steps each set.seed(123) random_normal_walk(.num_walks = 10, .n = 50) #> # A tibble: 400 × 8 #> walk_number x y cum_sum cum_prod cum_min cum_max cum_mean #> #> 1 1 1 0.125 0.125 0 0.125 0.125 0.125 #> 2 1 2 0.172 0.297 0 0.125 0.172 0.148 #> 3 1 3 -0.127 0.170 0 -0.127 0.172 0.0568 #> 4 1 4 -0.0218 0.149 0 -0.127 0.172 0.0371 #> 5 1 5 -0.0218 0.127 0 -0.127 0.172 0.0254 #> 6 1 6 -0.0306 0.0962 0 -0.127 0.172 0.0160 #> 7 1 7 0.0426 0.139 0 -0.127 0.172 0.0198 #> 8 1 8 0.0498 0.189 0 -0.127 0.172 0.0236 #> 9 1 9 0.0878 0.276 0 -0.127 0.172 0.0307 #> 10 1 10 0.00705 0.283 0 -0.127 0.172 0.0283 #> # ℹ 390 more rows # Generate random walks with different mean and standard deviation set.seed(123) random_normal_walk(.num_walks = 10, .n = 50, .samp = FALSE) #> # A tibble: 500 × 8 #> walk_number x y cum_sum cum_prod cum_min cum_max cum_mean #> #> 1 1 1 -0.0560 -0.0560 0 -0.0560 -0.0560 -0.0560 #> 2 1 2 -0.0230 -0.0791 0 -0.0560 -0.0230 -0.0395 #> 3 1 3 0.156 0.0768 0 -0.0560 0.156 0.0256 #> 4 1 4 0.00705 0.0839 0 -0.0560 0.156 0.0210 #> 5 1 5 0.0129 0.0968 0 -0.0560 0.156 0.0194 #> 6 1 6 0.172 0.268 0 -0.0560 0.172 0.0447 #> 7 1 7 0.0461 0.314 0 -0.0560 0.172 0.0449 #> 8 1 8 -0.127 0.188 0 -0.127 0.172 0.0235 #> 9 1 9 -0.0687 0.119 0 -0.127 0.172 0.0132 #> 10 1 10 -0.0446 0.0746 0 -0.127 0.172 0.00746 #> # ℹ 490 more rows set.seed(123) random_normal_walk(.num_walks = 2, .n = 100, .initial_value = 100) |> visualize_walks()"},{"path":"https://www.spsanderson.com/RandomWalker/reference/rand_walk_helper.html","id":null,"dir":"Reference","previous_headings":"","what":"Random Walk Helper — rand_walk_helper","title":"Random Walk Helper — rand_walk_helper","text":"function help build random walks mutating data frame.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/rand_walk_helper.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Random Walk Helper — rand_walk_helper","text":"","code":"rand_walk_helper(.data, .value)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/rand_walk_helper.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Random Walk Helper — rand_walk_helper","text":".data data frame mutate. .value .initial_value use. passed random walk function called end user.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/rand_walk_helper.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Random Walk Helper — rand_walk_helper","text":"modified data frame/tibble following columns added: cum_sum: Cumulative sum y. cum_prod: Cumulative product y. cum_min: Cumulative minimum y. cum_max: Cumulative maximum y. cum_mean: Cumulative mean y.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/rand_walk_helper.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Random Walk Helper — rand_walk_helper","text":"function help build random walks mutating data frame. mutation adds following columns data frame: cum_sum, cum_prod, cum_min, cum_max, cum_mean. function used internally certain functions generate random walks.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/rand_walk_helper.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Random Walk Helper — rand_walk_helper","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/rand_walk_helper.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Random Walk Helper — rand_walk_helper","text":"","code":"df <- data.frame( walk_number = factor(rep(1L:25L, each = 30L)), x = rep(1L:30L, 25L), y = rnorm(750L, 0L, 1L) ) rand_walk_helper(df, 100) #> # A tibble: 750 × 8 #> walk_number x y cum_sum cum_prod cum_min cum_max cum_mean #> #> 1 1 1 0.551 101. 155. 101. 101. 101. #> 2 1 2 -2.09 98.5 -169. 97.9 101. 99.2 #> 3 1 3 -0.0249 98.4 -165. 97.9 101. 99.5 #> 4 1 4 0.888 99.3 -311. 97.9 101. 99.8 #> 5 1 5 -0.337 99.0 -206. 97.9 101. 99.8 #> 6 1 6 -1.03 98.0 6.33 97.9 101. 99.7 #> 7 1 7 0.431 98.4 9.05 97.9 101. 99.8 #> 8 1 8 0.209 98.6 10.9 97.9 101. 99.8 #> 9 1 9 -1.55 97.0 -6.00 97.9 101. 99.7 #> 10 1 10 -1.17 95.9 1.04 97.9 101. 99.6 #> # ℹ 740 more rows"},{"path":"https://www.spsanderson.com/RandomWalker/reference/running_quantile.html","id":null,"dir":"Reference","previous_headings":"","what":"Running Quantile Calculation — running_quantile","title":"Running Quantile Calculation — running_quantile","text":"running_quantile function calculates quantile vector sliding window, allowing various alignment rule options.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/running_quantile.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Running Quantile Calculation — running_quantile","text":"","code":"running_quantile( .x, .window, .probs = 0.5, .type = 7, .rule = \"quantile\", .align = \"center\" )"},{"path":"https://www.spsanderson.com/RandomWalker/reference/running_quantile.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Running Quantile Calculation — running_quantile","text":".x numeric vector running quantile calculated. .window integer specifying size sliding window. .probs numeric value 0 1 indicating desired quantile probability (default 0.50). .type integer 1 9 specifying quantile algorithm type (default 7). .rule character string indicating rule apply edges window. Possible choices : \"quantile\": Standard quantile calculation. \"trim\": Trims output remove values outside window. \"keep\": Keeps original values edges window. \"constant\": Fills edges constant value nearest valid quantile. \"NA\": Fills edges NA values. \"func\": Applies custom function values window (default \"quantile\"). .align character string specifying alignment window (\"center\", \"left\", \"right\"; default \"center\").","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/running_quantile.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Running Quantile Calculation — running_quantile","text":"numeric vector containing running quantile values.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/running_quantile.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Running Quantile Calculation — running_quantile","text":"function computes running quantile numeric vector using specified window size probability.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/running_quantile.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Running Quantile Calculation — running_quantile","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/running_quantile.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Running Quantile Calculation — running_quantile","text":"","code":"# Example usage of running_quantile set.seed(123) data <- cumsum(rnorm(50)) result <- running_quantile(data, .window = 3, .probs = 0.5) print(result) #> [1] -0.6755644 -0.5604756 0.7680552 0.8385636 0.9678513 2.6829163 #> [7] 2.6829163 1.8787713 1.1919184 1.1919184 1.9703382 2.3301521 #> [13] 2.7309235 2.7309235 2.8416062 4.0726782 4.0726782 3.3052675 #> [19] 2.8324760 2.8324760 1.7646523 1.5466774 0.5206730 -0.2082182 #> [25] -0.8332575 -1.6821638 -1.6821638 -1.6821638 -1.5287907 -1.4131127 #> [31] -1.2817199 -0.9866485 -0.3865943 0.4915392 1.3131203 2.0017605 #> [37] 2.4937665 2.4937665 2.1878038 1.8073328 1.1126258 0.9047086 #> [43] 0.9047086 1.8082682 1.8931216 1.8931216 1.4902368 1.4902368 #> [49] 1.7201775 1.7618620 #> attr(,\"window\") #> [1] 3 #> attr(,\"probs\") #> [1] 0.5 #> attr(,\"type\") #> [1] 7 #> attr(,\"rule\") #> [1] \"quantile\" #> attr(,\"align\") #> [1] \"center\" plot(data, type = \"l\") lines(result, col = \"red\")"},{"path":"https://www.spsanderson.com/RandomWalker/reference/rw30.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate Random Walks — rw30","title":"Generate Random Walks — rw30","text":"Generate Random Walks","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/rw30.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate Random Walks — rw30","text":"","code":"rw30()"},{"path":"https://www.spsanderson.com/RandomWalker/reference/rw30.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate Random Walks — rw30","text":"tibble long format columns walk, x, value, representing random walks. Additionally, attributes num_walks, num_steps, mu, sd attached tibble.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/rw30.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Generate Random Walks — rw30","text":"function generates random walks using normal distribution specified mean (mu) standard deviation (sd). walk generated independently stored tibble. resulting tibble pivoted long format easier analysis.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/rw30.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Generate Random Walks — rw30","text":"Steven P. Sanderson II, MPH function generates 30 random walks 100 steps pivots result long format tibble.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/rw30.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Generate Random Walks — rw30","text":"","code":"# Generate random walks and print the result set.seed(123) rw30() #> # A tibble: 3,000 × 3 #> walk_number x y #> #> 1 1 1 0 #> 2 1 2 -0.560 #> 3 1 3 -0.791 #> 4 1 4 0.768 #> 5 1 5 0.839 #> 6 1 6 0.968 #> 7 1 7 2.68 #> 8 1 8 3.14 #> 9 1 9 1.88 #> 10 1 10 1.19 #> # ℹ 2,990 more rows set.seed(123) rw30() |> visualize_walks()"},{"path":"https://www.spsanderson.com/RandomWalker/reference/rw_range.html","id":null,"dir":"Reference","previous_headings":"","what":"Range — rw_range","title":"Range — rw_range","text":"function return range vector.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/rw_range.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Range — rw_range","text":"","code":"rw_range(.x)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/rw_range.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Range — rw_range","text":".x numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/rw_range.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Range — rw_range","text":"numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/rw_range.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Range — rw_range","text":"function return range vector. uses max(.x) - min(.x) basis function.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/rw_range.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Range — rw_range","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/rw_range.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Range — rw_range","text":"","code":"x <- mtcars$mpg rw_range(x) #> [1] 23.5"},{"path":"https://www.spsanderson.com/RandomWalker/reference/skewness_vec.html","id":null,"dir":"Reference","previous_headings":"","what":"Compute Skewness of a Vector — skewness_vec","title":"Compute Skewness of a Vector — skewness_vec","text":"function takes vector input return skewness vector. length vector must least four numbers. skewness explains 'tailedness' distribution data. ((1/n) * sum(x - mu})^3) / ((()1/n) * sum(x - mu)^2)^(3/2)","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/skewness_vec.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Compute Skewness of a Vector — skewness_vec","text":"","code":"skewness_vec(.x)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/skewness_vec.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Compute Skewness of a Vector — skewness_vec","text":".x numeric vector length four .","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/skewness_vec.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Compute Skewness of a Vector — skewness_vec","text":"skewness vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/skewness_vec.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Compute Skewness of a Vector — skewness_vec","text":"function return skewness vector.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/skewness_vec.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Compute Skewness of a Vector — skewness_vec","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/skewness_vec.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Compute Skewness of a Vector — skewness_vec","text":"","code":"set.seed(123) skewness_vec(rnorm(100, 3, 2)) #> [1] 0.06049948"},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_max_augment.html","id":null,"dir":"Reference","previous_headings":"","what":"Augment Cumulative Maximum — std_cum_max_augment","title":"Augment Cumulative Maximum — std_cum_max_augment","text":"function augments data frame adding cumulative maximum columns specified variables.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_max_augment.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Augment Cumulative Maximum — std_cum_max_augment","text":"","code":"std_cum_max_augment(.data, .value, .names = \"auto\", .initial_value = 0)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_max_augment.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Augment Cumulative Maximum — std_cum_max_augment","text":".data data frame augment. .value column name names compute cumulative maximum. .names Optional. character vector names new cumulative maximum columns. Defaults \"auto\", generates names based original column names. .initial_value numeric value start cumulative maximum . Defaults 0.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_max_augment.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Augment Cumulative Maximum — std_cum_max_augment","text":"tibble original data additional columns containing cumulative maximums.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_max_augment.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Augment Cumulative Maximum — std_cum_max_augment","text":"function takes data frame column name (names) computes cumulative maximum specified column, starting initial value. column names provided, throw error.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_max_augment.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Augment Cumulative Maximum — std_cum_max_augment","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_max_augment.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Augment Cumulative Maximum — std_cum_max_augment","text":"","code":"df <- data.frame(x = c(1, 3, 2, 5, 4), y = c(10, 7, 6, 12, 5)) std_cum_max_augment(df, .value = x) #> # A tibble: 5 × 3 #> x y cum_max_x #> #> 1 1 10 1 #> 2 3 7 3 #> 3 2 6 3 #> 4 5 12 5 #> 5 4 5 5 std_cum_max_augment(df, .value = y, .names = c(\"cummax_y\")) #> # A tibble: 5 × 3 #> x y cummax_y #> #> 1 1 10 10 #> 2 3 7 10 #> 3 2 6 10 #> 4 5 12 12 #> 5 4 5 12"},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_mean_augment.html","id":null,"dir":"Reference","previous_headings":"","what":"Augment Cumulative Sum — std_cum_mean_augment","title":"Augment Cumulative Sum — std_cum_mean_augment","text":"function augments data frame adding cumulative mean columns specified variables.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_mean_augment.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Augment Cumulative Sum — std_cum_mean_augment","text":"","code":"std_cum_mean_augment(.data, .value, .names = \"auto\", .initial_value = 0)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_mean_augment.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Augment Cumulative Sum — std_cum_mean_augment","text":".data data frame augment. .value column name names compute cumulative mean. .names Optional. character vector names new cumulative mean columns. Defaults \"auto\", generates names based original column names. .initial_value numeric value start cumulative mean . Defaults 0.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_mean_augment.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Augment Cumulative Sum — std_cum_mean_augment","text":"tibble original data additional columns containing cumulative means.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_mean_augment.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Augment Cumulative Sum — std_cum_mean_augment","text":"function takes data frame column name (names) computes cumulative mean specified column, starting initial value. column names provided, throw error.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_mean_augment.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Augment Cumulative Sum — std_cum_mean_augment","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_mean_augment.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Augment Cumulative Sum — std_cum_mean_augment","text":"","code":"df <- data.frame(x = c(1, 2, 3, 4, 5), y = c(10, 20, 30, 40, 50)) std_cum_mean_augment(df, .value = x) #> # A tibble: 5 × 3 #> x y cum_mean_x #> #> 1 1 10 1 #> 2 2 20 1.5 #> 3 3 30 2 #> 4 4 40 2.5 #> 5 5 50 3 std_cum_mean_augment(df, .value = y, .names = c(\"cummean_y\")) #> # A tibble: 5 × 3 #> x y cummean_y #> #> 1 1 10 10 #> 2 2 20 15 #> 3 3 30 20 #> 4 4 40 25 #> 5 5 50 30"},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_min_augment.html","id":null,"dir":"Reference","previous_headings":"","what":"Augment Cumulative Minimum — std_cum_min_augment","title":"Augment Cumulative Minimum — std_cum_min_augment","text":"function augments data frame adding cumulative minimum columns specified variables.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_min_augment.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Augment Cumulative Minimum — std_cum_min_augment","text":"","code":"std_cum_min_augment(.data, .value, .names = \"auto\", .initial_value = 0)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_min_augment.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Augment Cumulative Minimum — std_cum_min_augment","text":".data data frame augment. .value column name names compute cumulative minimum. .names Optional. character vector names new cumulative minimum columns. Defaults \"auto\", generates names based original column names. .initial_value numeric value start cumulative minimum . Defaults 0.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_min_augment.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Augment Cumulative Minimum — std_cum_min_augment","text":"tibble original data additional columns containing cumulative minimums.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_min_augment.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Augment Cumulative Minimum — std_cum_min_augment","text":"function takes data frame column name (names) computes cumulative minimum specified column, starting initial value. column names provided, throw error.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_min_augment.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Augment Cumulative Minimum — std_cum_min_augment","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_min_augment.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Augment Cumulative Minimum — std_cum_min_augment","text":"","code":"df <- data.frame(x = c(5, 3, 8, 1, 4), y = c(10, 7, 6, 12, 5)) std_cum_min_augment(df, .value = x) #> # A tibble: 5 × 3 #> x y cum_min_x #> #> 1 5 10 5 #> 2 3 7 3 #> 3 8 6 3 #> 4 1 12 1 #> 5 4 5 1 std_cum_min_augment(df, .value = y, .names = c(\"cummin_y\")) #> # A tibble: 5 × 3 #> x y cummin_y #> #> 1 5 10 10 #> 2 3 7 7 #> 3 8 6 6 #> 4 1 12 6 #> 5 4 5 5"},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_prod_augment.html","id":null,"dir":"Reference","previous_headings":"","what":"Augment Cumulative Product — std_cum_prod_augment","title":"Augment Cumulative Product — std_cum_prod_augment","text":"function augments data frame adding cumulative product columns specified variables.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_prod_augment.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Augment Cumulative Product — std_cum_prod_augment","text":"","code":"std_cum_prod_augment(.data, .value, .names = \"auto\", .initial_value = 1)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_prod_augment.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Augment Cumulative Product — std_cum_prod_augment","text":".data data frame augment. .value column name names compute cumulative product. .names Optional. character vector names new cumulative product columns. Defaults \"auto\", generates names based original column names. .initial_value numeric value start cumulative product . Defaults 1.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_prod_augment.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Augment Cumulative Product — std_cum_prod_augment","text":"tibble original data additional columns containing cumulative products.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_prod_augment.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Augment Cumulative Product — std_cum_prod_augment","text":"function takes data frame column name (names) computes cumulative product specified column, starting initial value. column names provided, throw error.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_prod_augment.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Augment Cumulative Product — std_cum_prod_augment","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_prod_augment.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Augment Cumulative Product — std_cum_prod_augment","text":"","code":"df <- data.frame(x = 1:5, y = 6:10) std_cum_prod_augment(df, .value = x) #> # A tibble: 5 × 3 #> x y cum_prod_x #> #> 1 1 6 2 #> 2 2 7 6 #> 3 3 8 24 #> 4 4 9 120 #> 5 5 10 720 std_cum_prod_augment(df, .value = y, .names = c(\"cumprod_y\")) #> # A tibble: 5 × 3 #> x y cumprod_y #> #> 1 1 6 7 #> 2 2 7 56 #> 3 3 8 504 #> 4 4 9 5040 #> 5 5 10 55440"},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_sum_augment.html","id":null,"dir":"Reference","previous_headings":"","what":"Augment Cumulative Sum — std_cum_sum_augment","title":"Augment Cumulative Sum — std_cum_sum_augment","text":"function augments data frame adding cumulative sum columns specified variables.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_sum_augment.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Augment Cumulative Sum — std_cum_sum_augment","text":"","code":"std_cum_sum_augment(.data, .value, .names = \"auto\", .initial_value = 0)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_sum_augment.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Augment Cumulative Sum — std_cum_sum_augment","text":".data data frame augment. .value column name names compute cumulative sum. .names Optional. character vector names new cumulative sum columns. Defaults \"auto\", generates names based original column names. .initial_value numeric value start cumulative sum . Defaults 0.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_sum_augment.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Augment Cumulative Sum — std_cum_sum_augment","text":"tibble original data additional columns containing cumulative sums.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_sum_augment.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Augment Cumulative Sum — std_cum_sum_augment","text":"function takes data frame column name (names) computes cumulative sum specified column, starting initial value. column names provided, throw error.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_sum_augment.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Augment Cumulative Sum — std_cum_sum_augment","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_sum_augment.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Augment Cumulative Sum — std_cum_sum_augment","text":"","code":"df <- data.frame(x = 1:5, y = 6:10) std_cum_sum_augment(df, .value = x) #> # A tibble: 5 × 3 #> x y cum_sum_x #> #> 1 1 6 1 #> 2 2 7 3 #> 3 3 8 6 #> 4 4 9 10 #> 5 5 10 15 std_cum_sum_augment(df, .value = y, .names = c(\"cumsum_y\")) #> # A tibble: 5 × 3 #> x y cumsum_y #> #> 1 1 6 6 #> 2 2 7 13 #> 3 3 8 21 #> 4 4 9 30 #> 5 5 10 40"},{"path":"https://www.spsanderson.com/RandomWalker/reference/summarize_walks.html","id":null,"dir":"Reference","previous_headings":"","what":"Summarize Walks Data — summarize_walks","title":"Summarize Walks Data — summarize_walks","text":"Summarizes random walk data computing statistical measures.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/summarize_walks.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Summarize Walks Data — summarize_walks","text":"","code":"summarize_walks(.data, .value, .group_var) summarise_walks(.data, .value, .group_var)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/summarize_walks.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Summarize Walks Data — summarize_walks","text":".data data frame tibble containing random walk data. .value column name (unquoted) representing value summarize. .group_var column name (unquoted) representing grouping variable.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/summarize_walks.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Summarize Walks Data — summarize_walks","text":"tibble containing summarized statistics group, including mean, median, range, quantiles, variance, standard deviation, .","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/summarize_walks.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Summarize Walks Data — summarize_walks","text":"function requires input data frame contains column named 'walk_number' value summarize provided. computes statistics mean, median, variance, quantiles specified value variable. #' function summarizes data frame containing random walk data computing various statistical measures specified value variable, grouped specified grouping variable. checks necessary attributes ensures data frame structured correctly.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/summarize_walks.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Summarize Walks Data — summarize_walks","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/summarize_walks.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Summarize Walks Data — summarize_walks","text":"","code":"library(dplyr) #> #> Attaching package: 'dplyr' #> The following objects are masked from 'package:stats': #> #> filter, lag #> The following objects are masked from 'package:base': #> #> intersect, setdiff, setequal, union # Example data frame walk_data <- random_normal_walk(.initial_value = 100) # Summarize the walks summarize_walks(walk_data, cum_sum, walk_number) |> glimpse() #> Registered S3 method overwritten by 'quantmod': #> method from #> as.zoo.data.frame zoo #> Rows: 25 #> Columns: 17 #> $ walk_number 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, … #> $ fns \"random_normal_walk\", \"random_normal_walk\", \"random_nor… #> $ fns_name \"Random Normal Walk\", \"Random Normal Walk\", \"Random Nor… #> $ dimensions 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1… #> $ mean_val 100.10659, 99.82922, 99.52922, 98.75850, 100.85864, 100… #> $ median 100.07614, 99.81004, 99.46064, 98.59080, 100.87054, 99.… #> $ range 1.4702499, 0.7206181, 0.9869902, 1.9579304, 1.4119450, … #> $ quantile_lo 99.47986, 99.56809, 99.17375, 98.08058, 100.38400, 99.6… #> $ quantile_hi 100.79633, 100.17122, 100.01265, 99.74580, 101.37084, 1… #> $ variance 0.14913626, 0.02532646, 0.07434017, 0.24369466, 0.10788… #> $ sd 0.3861816, 0.1591429, 0.2726539, 0.4936544, 0.3284642, … #> $ min_val 99.43543, 99.49121, 99.05844, 98.04468, 100.10611, 99.6… #> $ max_val 100.90568, 100.21183, 100.04543, 100.00261, 101.51805, … #> $ harmonic_mean 100.10512, 99.82897, 99.52849, 98.75607, 100.85759, 100… #> $ geometric_mean 100.10585, 99.82910, 99.52885, 98.75728, 100.85812, 100… #> $ skewness 0.18662786, 0.34427100, 0.42980993, 0.41718949, -0.0445… #> $ kurtosis -0.9483369, -0.1798819, -1.1319872, -0.8449953, -0.9673… summarize_walks(walk_data, y) |> glimpse() #> Warning: There was 1 warning in `dplyr::summarize()`. #> ℹ In argument: `geometric_mean = exp(mean(log(y)))`. #> Caused by warning in `log()`: #> ! NaNs produced #> Rows: 1 #> Columns: 16 #> $ fns \"random_normal_walk\" #> $ fns_name \"Random Normal Walk\" #> $ dimensions 1 #> $ mean_val -0.002189823 #> $ median -0.005327023 #> $ range 0.6899619 #> $ quantile_lo -0.1991602 #> $ quantile_hi 0.1989294 #> $ variance 0.01035473 #> $ sd 0.1017582 #> $ min_val -0.3047861 #> $ max_val 0.3851758 #> $ harmonic_mean -0.01258915 #> $ geometric_mean NaN #> $ skewness 0.1464476 #> $ kurtosis 0.09097494 # Example with missing value variable # summarize_walks(walk_data, NULL, group) # This will trigger an error."},{"path":"https://www.spsanderson.com/RandomWalker/reference/visualize_walks.html","id":null,"dir":"Reference","previous_headings":"","what":"Visualize Walks — visualize_walks","title":"Visualize Walks — visualize_walks","text":"visualize_walks() visualizes output random walk functions RandomWalker package, resulting one ggplot2 plots put together patchwork composed 1 patches.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/visualize_walks.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Visualize Walks — visualize_walks","text":"","code":"visualize_walks(.data, .alpha = 0.7, .interactive = FALSE, .pluck = FALSE)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/visualize_walks.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Visualize Walks — visualize_walks","text":".data input data. Assumed created one random walk functions RandomWalker package, can data frame tibble contains columns walk_number, x, one numeric columns like y, cum_sum, cum_prod, cum_min, cum_max cum_mean, instance. .alpha alpha value line charts visualization. Values range 0 1. Default 0.7. .interactive boolean value. TRUE want patches interactive. FALSE . Default FALSE. .pluck want visualize one can choose one values (y, cum_sum, cum_prod, cum_min, cum_max, cum_mean). Default FALSE.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/visualize_walks.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Visualize Walks — visualize_walks","text":"patchwork composed 1 patches","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/visualize_walks.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Visualize Walks — visualize_walks","text":"visualize_walks() generates visualizations random walks generated random walk functions RandomWalker package. functions moment writing: brownian_motion() discrete_walk() geometric_brownian_motion() random_normal_drift_walk() random_normal_walk() rw30() possible read , can check rest documentation current situation. visualization function meant easy use. parameters needed, can set .alpha default value 0.7 liking. can also choose whether want visualization interactive setting .interactive TRUE. function uses ggiraph package making patches interactive. want visualize one attributes, can choose use one values (y, cum_sum, cum_prod, cum_min, cum_max, cum_mean) .pluck parameter.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/visualize_walks.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Visualize Walks — visualize_walks","text":"Antti Lennart Rask","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/visualize_walks.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Visualize Walks — visualize_walks","text":"","code":"# Generate random walks and visualize the result set.seed(123) rw30() |> visualize_walks() # Set the alpha value to be other than the default 0.7 set.seed(123) rw30() |> visualize_walks(.alpha = 0.5) # Use the function with an input that has alternatives for y set.seed(123) random_normal_walk(.num_walks = 5, .initial_value = 100) |> visualize_walks() # Use the function to create interactive visualizations set.seed(123) random_normal_walk(.num_walks = 5, .initial_value = 100) |> visualize_walks(.interactive = TRUE) {\"x\":{\"html\":\"\\n\\n \\n \\n \\n <\\/clipPath>\\n \\n \\n <\\/clipPath>\\n \\n \\n <\\/clipPath>\\n \\n \\n <\\/clipPath>\\n \\n \\n <\\/clipPath>\\n \\n \\n <\\/clipPath>\\n \\n \\n <\\/clipPath>\\n \\n \\n <\\/clipPath>\\n \\n \\n <\\/clipPath>\\n \\n \\n <\\/clipPath>\\n \\n \\n <\\/clipPath>\\n \\n \\n <\\/clipPath>\\n \\n \\n <\\/clipPath>\\n \\n \\n <\\/clipPath>\\n <\\/defs>\\n \\n \\n \\n \\n <\\/g>\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n <\\/g>\\n \\n -0.3<\\/text>\\n -0.2<\\/text>\\n -0.1<\\/text>\\n 0.0<\\/text>\\n 0.1<\\/text>\\n 0.2<\\/text>\\n 0<\\/text>\\n 20<\\/text>\\n 40<\\/text>\\n 60<\\/text>\\n 80<\\/text>\\n Step<\\/text>\\n y<\\/text>\\n <\\/g>\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n <\\/g>\\n \\n 99<\\/text>\\n 100<\\/text>\\n 0<\\/text>\\n 20<\\/text>\\n 40<\\/text>\\n 60<\\/text>\\n 80<\\/text>\\n Step<\\/text>\\n Cumulative Sum<\\/text>\\n <\\/g>\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n <\\/g>\\n \\n 50<\\/text>\\n 100<\\/text>\\n 150<\\/text>\\n 0<\\/text>\\n 20<\\/text>\\n 40<\\/text>\\n 60<\\/text>\\n 80<\\/text>\\n Step<\\/text>\\n Cumulative Prod<\\/text>\\n <\\/g>\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n <\\/g>\\n \\n 99.8<\\/text>\\n 99.9<\\/text>\\n 100.0<\\/text>\\n 0<\\/text>\\n 20<\\/text>\\n 40<\\/text>\\n 60<\\/text>\\n 80<\\/text>\\n Step<\\/text>\\n Cumulative Min<\\/text>\\n <\\/g>\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n <\\/g>\\n \\n 99.9<\\/text>\\n 100.0<\\/text>\\n 100.1<\\/text>\\n 100.2<\\/text>\\n 0<\\/text>\\n 20<\\/text>\\n 40<\\/text>\\n 60<\\/text>\\n 80<\\/text>\\n Step<\\/text>\\n Cumulative Max<\\/text>\\n <\\/g>\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n <\\/g>\\n \\n 99.90<\\/text>\\n 99.95<\\/text>\\n 100.00<\\/text>\\n 100.05<\\/text>\\n 0<\\/text>\\n 20<\\/text>\\n 40<\\/text>\\n 60<\\/text>\\n 80<\\/text>\\n Step<\\/text>\\n Cumulative Mean<\\/text>\\n 1 dimensions, mu = 0, sd = 0.1.<\\/text>\\n Function: Random Normal Walk<\\/text>\\n 5 Random Walks<\\/text>\\n <\\/g>\\n <\\/g>\\n<\\/svg>\",\"js\":null,\"uid\":\"svg_aec48058_7bde_48bc_b8f4_30dedcd72eb4\",\"ratio\":1.2,\"settings\":{\"tooltip\":{\"css\":\".tooltip_SVGID_ { padding:5px;background:black;color:white;border-radius:2px 2px 2px 2px;text-align:left; ; position:absolute;pointer-events:none;z-index:999;}\",\"placement\":\"doc\",\"opacity\":0.7,\"offx\":200,\"offy\":5,\"use_cursor_pos\":false,\"use_fill\":false,\"use_stroke\":false,\"delay_over\":200,\"delay_out\":500},\"hover\":{\"css\":\".hover_data_SVGID_ { stroke:black;stroke-width:2pt; }\",\"reactive\":false,\"nearest_distance\":null},\"hover_inv\":{\"css\":\".hover_inv_SVGID_ { opacity:0.4; }\"},\"hover_key\":{\"css\":\".hover_key_SVGID_ { fill:orange;stroke:black;cursor:pointer; }\\ntext.hover_key_SVGID_ { stroke:none;fill:orange; }\\ncircle.hover_key_SVGID_ { fill:orange;stroke:black; }\\nline.hover_key_SVGID_, polyline.hover_key_SVGID_ { fill:none;stroke:orange; }\\nrect.hover_key_SVGID_, polygon.hover_key_SVGID_, path.hover_key_SVGID_ { fill:orange;stroke:none; }\\nimage.hover_key_SVGID_ { stroke:orange; }\",\"reactive\":true},\"hover_theme\":{\"css\":\".hover_theme_SVGID_ { fill:orange;stroke:black;cursor:pointer; }\\ntext.hover_theme_SVGID_ { stroke:none;fill:orange; }\\ncircle.hover_theme_SVGID_ { fill:orange;stroke:black; }\\nline.hover_theme_SVGID_, polyline.hover_theme_SVGID_ { fill:none;stroke:orange; }\\nrect.hover_theme_SVGID_, polygon.hover_theme_SVGID_, path.hover_theme_SVGID_ { fill:orange;stroke:none; }\\nimage.hover_theme_SVGID_ { stroke:orange; }\",\"reactive\":true},\"select\":{\"css\":\".select_data_SVGID_ { fill:red;stroke:black;cursor:pointer; }\\ntext.select_data_SVGID_ { stroke:none;fill:red; }\\ncircle.select_data_SVGID_ { fill:red;stroke:black; }\\nline.select_data_SVGID_, polyline.select_data_SVGID_ { fill:none;stroke:red; }\\nrect.select_data_SVGID_, polygon.select_data_SVGID_, path.select_data_SVGID_ { fill:red;stroke:none; }\\nimage.select_data_SVGID_ { stroke:red; }\",\"type\":\"multiple\",\"only_shiny\":true,\"selected\":[]},\"select_inv\":{\"css\":\"\"},\"select_key\":{\"css\":\".select_key_SVGID_ { fill:red;stroke:black;cursor:pointer; }\\ntext.select_key_SVGID_ { stroke:none;fill:red; }\\ncircle.select_key_SVGID_ { fill:red;stroke:black; }\\nline.select_key_SVGID_, polyline.select_key_SVGID_ { fill:none;stroke:red; }\\nrect.select_key_SVGID_, polygon.select_key_SVGID_, path.select_key_SVGID_ { fill:red;stroke:none; }\\nimage.select_key_SVGID_ { stroke:red; }\",\"type\":\"single\",\"only_shiny\":true,\"selected\":[]},\"select_theme\":{\"css\":\".select_theme_SVGID_ { fill:red;stroke:black;cursor:pointer; }\\ntext.select_theme_SVGID_ { stroke:none;fill:red; }\\ncircle.select_theme_SVGID_ { fill:red;stroke:black; }\\nline.select_theme_SVGID_, polyline.select_theme_SVGID_ { fill:none;stroke:red; }\\nrect.select_theme_SVGID_, polygon.select_theme_SVGID_, path.select_theme_SVGID_ { fill:red;stroke:none; }\\nimage.select_theme_SVGID_ { stroke:red; }\",\"type\":\"single\",\"only_shiny\":true,\"selected\":[]},\"zoom\":{\"min\":1,\"max\":5,\"duration\":300},\"toolbar\":{\"position\":\"topright\",\"pngname\":\"diagram\",\"tooltips\":null,\"fixed\":false,\"hidden\":[],\"delay_over\":200,\"delay_out\":500},\"sizing\":{\"rescale\":true,\"width\":1}}},\"evals\":[],\"jsHooks\":[]} # Use .pluck to pick just one visualization set.seed(123) random_normal_walk(.num_walks = 5, .initial_value = 100) |> visualize_walks(.pluck = \"cum_sum\")"},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/news/index.html","id":"randomwalker-020","dir":"Changelog","previous_headings":"","what":"RandomWalker 0.2.0","title":"RandomWalker 0.2.0","text":"CRAN release: 2024-10-23","code":""},{"path":"https://www.spsanderson.com/RandomWalker/news/index.html","id":"breaking-changes-0-2-0","dir":"Changelog","previous_headings":"","what":"Breaking Changes","title":"RandomWalker 0.2.0","text":"None","code":""},{"path":"https://www.spsanderson.com/RandomWalker/news/index.html","id":"new-features-0-2-0","dir":"Changelog","previous_headings":"","what":"New Features","title":"RandomWalker 0.2.0","text":"Fix #92 - Add Function std_cum_sum_augment() calculate cumulative sum random walk. Fix #93 - Add Function std_cum_prod_augment() calculate cumulative product random walk. Fix #94 - Add Function std_cum_min_augment() calculate cumulative minimum random walk. Fix #95 - Add Function std_cum_max_augment() calculate cumulative maximum random walk. Fix #96 - Add Function std_cum_mean_augment() calculate cumulative mean random walk. Fix #113 - Add Function get_attributes() get attributes without row.names Fix #123 - Add Function running_quantile() calculate running quantile given vector.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/news/index.html","id":"minor-improvements-and-fixes-0-2-0","dir":"Changelog","previous_headings":"","what":"Minor Improvements and Fixes","title":"RandomWalker 0.2.0","text":"Fix #117 - Add .interactive parameter visualize_walks() allow interactive plots. Fix #120 - Add .pluck parameter visualize_walks() allow plucking specific graph walks.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/news/index.html","id":"release-blog-post-0-2-0","dir":"Changelog","previous_headings":"","what":"Release Blog Post","title":"RandomWalker 0.2.0","text":"https://www.spsanderson.com/steveondata/posts/2024-10-24/","code":""},{"path":"https://www.spsanderson.com/RandomWalker/news/index.html","id":"randomwalker-010","dir":"Changelog","previous_headings":"","what":"RandomWalker 0.1.0","title":"RandomWalker 0.1.0","text":"CRAN release: 2024-09-15","code":""},{"path":"https://www.spsanderson.com/RandomWalker/news/index.html","id":"breaking-changes-0-1-0","dir":"Changelog","previous_headings":"","what":"Breaking Changes","title":"RandomWalker 0.1.0","text":"None","code":""},{"path":"https://www.spsanderson.com/RandomWalker/news/index.html","id":"new-features-0-1-0","dir":"Changelog","previous_headings":"","what":"New Features","title":"RandomWalker 0.1.0","text":"Fix #9 - Add Function rw30() generate 30 random walks 100 steps Fix #17 - Add Function geometric_brownian_motion() generate Geometric Brownian Motion Fix #18 - Add Function random_normal_drift_walk() generate Random Walk Drift Fix #16 - Add Function brownian_motion() generate Brownian Motion Fix #13 - Add Function random_normal_walk() generate Random Walk Fix #30 - Add Function discrete_walk() generate Discrete Random Walk Fix #43 - Add vectorized functions Fix #44 - Add Function internal_rand_walk_helper() help generate common columns random walks. Fix #34 - Add Function euclidean_distance() calculate Euclidean distance random walk. Fix #33 - Add Function visualize_walks() visualize random walks. Fix #66 - Add Function summarize_walks() summarize random walks.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/news/index.html","id":"minor-improvements-and-fixes-0-1-0","dir":"Changelog","previous_headings":"","what":"Minor Improvements and Fixes","title":"RandomWalker 0.1.0","text":"None","code":""}] +[{"path":"https://www.spsanderson.com/RandomWalker/articles/getting-started.html","id":"random-walks","dir":"Articles","previous_headings":"","what":"Random Walks","title":"Getting Started with RandomWalker","text":"random walk? random walk mathematical concept describing path consisting succession random steps. step independent previous ones, direction distance step determined chance. simplest form random walk one-dimensional walk, object moves either forward backward equal probability step. random walk, average position object NN steps zero, average square distance starting point NN, meaning object typically N\\sqrt{N} steps away start NN steps. concept widely used various fields, including physics, economics, computer science, model phenomena particle diffusion, stock price movements, network topology. finance, random walk theory suggests stock prices move unpredictably, making impossible predict future prices based past movements. theory underpins Efficient Market Hypothesis, posits available information already reflected stock prices, thus making impossible consistently outperform market. higher dimensions, random walks exhibit complex geometric properties can used model intricate systems, behavior particles fluid structure networks. understanding random walks, researchers can gain insights various stochastic processes applications across different scientific practical domains. Now basic understanding concepts, let’s explore can create visualize random walks using RandomWalker package R.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/articles/getting-started.html","id":"installation","dir":"Articles","previous_headings":"","what":"Installation","title":"Getting Started with RandomWalker","text":"can install released version RandomWalker CRAN : can install development version RandomWalker GitHub :","code":"install.packages(\"RandomWalker\") # install.packages(\"devtools\") devtools::install_github(\"spsanderson/RandomWalker\")"},{"path":"https://www.spsanderson.com/RandomWalker/articles/getting-started.html","id":"example-usage","dir":"Articles","previous_headings":"","what":"Example Usage","title":"Getting Started with RandomWalker","text":"Let’s start generating simple random walk using rw30() function RandomWalker package. function generates random walk 30 steps. output shows first 10 steps random walk. step represents position object moving forward backward one unit. rw30() function takes parameters generates 30 random walks 100 steps. uses rnorm() function generate random numbers normal distribution mean 0 standard deviation 1.","code":"rw30() |> head(10) #> # A tibble: 10 × 3 #> walk_number step_number y #> #> 1 1 1 0 #> 2 1 2 -1.40 #> 3 1 3 -1.14 #> 4 1 4 -3.58 #> 5 1 5 -3.59 #> 6 1 6 -2.97 #> 7 1 7 -1.82 #> 8 1 8 -3.64 #> 9 1 9 -3.89 #> 10 1 10 -4.13"},{"path":"https://www.spsanderson.com/RandomWalker/articles/getting-started.html","id":"attributes","dir":"Articles","previous_headings":"","what":"Attributes","title":"Getting Started with RandomWalker","text":"function RandomWalker package attributes can accessed using attributes() function. example, let’s look attributes rw30() function:","code":"atb <- attributes(rw30()) atb[!names(atb) %in% c(\"row.names\")] #> $names #> [1] \"walk_number\" \"step_number\" \"y\" #> #> $class #> [1] \"tbl_df\" \"tbl\" \"data.frame\" #> #> $num_walks #> [1] 30 #> #> $num_steps #> [1] 100 #> #> $mu #> [1] 0 #> #> $sd #> [1] 1 #> #> $fns #> [1] \"rw30\" #> #> $dimension #> [1] 1"},{"path":"https://www.spsanderson.com/RandomWalker/articles/getting-started.html","id":"visualizing-random-walks","dir":"Articles","previous_headings":"","what":"Visualizing Random Walks","title":"Getting Started with RandomWalker","text":"visualize random walk generated rw30() function, can use visualize_walks() function. function creates line plot showing path random walk time. plot shows path random walk time, x-axis representing number steps y-axis representing position object. random walk exhibits random pattern movement, object moving forward backward seemingly unpredictable manner.","code":"visualize_walks(rw30())"},{"path":"https://www.spsanderson.com/RandomWalker/articles/getting-started.html","id":"future-direction","dir":"Articles","previous_headings":"","what":"Future Direction","title":"Getting Started with RandomWalker","text":"now RandomWalker supports 1-dimensional random walks. future, plan extend package support higher-dimensional random walks provide additional functionalities analyzing visualizing random walks various contexts. hope vignette provided basic understanding random walks use RandomWalker package R. questions feedback, please feel free reach us.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/articles/getting-started.html","id":"references","dir":"Articles","previous_headings":"","what":"References","title":"Getting Started with RandomWalker","text":"Issues Discussions Random Walks Wikipedia","code":""},{"path":"https://www.spsanderson.com/RandomWalker/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Steven Sanderson. Author, maintainer, copyright holder. Antti Rask. Author, copyright holder.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Sanderson S, Rask (2024). RandomWalker: Generate Random Walks Compatible 'tidyverse'. R package version 0.2.0.9000, https://github.com/spsanderson/RandomWalker, https://www.spsanderson.com/RandomWalker/.","code":"@Manual{, title = {RandomWalker: Generate Random Walks Compatible with the 'tidyverse'}, author = {Steven Sanderson and Antti Rask}, year = {2024}, note = {R package version 0.2.0.9000, https://github.com/spsanderson/RandomWalker}, url = {https://www.spsanderson.com/RandomWalker/}, }"},{"path":"https://www.spsanderson.com/RandomWalker/index.html","id":"randomwalker-","dir":"","previous_headings":"","what":"Generate Random Walks Compatible with the tidyverse","title":"Generate Random Walks Compatible with the tidyverse","text":"goal RandomWalker allow users easily create Random Walks different types compatible tidyverse suite packages. package currently experimental stage development.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Generate Random Walks Compatible with the tidyverse","text":"can install released version {TidyDensity} CRAN : can install development version RandomWalker GitHub :","code":"install.packages(\"RandomWalker\") # install.packages(\"devtools\") devtools::install_github(\"spsanderson/RandomWalker\")"},{"path":"https://www.spsanderson.com/RandomWalker/index.html","id":"example","dir":"","previous_headings":"","what":"Example","title":"Generate Random Walks Compatible with the tidyverse","text":"basic example shows solve common problem: basic visualization Random Walk: basic summary random walks:","code":"library(RandomWalker) ## basic example code rw30() |> head(10) #> # A tibble: 10 × 3 #> walk_number x y #> #> 1 1 1 0 #> 2 1 2 1.52 #> 3 1 3 2.02 #> 4 1 4 1.82 #> 5 1 5 -0.120 #> 6 1 6 0.588 #> 7 1 7 0.412 #> 8 1 8 0.998 #> 9 1 9 1.37 #> 10 1 10 0.826 rw30() |> visualize_walks() rw30() |> summarize_walks(.value = y) #> # A tibble: 1 × 16 #> fns fns_name dimensions mean_val median range quantile_lo quantile_hi #> #> 1 rw30 Rw30 1 -0.670 -0.132 47.4 -18.3 14.2 #> # ℹ 8 more variables: variance , sd , min_val , max_val , #> # harmonic_mean , geometric_mean , skewness , kurtosis rw30() |> summarize_walks(.value = y, .group_var = walk_number) #> # A tibble: 30 × 17 #> walk_number fns fns_name dimensions mean_val median range quantile_lo #> #> 1 1 rw30 Rw30 1 -0.951 0.0447 15.6 -10.5 #> 2 2 rw30 Rw30 1 -0.947 -2.02 13.5 -5.69 #> 3 3 rw30 Rw30 1 -2.91 -3.42 12.9 -8.84 #> 4 4 rw30 Rw30 1 -0.0432 0.299 11.1 -4.63 #> 5 5 rw30 Rw30 1 -4.28 -4.52 12.8 -9.94 #> 6 6 rw30 Rw30 1 -1.77 -1.71 14.6 -9.60 #> 7 7 rw30 Rw30 1 -3.51 -3.43 13.6 -9.47 #> 8 8 rw30 Rw30 1 -4.25 -3.94 20.1 -14.8 #> 9 9 rw30 Rw30 1 1.93 2.16 7.11 -1.46 #> 10 10 rw30 Rw30 1 0.621 1.20 13.7 -5.59 #> # ℹ 20 more rows #> # ℹ 9 more variables: quantile_hi , variance , sd , #> # min_val , max_val , harmonic_mean , geometric_mean , #> # skewness , kurtosis "},{"path":"https://www.spsanderson.com/RandomWalker/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2024 Steven P. Sanderson II, MPH Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/brownian_motion.html","id":null,"dir":"Reference","previous_headings":"","what":"Brownian Motion — brownian_motion","title":"Brownian Motion — brownian_motion","text":"Create Brownian Motion Tibble","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/brownian_motion.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Brownian Motion — brownian_motion","text":"","code":"brownian_motion( .num_walks = 25, .n = 100, .delta_time = 1, .initial_value = 0, .dimensions = 1 )"},{"path":"https://www.spsanderson.com/RandomWalker/reference/brownian_motion.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Brownian Motion — brownian_motion","text":".num_walks Total number simulations. .n Total time simulation. .delta_time Time step size. .initial_value Integer representing initial value. .dimensions default 1. Allowable values 1, 2 3.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/brownian_motion.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Brownian Motion — brownian_motion","text":"tibble containing generated random walks columns depending number dimensions: walk_number: Factor representing walk number. step_number: Step index. y: .dimensions = 1, value walk step. x, y: .dimensions = 2, values walk two dimensions. x, y, z: .dimensions = 3, values walk three dimensions. following also returned based upon many dimensions x, y z: cum_sum: Cumulative sum dplyr::all_of(.dimensions). cum_prod: Cumulative product dplyr::all_of(.dimensions). cum_min: Cumulative minimum dplyr::all_of(.dimensions). cum_max: Cumulative maximum dplyr::all_of(.dimensions). cum_mean: Cumulative mean dplyr::all_of(.dimensions).","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/brownian_motion.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Brownian Motion — brownian_motion","text":"Brownian Motion, also known Wiener process, continuous-time random process describes random movement particles suspended fluid. named physicist Robert Brown, first described phenomenon 1827. equation Brownian Motion can represented : W(t) Brownian motion time t, W(0) initial value Brownian motion, sqrt(t) square root time, Z standard normal random variable. Brownian Motion numerous applications, including modeling stock prices financial markets, modeling particle movement fluids, modeling random walk processes general. useful tool probability theory statistical analysis.","code":"W(t) = W(0) + sqrt(t) * Z"},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/brownian_motion.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Brownian Motion — brownian_motion","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/brownian_motion.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Brownian Motion — brownian_motion","text":"","code":"set.seed(123) brownian_motion() #> # A tibble: 2,500 × 8 #> walk_number step_number y cum_sum_y cum_prod_y cum_min_y cum_max_y #> #> 1 1 1 -0.560 -0.560 0 -0.560 -0.560 #> 2 1 2 -0.230 -0.791 0 -0.560 -0.230 #> 3 1 3 1.56 0.768 0 -0.560 1.56 #> 4 1 4 0.0705 0.839 0 -0.560 1.56 #> 5 1 5 0.129 0.968 0 -0.560 1.56 #> 6 1 6 1.72 2.68 0 -0.560 1.72 #> 7 1 7 0.461 3.14 0 -0.560 1.72 #> 8 1 8 -1.27 1.88 0 -1.27 1.72 #> 9 1 9 -0.687 1.19 0 -1.27 1.72 #> 10 1 10 -0.446 0.746 0 -1.27 1.72 #> # ℹ 2,490 more rows #> # ℹ 1 more variable: cum_mean_y set.seed(123) brownian_motion(.dimensions = 3) |> head() |> t() #> [,1] [,2] [,3] [,4] #> walk_number \"1\" \"1\" \"1\" \"1\" #> step_number \"1\" \"2\" \"3\" \"4\" #> x \"-0.56047565\" \"-0.23017749\" \" 1.55870831\" \" 0.07050839\" #> y \"-0.71040656\" \" 0.25688371\" \"-0.24669188\" \"-0.34754260\" #> z \" 2.1988103\" \" 1.3124130\" \"-0.2651451\" \" 0.5431941\" #> cum_sum_x \"-0.5604756\" \"-0.7906531\" \" 0.7680552\" \" 0.8385636\" #> cum_sum_y \"-0.7104066\" \"-0.4535229\" \"-0.7002147\" \"-1.0477573\" #> cum_sum_z \"2.198810\" \"3.511223\" \"3.246078\" \"3.789272\" #> cum_prod_x \"0\" \"0\" \"0\" \"0\" #> cum_prod_y \"0\" \"0\" \"0\" \"0\" #> cum_prod_z \"0\" \"0\" \"0\" \"0\" #> cum_min_x \"-0.5604756\" \"-0.5604756\" \"-0.5604756\" \"-0.5604756\" #> cum_min_y \"-0.7104066\" \"-0.7104066\" \"-0.7104066\" \"-0.7104066\" #> cum_min_z \" 2.1988103\" \" 1.3124130\" \"-0.2651451\" \"-0.2651451\" #> cum_max_x \"-0.5604756\" \"-0.2301775\" \" 1.5587083\" \" 1.5587083\" #> cum_max_y \"-0.7104066\" \" 0.2568837\" \" 0.2568837\" \" 0.2568837\" #> cum_max_z \"2.19881\" \"2.19881\" \"2.19881\" \"2.19881\" #> cum_mean_x \"-0.5604756\" \"-0.3953266\" \" 0.2560184\" \" 0.2096409\" #> cum_mean_y \"-0.7104066\" \"-0.2267614\" \"-0.2334049\" \"-0.2619393\" #> cum_mean_z \"2.1988103\" \"1.7556117\" \"1.0820261\" \"0.9473181\" #> [,5] [,6] #> walk_number \"1\" \"1\" #> step_number \"5\" \"6\" #> x \" 0.12928774\" \" 1.71506499\" #> y \"-0.95161857\" \"-0.04502772\" #> z \"-0.4143399\" \"-0.4762469\" #> cum_sum_x \" 0.9678513\" \" 2.6829163\" #> cum_sum_y \"-1.9993759\" \"-2.0444036\" #> cum_sum_z \"3.374932\" \"2.898685\" #> cum_prod_x \"0\" \"0\" #> cum_prod_y \"0\" \"0\" #> cum_prod_z \"0\" \"0\" #> cum_min_x \"-0.5604756\" \"-0.5604756\" #> cum_min_y \"-0.9516186\" \"-0.9516186\" #> cum_min_z \"-0.4143399\" \"-0.4762469\" #> cum_max_x \" 1.5587083\" \" 1.7150650\" #> cum_max_y \" 0.2568837\" \" 0.2568837\" #> cum_max_z \"2.19881\" \"2.19881\" #> cum_mean_x \" 0.1935703\" \" 0.4471527\" #> cum_mean_y \"-0.3998752\" \"-0.3407339\" #> cum_mean_z \"0.6749865\" \"0.4831142\""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cgmean.html","id":null,"dir":"Reference","previous_headings":"","what":"Cumulative Geometric Mean — cgmean","title":"Cumulative Geometric Mean — cgmean","text":"function return cumulative geometric mean vector.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cgmean.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cumulative Geometric Mean — cgmean","text":"","code":"cgmean(.x)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/cgmean.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cumulative Geometric Mean — cgmean","text":".x numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cgmean.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cumulative Geometric Mean — cgmean","text":"numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cgmean.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Cumulative Geometric Mean — cgmean","text":"function return cumulative geometric mean vector. exp(cummean(log(.x)))","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/cgmean.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Cumulative Geometric Mean — cgmean","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cgmean.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cumulative Geometric Mean — cgmean","text":"","code":"x <- mtcars$mpg cgmean(x) #> [1] 21.00000 21.00000 21.58363 21.53757 20.93755 20.43547 19.41935 19.98155 #> [9] 20.27666 20.16633 19.93880 19.61678 19.42805 19.09044 18.33287 17.69470 #> [17] 17.50275 18.11190 18.61236 19.17879 19.28342 19.09293 18.90457 18.62961 #> [25] 18.65210 18.92738 19.15126 19.46993 19.33021 19.34242 19.18443 19.25006"},{"path":"https://www.spsanderson.com/RandomWalker/reference/chmean.html","id":null,"dir":"Reference","previous_headings":"","what":"Cumulative Harmonic Mean — chmean","title":"Cumulative Harmonic Mean — chmean","text":"function return cumulative harmonic mean vector.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/chmean.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cumulative Harmonic Mean — chmean","text":"","code":"chmean(.x)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/chmean.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cumulative Harmonic Mean — chmean","text":".x numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/chmean.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cumulative Harmonic Mean — chmean","text":"numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/chmean.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Cumulative Harmonic Mean — chmean","text":"function return cumulative harmonic mean vector. 1 / (cumsum(1 / .x))","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/chmean.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Cumulative Harmonic Mean — chmean","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/chmean.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cumulative Harmonic Mean — chmean","text":"","code":"x <- mtcars$mpg chmean(x) #> [1] 21.0000000 10.5000000 7.1891892 5.3813575 4.1788087 3.3949947 #> [7] 2.7436247 2.4663044 2.2255626 1.9943841 1.7934398 1.6166494 #> [13] 1.4784877 1.3474251 1.1928760 1.0701322 0.9975150 0.9677213 #> [19] 0.9378663 0.9126181 0.8754572 0.8286539 0.7858140 0.7419753 #> [25] 0.7143688 0.6961523 0.6779989 0.6632076 0.6364908 0.6165699 #> [31] 0.5922267 0.5762786"},{"path":"https://www.spsanderson.com/RandomWalker/reference/ckurtosis.html","id":null,"dir":"Reference","previous_headings":"","what":"Cumulative Kurtosis — ckurtosis","title":"Cumulative Kurtosis — ckurtosis","text":"function return cumulative kurtosis vector.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/ckurtosis.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cumulative Kurtosis — ckurtosis","text":"","code":"ckurtosis(.x)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/ckurtosis.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cumulative Kurtosis — ckurtosis","text":".x numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/ckurtosis.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cumulative Kurtosis — ckurtosis","text":"numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/ckurtosis.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Cumulative Kurtosis — ckurtosis","text":"function return cumulative kurtosis vector.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/ckurtosis.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Cumulative Kurtosis — ckurtosis","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/ckurtosis.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cumulative Kurtosis — ckurtosis","text":"","code":"x <- mtcars$mpg ckurtosis(x) #> [1] NaN NaN 1.500000 2.189216 2.518932 1.786006 2.744467 2.724675 #> [9] 2.930885 2.988093 2.690270 2.269038 2.176622 1.992044 2.839430 2.481896 #> [17] 2.356826 3.877115 3.174702 2.896931 3.000743 3.091225 3.182071 3.212816 #> [25] 3.352916 3.015952 2.837139 2.535185 2.595908 2.691103 2.738468 2.799467"},{"path":"https://www.spsanderson.com/RandomWalker/reference/cmean.html","id":null,"dir":"Reference","previous_headings":"","what":"Cumulative Mean — cmean","title":"Cumulative Mean — cmean","text":"function return cumulative mean vector.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cmean.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cumulative Mean — cmean","text":"","code":"cmean(.x)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/cmean.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cumulative Mean — cmean","text":".x numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cmean.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cumulative Mean — cmean","text":"numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cmean.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Cumulative Mean — cmean","text":"function return cumulative mean vector. uses dplyr::cummean() basis function.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/cmean.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Cumulative Mean — cmean","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cmean.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cumulative Mean — cmean","text":"","code":"x <- mtcars$mpg cmean(x) #> [1] 21.00000 21.00000 21.60000 21.55000 20.98000 20.50000 19.61429 20.21250 #> [9] 20.50000 20.37000 20.13636 19.82500 19.63077 19.31429 18.72000 18.20000 #> [17] 17.99412 18.79444 19.40526 20.13000 20.19524 19.98182 19.77391 19.50417 #> [25] 19.49200 19.79231 20.02222 20.39286 20.23448 20.21667 20.04839 20.09062"},{"path":"https://www.spsanderson.com/RandomWalker/reference/cmedian.html","id":null,"dir":"Reference","previous_headings":"","what":"Cumulative Median — cmedian","title":"Cumulative Median — cmedian","text":"function return cumulative median vector.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cmedian.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cumulative Median — cmedian","text":"","code":"cmedian(.x)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/cmedian.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cumulative Median — cmedian","text":".x numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cmedian.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cumulative Median — cmedian","text":"numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cmedian.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Cumulative Median — cmedian","text":"function return cumulative median vector.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/cmedian.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Cumulative Median — cmedian","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cmedian.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cumulative Median — cmedian","text":"","code":"x <- mtcars$mpg cmedian(x) #> [1] 21.00 21.00 21.00 21.20 21.00 21.00 21.00 21.00 21.00 21.00 21.00 20.10 #> [13] 19.20 18.95 18.70 18.40 18.10 18.40 18.70 18.95 19.20 18.95 18.70 18.40 #> [25] 18.70 18.95 19.20 19.20 19.20 19.20 19.20 19.20"},{"path":"https://www.spsanderson.com/RandomWalker/reference/convert_snake_to_title_case.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to convert a snake_case string to Title Case — convert_snake_to_title_case","title":"Helper function to convert a snake_case string to Title Case — convert_snake_to_title_case","text":"Converts snake_case string Title Case.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/convert_snake_to_title_case.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to convert a snake_case string to Title Case — convert_snake_to_title_case","text":"","code":"convert_snake_to_title_case(string)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/convert_snake_to_title_case.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to convert a snake_case string to Title Case — convert_snake_to_title_case","text":"string character string snake_case format.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/convert_snake_to_title_case.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to convert a snake_case string to Title Case — convert_snake_to_title_case","text":"character string converted Title Case.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/convert_snake_to_title_case.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Helper function to convert a snake_case string to Title Case — convert_snake_to_title_case","text":"function useful formatting strings readable way, especially dealing variable names identifiers use snake_case. function takes snake_case string converts Title Case. replaces underscores spaces, capitalizes first letter word, replaces substring \"cum\" \"cumulative\" better readability.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/convert_snake_to_title_case.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Helper function to convert a snake_case string to Title Case — convert_snake_to_title_case","text":"Antti Lennart Rask","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/convert_snake_to_title_case.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to convert a snake_case string to Title Case — convert_snake_to_title_case","text":"","code":"convert_snake_to_title_case(\"hello_world\") # \"Hello World\" #> [1] \"Hello World\" convert_snake_to_title_case(\"this_is_a_test\") # \"This Is A Test\" #> [1] \"This Is A Test\" convert_snake_to_title_case(\"cumulative_sum\") # \"Cumulative Sum\" #> [1] \"Cumulative Sum\""},{"path":"https://www.spsanderson.com/RandomWalker/reference/crange.html","id":null,"dir":"Reference","previous_headings":"","what":"Cumulative Range — crange","title":"Cumulative Range — crange","text":"function return cumulative range vector.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/crange.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cumulative Range — crange","text":"","code":"crange(.x)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/crange.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cumulative Range — crange","text":".x numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/crange.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cumulative Range — crange","text":"numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/crange.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Cumulative Range — crange","text":"function return cumulative range vector. uses max(.x[1:k]) - min(.x[1:k]) basis function.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/crange.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Cumulative Range — crange","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/crange.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cumulative Range — crange","text":"","code":"x <- mtcars$mpg crange(x) #> [1] 0.0 0.0 1.8 1.8 4.1 4.7 8.5 10.1 10.1 10.1 10.1 10.1 10.1 10.1 14.0 #> [16] 14.0 14.0 22.0 22.0 23.5 23.5 23.5 23.5 23.5 23.5 23.5 23.5 23.5 23.5 23.5 #> [31] 23.5 23.5"},{"path":"https://www.spsanderson.com/RandomWalker/reference/csd.html","id":null,"dir":"Reference","previous_headings":"","what":"Cumulative Standard Deviation — csd","title":"Cumulative Standard Deviation — csd","text":"function return cumulative standard deviation vector.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/csd.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cumulative Standard Deviation — csd","text":"","code":"csd(.x)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/csd.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cumulative Standard Deviation — csd","text":".x numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/csd.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cumulative Standard Deviation — csd","text":"numeric vector. Note: first entry always NaN.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/csd.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Cumulative Standard Deviation — csd","text":"function return cumulative standard deviation vector.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/csd.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Cumulative Standard Deviation — csd","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/csd.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cumulative Standard Deviation — csd","text":"","code":"x <- mtcars$mpg csd(x) #> [1] NaN 0.0000000 1.0392305 0.8544004 1.4737707 1.7663522 2.8445436 #> [8] 3.1302385 3.0524580 2.9070986 2.8647069 2.9366416 2.8975233 3.0252418 #> [15] 3.7142967 4.1476098 4.1046423 5.2332053 5.7405452 6.4594362 6.3029736 #> [22] 6.2319940 6.1698105 6.1772007 6.0474457 6.1199296 6.1188444 6.3166405 #> [29] 6.2611772 6.1530527 6.1217574 6.0269481"},{"path":"https://www.spsanderson.com/RandomWalker/reference/cskewness.html","id":null,"dir":"Reference","previous_headings":"","what":"Cumulative Skewness — cskewness","title":"Cumulative Skewness — cskewness","text":"function return cumulative skewness vector.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cskewness.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cumulative Skewness — cskewness","text":"","code":"cskewness(.x)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/cskewness.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cumulative Skewness — cskewness","text":".x numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cskewness.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cumulative Skewness — cskewness","text":"numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cskewness.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Cumulative Skewness — cskewness","text":"function return cumulative skewness vector.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/cskewness.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Cumulative Skewness — cskewness","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cskewness.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cumulative Skewness — cskewness","text":"","code":"x <- mtcars$mpg cskewness(x) #> [1] NaN NaN 0.707106781 0.997869718 -0.502052297 #> [6] -0.258803244 -0.867969171 -0.628239920 -0.808101715 -0.695348960 #> [11] -0.469220594 -0.256323338 -0.091505282 0.002188142 -0.519593266 #> [16] -0.512660692 -0.379598706 0.614549281 0.581410573 0.649357202 #> [21] 0.631855977 0.706212631 0.775750182 0.821447605 0.844413861 #> [26] 0.716010069 0.614326432 0.525141032 0.582528820 0.601075783 #> [31] 0.652552397 0.640439864"},{"path":"https://www.spsanderson.com/RandomWalker/reference/cvar.html","id":null,"dir":"Reference","previous_headings":"","what":"Cumulative Variance — cvar","title":"Cumulative Variance — cvar","text":"function return cumulative variance vector.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cvar.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cumulative Variance — cvar","text":"","code":"cvar(.x)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/cvar.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cumulative Variance — cvar","text":".x numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cvar.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cumulative Variance — cvar","text":"numeric vector. Note: first entry always NaN.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cvar.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Cumulative Variance — cvar","text":"function return cumulative variance vector. exp(cummean(log(.x)))","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/cvar.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Cumulative Variance — cvar","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/cvar.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cumulative Variance — cvar","text":"","code":"x <- mtcars$mpg cvar(x) #> [1] NaN 0.000000 1.080000 0.730000 2.172000 3.120000 8.091429 #> [8] 9.798393 9.317500 8.451222 8.206545 8.623864 8.395641 9.152088 #> [15] 13.796000 17.202667 16.848088 27.386438 32.953860 41.724316 39.727476 #> [22] 38.837749 38.066561 38.157808 36.571600 37.453538 37.440256 39.899947 #> [29] 39.202340 37.860057 37.475914 36.324103"},{"path":"https://www.spsanderson.com/RandomWalker/reference/discrete_walk.html","id":null,"dir":"Reference","previous_headings":"","what":"Discrete Sampled Walk — discrete_walk","title":"Discrete Sampled Walk — discrete_walk","text":"discrete_walk function generates multiple random walks discrete time periods. step walk determined probabilistic sample specified upper lower bounds. function useful simulating stochastic processes, stock price movements scenarios outcomes determined random process.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/discrete_walk.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Discrete Sampled Walk — discrete_walk","text":"","code":"discrete_walk( .num_walks = 25, .n = 100, .upper_bound = 1, .lower_bound = -1, .upper_probability = 0.5, .initial_value = 100, .dimensions = 1 )"},{"path":"https://www.spsanderson.com/RandomWalker/reference/discrete_walk.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Discrete Sampled Walk — discrete_walk","text":".num_walks Total number simulations. .n Total time simulation. .upper_bound upper bound random walk. .lower_bound lower bound random walk. .upper_probability probability upper bound. Default 0.5. lower bound calculated 1 - .upper_probability. .initial_value initial value random walk. Default 100. .dimensions default 1. Allowable values 1, 2 3.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/discrete_walk.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Discrete Sampled Walk — discrete_walk","text":"tibble containing generated random walks columns depending number dimensions: walk_number: Factor representing walk number. step_number: Step index. y: .dimensions = 1, value walk step. x, y: .dimensions = 2, values walk two dimensions. x, y, z: .dimensions = 3, values walk three dimensions. following also returned based upon many dimensions x, y z: cum_sum: Cumulative sum dplyr::all_of(.dimensions). cum_prod: Cumulative product dplyr::all_of(.dimensions). cum_min: Cumulative minimum dplyr::all_of(.dimensions). cum_max: Cumulative maximum dplyr::all_of(.dimensions). cum_mean: Cumulative mean dplyr::all_of(.dimensions).","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/discrete_walk.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Discrete Sampled Walk — discrete_walk","text":"function discrete_walk simulates random walks specified number simulations (.num_walks) given total time (.n). step walk either upper bound lower bound, determined probability (.upper_probability). initial value walk set user (.initial_value), cumulative sum, product, minimum, maximum steps calculated walk. results returned tibble detailed attributes, including parameters used simulation.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/discrete_walk.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Discrete Sampled Walk — discrete_walk","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/discrete_walk.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Discrete Sampled Walk — discrete_walk","text":"","code":"set.seed(123) discrete_walk() #> # A tibble: 2,500 × 8 #> walk_number step_number y cum_sum_y cum_prod_y cum_min_y cum_max_y #> #> 1 1 1 -1 99 0 99 99 #> 2 1 2 1 100 0 99 101 #> 3 1 3 -1 99 0 99 101 #> 4 1 4 1 100 0 99 101 #> 5 1 5 1 101 0 99 101 #> 6 1 6 -1 100 0 99 101 #> 7 1 7 1 101 0 99 101 #> 8 1 8 1 102 0 99 101 #> 9 1 9 1 103 0 99 101 #> 10 1 10 -1 102 0 99 101 #> # ℹ 2,490 more rows #> # ℹ 1 more variable: cum_mean_y set.seed(123) discrete_walk(.dimensions = 3) |> head() |> t() #> [,1] [,2] [,3] [,4] [,5] #> walk_number \"1\" \"1\" \"1\" \"1\" \"1\" #> step_number \"1\" \"2\" \"3\" \"4\" \"5\" #> x \"-1\" \" 1\" \"-1\" \" 1\" \" 1\" #> y \" 1\" \"-1\" \"-1\" \" 1\" \"-1\" #> z \"-1\" \" 1\" \" 1\" \" 1\" \"-1\" #> cum_sum_x \" 99\" \"100\" \" 99\" \"100\" \"101\" #> cum_sum_y \"101\" \"100\" \" 99\" \"100\" \" 99\" #> cum_sum_z \" 99\" \"100\" \"101\" \"102\" \"101\" #> cum_prod_x \"0\" \"0\" \"0\" \"0\" \"0\" #> cum_prod_y \"200\" \" 0\" \" 0\" \" 0\" \" 0\" #> cum_prod_z \"0\" \"0\" \"0\" \"0\" \"0\" #> cum_min_x \"99\" \"99\" \"99\" \"99\" \"99\" #> cum_min_y \"101\" \" 99\" \" 99\" \" 99\" \" 99\" #> cum_min_z \"99\" \"99\" \"99\" \"99\" \"99\" #> cum_max_x \" 99\" \"101\" \"101\" \"101\" \"101\" #> cum_max_y \"101\" \"101\" \"101\" \"101\" \"101\" #> cum_max_z \" 99\" \"101\" \"101\" \"101\" \"101\" #> cum_mean_x \" 99.00000\" \"100.00000\" \" 99.66667\" \"100.00000\" \"100.20000\" #> cum_mean_y \"101.00000\" \"100.00000\" \" 99.66667\" \"100.00000\" \" 99.80000\" #> cum_mean_z \" 99.0000\" \"100.0000\" \"100.3333\" \"100.5000\" \"100.2000\" #> [,6] #> walk_number \"1\" #> step_number \"6\" #> x \"-1\" #> y \" 1\" #> z \" 1\" #> cum_sum_x \"100\" #> cum_sum_y \"100\" #> cum_sum_z \"102\" #> cum_prod_x \"0\" #> cum_prod_y \" 0\" #> cum_prod_z \"0\" #> cum_min_x \"99\" #> cum_min_y \" 99\" #> cum_min_z \"99\" #> cum_max_x \"101\" #> cum_max_y \"101\" #> cum_max_z \"101\" #> cum_mean_x \"100.00000\" #> cum_mean_y \"100.00000\" #> cum_mean_z \"100.3333\""},{"path":"https://www.spsanderson.com/RandomWalker/reference/euclidean_distance.html","id":null,"dir":"Reference","previous_headings":"","what":"Distance Calculations — euclidean_distance","title":"Distance Calculations — euclidean_distance","text":"function calculate Euclidean distance two vectors.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/euclidean_distance.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Distance Calculations — euclidean_distance","text":"","code":"euclidean_distance(.data, .x, .y, .pull_vector = FALSE)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/euclidean_distance.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Distance Calculations — euclidean_distance","text":".data data frame .x numeric vector .y numeric vector .pull_vector boolean TRUE FALSE. Default FALSE augment distance data frame. TRUE return vector distances return.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/euclidean_distance.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Distance Calculations — euclidean_distance","text":"numeric Vector ditances","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/euclidean_distance.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Distance Calculations — euclidean_distance","text":"function calculate Euclidean distance two vectors. uses formula sqrt((x - lag(x))^2 + (y - lag(y))^2). function uses augments data frame new column called distance.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/euclidean_distance.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Distance Calculations — euclidean_distance","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/euclidean_distance.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Distance Calculations — euclidean_distance","text":"","code":"set.seed(123) df <- rw30() euclidean_distance(df, step_number, y) #> # A tibble: 3,000 × 4 #> walk_number step_number y distance #> #> 1 1 1 0 NA #> 2 1 2 -0.560 1.15 #> 3 1 3 -0.791 1.03 #> 4 1 4 0.768 1.85 #> 5 1 5 0.839 1.00 #> 6 1 6 0.968 1.01 #> 7 1 7 2.68 1.99 #> 8 1 8 3.14 1.10 #> 9 1 9 1.88 1.61 #> 10 1 10 1.19 1.21 #> # ℹ 2,990 more rows euclidean_distance(df, step_number, y, TRUE) |> head(10) #> [1] NA 1.146356 1.026149 1.851910 1.002483 1.008323 1.985308 1.101110 #> [9] 1.612569 1.213164"},{"path":"https://www.spsanderson.com/RandomWalker/reference/generate_caption.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to generate a caption string based on provided attributes — generate_caption","title":"Helper function to generate a caption string based on provided attributes — generate_caption","text":"Generates caption string based provided attributes.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/generate_caption.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to generate a caption string based on provided attributes — generate_caption","text":"","code":"generate_caption(attributes)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/generate_caption.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to generate a caption string based on provided attributes — generate_caption","text":"attributes list containing various attributes may include dimension, num_steps, mu, sd.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/generate_caption.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to generate a caption string based on provided attributes — generate_caption","text":"character string representing generated caption. attributes provided, returns empty string.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/generate_caption.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Helper function to generate a caption string based on provided attributes — generate_caption","text":"function useful creating descriptive captions plots outputs based attributes provided. ensures non-null attributes included caption. function constructs caption string checking various attributes provided list. formats caption based presence specific attributes, dimensions, number steps, statistical parameters like mu standard deviation (sd).","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/generate_caption.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Helper function to generate a caption string based on provided attributes — generate_caption","text":"Antti Lennart Rask","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/generate_caption.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to generate a caption string based on provided attributes — generate_caption","text":"","code":"attrs <- list(dimension = 3, num_steps = 100, mu = 0.5, sd = 1.2) generate_caption(attrs) # \"3 dimensions, 100 steps, mu = 0.5, sd = 1.2.\" #> [1] \"3 dimensions, 100 steps, mu = 0.5, sd = 1.2.\" attrs <- list(dimension = NULL, num_steps = 50, mu = NULL, sd = 2.0) generate_caption(attrs) # \"50 steps, sd = 2.0.\" #> [1] \"50 steps, sd = 2.\""},{"path":"https://www.spsanderson.com/RandomWalker/reference/geometric_brownian_motion.html","id":null,"dir":"Reference","previous_headings":"","what":"Geometric Brownian Motion — geometric_brownian_motion","title":"Geometric Brownian Motion — geometric_brownian_motion","text":"Create Geometric Brownian Motion.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/geometric_brownian_motion.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Geometric Brownian Motion — geometric_brownian_motion","text":"","code":"geometric_brownian_motion( .num_walks = 25, .n = 100, .mu = 0, .sigma = 0.1, .initial_value = 100, .delta_time = 0.003, .dimensions = 1 )"},{"path":"https://www.spsanderson.com/RandomWalker/reference/geometric_brownian_motion.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Geometric Brownian Motion — geometric_brownian_motion","text":".num_walks Total number simulations. .n Total time simulation, many n points time. .mu Expected return .sigma Volatility .initial_value Integer representing initial value. .delta_time Time step size. .dimensions default 1. Allowable values 1, 2 3.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/geometric_brownian_motion.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Geometric Brownian Motion — geometric_brownian_motion","text":"tibble containing generated random walks columns depending number dimensions: walk_number: Factor representing walk number. step_number: Step index. y: .dimensions = 1, value walk step. x, y: .dimensions = 2, values walk two dimensions. x, y, z: .dimensions = 3, values walk three dimensions. following also returned based upon many dimensions x, y z: cum_sum: Cumulative sum dplyr::all_of(.dimensions). cum_prod: Cumulative product dplyr::all_of(.dimensions). cum_min: Cumulative minimum dplyr::all_of(.dimensions). cum_max: Cumulative maximum dplyr::all_of(.dimensions). cum_mean: Cumulative mean dplyr::all_of(.dimensions).","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/geometric_brownian_motion.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Geometric Brownian Motion — geometric_brownian_motion","text":"Geometric Brownian Motion (GBM) statistical method modeling evolution given financial asset time. type stochastic process, means system undergoes random changes time. GBM widely used field finance model behavior stock prices, foreign exchange rates, financial assets. based assumption asset's price follows random walk, meaning influenced number unpredictable factors market trends, news events, investor sentiment. equation GBM : S price asset, t time, m expected return asset, s volatility asset, dW small random change asset's price. GBM can used estimate likelihood different outcomes given asset, often used conjunction statistical methods make accurate predictions future performance asset. function provides ability simulating estimating parameters GBM process. can used analyze behavior financial assets make informed investment decisions.","code":"dS/S = mdt + sdW"},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/geometric_brownian_motion.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Geometric Brownian Motion — geometric_brownian_motion","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/geometric_brownian_motion.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Geometric Brownian Motion — geometric_brownian_motion","text":"","code":"set.seed(123) geometric_brownian_motion() #> # A tibble: 2,500 × 6 #> walk_number step_number y cum_min_y cum_max_y cum_mean_y #> #> 1 1 1 0.997 101. 101. 101. #> 2 1 2 0.996 101. 101. 101. #> 3 1 3 1.00 101. 101. 101. #> 4 1 4 1.00 101. 101. 101. #> 5 1 5 1.01 101. 101. 101. #> 6 1 6 1.01 101. 101. 101. #> 7 1 7 1.02 101. 101. 101. #> 8 1 8 1.01 101. 101. 101. #> 9 1 9 1.01 101. 101. 101. #> 10 1 10 1.00 101. 101. 101. #> # ℹ 2,490 more rows set.seed(123) geometric_brownian_motion(.dimensions = 3) |> head() |> t() #> [,1] [,2] [,3] [,4] [,5] #> walk_number \"1\" \"1\" \"1\" \"1\" \"1\" #> step_number \"1\" \"2\" \"3\" \"4\" \"5\" #> x \"0.9969199\" \"0.9956489\" \"1.0041705\" \"1.0045433\" \"1.0052398\" #> y \"0.9961016\" \"0.9974891\" \"0.9961273\" \"0.9942180\" \"0.9890345\" #> z \"1.012101\" \"1.019387\" \"1.017893\" \"1.020910\" \"1.018581\" #> cum_min_x \"100.9969\" \"100.9956\" \"100.9956\" \"100.9956\" \"100.9956\" #> cum_min_y \"100.9961\" \"100.9961\" \"100.9961\" \"100.9942\" \"100.9890\" #> cum_min_z \"101.0121\" \"101.0121\" \"101.0121\" \"101.0121\" \"101.0121\" #> cum_max_x \"100.9969\" \"100.9969\" \"101.0042\" \"101.0045\" \"101.0052\" #> cum_max_y \"100.9961\" \"100.9975\" \"100.9975\" \"100.9975\" \"100.9975\" #> cum_max_z \"101.0121\" \"101.0194\" \"101.0194\" \"101.0209\" \"101.0209\" #> cum_mean_x \"100.9969\" \"100.9963\" \"100.9989\" \"101.0003\" \"101.0013\" #> cum_mean_y \"100.9961\" \"100.9968\" \"100.9966\" \"100.9960\" \"100.9946\" #> cum_mean_z \"101.0121\" \"101.0157\" \"101.0165\" \"101.0176\" \"101.0178\" #> [,6] #> walk_number \"1\" #> step_number \"6\" #> x \"1.0147121\" #> y \"0.9887758\" #> z \"1.015912\" #> cum_min_x \"100.9956\" #> cum_min_y \"100.9888\" #> cum_min_z \"101.0121\" #> cum_max_x \"101.0147\" #> cum_max_y \"100.9975\" #> cum_max_z \"101.0209\" #> cum_mean_x \"101.0035\" #> cum_mean_y \"100.9936\" #> cum_mean_z \"101.0175\""},{"path":"https://www.spsanderson.com/RandomWalker/reference/get_attributes.html","id":null,"dir":"Reference","previous_headings":"","what":"Get Attributes — get_attributes","title":"Get Attributes — get_attributes","text":"get_attributes function takes R object input returns attributes, omitting row.names attribute.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/get_attributes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get Attributes — get_attributes","text":"","code":"get_attributes(.data)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/get_attributes.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get Attributes — get_attributes","text":".data R object attributes extracted.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/get_attributes.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get Attributes — get_attributes","text":"list attributes input R object, excluding row.names.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/get_attributes.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Get Attributes — get_attributes","text":"function retrieves attributes given R object, excluding row.names attribute.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/get_attributes.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Get Attributes — get_attributes","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/get_attributes.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get Attributes — get_attributes","text":"","code":"get_attributes(rw30()) #> $names #> [1] \"walk_number\" \"step_number\" \"y\" #> #> $class #> [1] \"tbl_df\" \"tbl\" \"data.frame\" #> #> $num_walks #> [1] 30 #> #> $num_steps #> [1] 100 #> #> $mu #> [1] 0 #> #> $sd #> [1] 1 #> #> $fns #> [1] \"rw30\" #> #> $dimension #> [1] 1 #> get_attributes(iris) #> $names #> [1] \"Sepal.Length\" \"Sepal.Width\" \"Petal.Length\" \"Petal.Width\" \"Species\" #> #> $class #> [1] \"data.frame\" #> get_attributes(mtcars) #> $names #> [1] \"mpg\" \"cyl\" \"disp\" \"hp\" \"drat\" \"wt\" \"qsec\" \"vs\" \"am\" \"gear\" #> [11] \"carb\" #> #> $class #> [1] \"data.frame\" #>"},{"path":"https://www.spsanderson.com/RandomWalker/reference/kurtosis_vec.html","id":null,"dir":"Reference","previous_headings":"","what":"Compute Kurtosis of a Vector — kurtosis_vec","title":"Compute Kurtosis of a Vector — kurtosis_vec","text":"function takes vector input return kurtosis vector. length vector must least four numbers. kurtosis explains sharpness peak distribution data. ((1/n) * sum(x - mu})^4) / ((()1/n) * sum(x - mu)^2)^2","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/kurtosis_vec.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Compute Kurtosis of a Vector — kurtosis_vec","text":"","code":"kurtosis_vec(.x)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/kurtosis_vec.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Compute Kurtosis of a Vector — kurtosis_vec","text":".x numeric vector length four .","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/kurtosis_vec.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Compute Kurtosis of a Vector — kurtosis_vec","text":"kurtosis vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/kurtosis_vec.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Compute Kurtosis of a Vector — kurtosis_vec","text":"function return kurtosis vector.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/kurtosis_vec.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Compute Kurtosis of a Vector — kurtosis_vec","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/kurtosis_vec.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Compute Kurtosis of a Vector — kurtosis_vec","text":"","code":"set.seed(123) kurtosis_vec(rnorm(100, 3, 2)) #> [1] 2.838947"},{"path":"https://www.spsanderson.com/RandomWalker/reference/name.html","id":null,"dir":"Reference","previous_headings":"","what":"Cumulative Range — name","title":"Cumulative Range — name","text":"function return cumulative range vector.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/name.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cumulative Range — name","text":".x numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/name.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cumulative Range — name","text":"numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/name.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Cumulative Range — name","text":"function return cumulative range vector. uses max(.x[1:k]) - min(.x[1:k]) basis function.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/name.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Cumulative Range — name","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/name.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cumulative Range — name","text":"","code":"x <- mtcars$mpg crange(x) #> [1] 0.0 0.0 1.8 1.8 4.1 4.7 8.5 10.1 10.1 10.1 10.1 10.1 10.1 10.1 14.0 #> [16] 14.0 14.0 22.0 22.0 23.5 23.5 23.5 23.5 23.5 23.5 23.5 23.5 23.5 23.5 23.5 #> [31] 23.5 23.5"},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_drift_walk.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate Multiple Random Walks with Drift — random_normal_drift_walk","title":"Generate Multiple Random Walks with Drift — random_normal_drift_walk","text":"function generates specified number random walks, consisting specified number steps. steps generated normal distribution given mean standard deviation. additional drift term added step introduce consistent directional component walks.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_drift_walk.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate Multiple Random Walks with Drift — random_normal_drift_walk","text":"","code":"random_normal_drift_walk( .num_walks = 25, .n = 100, .mu = 0, .sd = 1, .drift = 0.1, .initial_value = 0, .dimensions = 1 )"},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_drift_walk.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generate Multiple Random Walks with Drift — random_normal_drift_walk","text":".num_walks Integer. number random walks generate. Default 25. .n Integer. number steps random walk. Default 100. .mu Numeric. mean normal distribution used generating steps. Default 0. .sd Numeric. standard deviation normal distribution used generating steps. Default 1. .drift Numeric. drift term added step. Default 0.1. .initial_value numeric value indicating initial value walks. Default 0. .dimensions default 1. Allowable values 1, 2 3.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_drift_walk.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate Multiple Random Walks with Drift — random_normal_drift_walk","text":"tibble containing generated random walks columns depending number dimensions: walk_number: Factor representing walk number. step_number: Step index. y: .dimensions = 1, value walk step. x, y: .dimensions = 2, values walk two dimensions. x, y, z: .dimensions = 3, values walk three dimensions. following also returned based upon many dimensions x, y z: cum_sum: Cumulative sum dplyr::all_of(.dimensions). cum_prod: Cumulative product dplyr::all_of(.dimensions). cum_min: Cumulative minimum dplyr::all_of(.dimensions). cum_max: Cumulative maximum dplyr::all_of(.dimensions). cum_mean: Cumulative mean dplyr::all_of(.dimensions).","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_drift_walk.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Generate Multiple Random Walks with Drift — random_normal_drift_walk","text":"function generates multiple random walks specified drift. walk generated using normal distribution steps, additional drift term added step.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_drift_walk.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Generate Multiple Random Walks with Drift — random_normal_drift_walk","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_drift_walk.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Generate Multiple Random Walks with Drift — random_normal_drift_walk","text":"","code":"set.seed(123) random_normal_drift_walk() #> # A tibble: 2,500 × 8 #> walk_number step_number y cum_sum_y cum_prod_y cum_min_y cum_max_y #> #> 1 1 1 -1.02 -1.02 0 -1.02 -1.02 #> 2 1 2 -0.821 -1.84 0 -1.02 -0.821 #> 3 1 3 2.63 0.785 0 -1.02 2.63 #> 4 1 4 1.31 2.09 0 -1.02 2.63 #> 5 1 5 1.60 3.69 0 -1.02 2.63 #> 6 1 6 5.00 8.69 0 -1.02 5.00 #> 7 1 7 4.30 13.0 0 -1.02 5.00 #> 8 1 8 1.41 14.4 0 -1.02 5.00 #> 9 1 9 1.41 15.8 0 -1.02 5.00 #> 10 1 10 1.30 17.1 0 -1.02 5.00 #> # ℹ 2,490 more rows #> # ℹ 1 more variable: cum_mean_y set.seed(123) random_normal_drift_walk(.dimensions = 3) |> head() |> t() #> [,1] [,2] [,3] [,4] #> walk_number \"1\" \"1\" \"1\" \"1\" #> step_number \"1\" \"2\" \"3\" \"4\" #> x \"-1.0209513\" \"-0.8208306\" \" 2.6267635\" \" 1.3090720\" #> y \"-1.320813127\" \" 0.003360855\" \"-0.646906611\" \"-0.995299932\" #> z \"4.497621\" \"5.023636\" \"3.280933\" \"4.732466\" #> cum_sum_x \"-1.0209513\" \"-1.8417819\" \" 0.7849816\" \" 2.0940535\" #> cum_sum_y \"-1.320813\" \"-1.317452\" \"-1.964359\" \"-2.959659\" #> cum_sum_z \" 4.497621\" \" 9.521257\" \"12.802190\" \"17.534657\" #> cum_prod_x \"0\" \"0\" \"0\" \"0\" #> cum_prod_y \"0\" \"0\" \"0\" \"0\" #> cum_prod_z \"0\" \"0\" \"0\" \"0\" #> cum_min_x \"-1.020951\" \"-1.020951\" \"-1.020951\" \"-1.020951\" #> cum_min_y \"-1.320813\" \"-1.320813\" \"-1.320813\" \"-1.320813\" #> cum_min_z \"4.497621\" \"4.497621\" \"3.280933\" \"3.280933\" #> cum_max_x \"-1.0209513\" \"-0.8208306\" \" 2.6267635\" \" 2.6267635\" #> cum_max_y \"-1.320813127\" \" 0.003360855\" \" 0.003360855\" \" 0.003360855\" #> cum_max_z \"4.497621\" \"5.023636\" \"5.023636\" \"5.023636\" #> cum_mean_x \"-1.0209513\" \"-0.9208910\" \" 0.2616605\" \" 0.5235134\" #> cum_mean_y \"-1.3208131\" \"-0.6587261\" \"-0.6547863\" \"-0.7399147\" #> cum_mean_z \"4.497621\" \"4.760628\" \"4.267397\" \"4.383664\" #> [,5] [,6] #> walk_number \"1\" \"1\" #> step_number \"5\" \"6\" #> x \" 1.5971390\" \" 4.9979813\" #> y \"-2.450994467\" \"-1.489431349\" #> z \"3.460592\" \"3.022439\" #> cum_sum_x \" 3.6911926\" \" 8.6891739\" #> cum_sum_y \"-5.410653\" \"-6.900085\" #> cum_sum_z \"20.995249\" \"24.017688\" #> cum_prod_x \"0\" \"0\" #> cum_prod_y \"0\" \"0\" #> cum_prod_z \"0\" \"0\" #> cum_min_x \"-1.020951\" \"-1.020951\" #> cum_min_y \"-2.450994\" \"-2.450994\" #> cum_min_z \"3.280933\" \"3.022439\" #> cum_max_x \" 2.6267635\" \" 4.9979813\" #> cum_max_y \" 0.003360855\" \" 0.003360855\" #> cum_max_z \"5.023636\" \"5.023636\" #> cum_mean_x \" 0.7382385\" \" 1.4481956\" #> cum_mean_y \"-1.0821307\" \"-1.1500141\" #> cum_mean_z \"4.199050\" \"4.002948\""},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_walk.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate Multiple Random Normal Walks in Multiple Dimensions — random_normal_walk","title":"Generate Multiple Random Normal Walks in Multiple Dimensions — random_normal_walk","text":"random_normal_walk function generates multiple random walks 1, 2, 3 dimensions. walk sequence steps step random draw normal distribution. user can specify number walks, number steps walk, parameters normal distribution (mean standard deviation). function also allows sampling proportion steps optionally sampling replacement.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_walk.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate Multiple Random Normal Walks in Multiple Dimensions — random_normal_walk","text":"","code":"random_normal_walk( .num_walks = 25, .n = 100, .mu = 0, .sd = 0.1, .initial_value = 0, .samp = TRUE, .replace = TRUE, .sample_size = 0.8, .dimensions = 1 )"},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_walk.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generate Multiple Random Normal Walks in Multiple Dimensions — random_normal_walk","text":".num_walks integer specifying number random walks generate. Default 25. .n integer specifying number steps walk. Default 100. .mu numeric value indicating mean normal distribution. Default 0. .sd numeric value indicating standard deviation normal distribution. Default 0.1. .initial_value numeric value indicating initial value walks. Default 0. .samp logical value indicating whether sample normal distribution values. Default TRUE. .replace logical value indicating whether sampling replacement. Default TRUE. .sample_size numeric value 0 1 specifying proportion .n sample. Default 0.8. .dimensions integer specifying number dimensions (1, 2, 3). Default 1.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_walk.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate Multiple Random Normal Walks in Multiple Dimensions — random_normal_walk","text":"tibble containing generated random walks columns depending number dimensions: walk_number: Factor representing walk number. step_number: Step index. y: .dimensions = 1, value walk step. x, y: .dimensions = 2, values walk two dimensions. x, y, z: .dimensions = 3, values walk three dimensions. following also returned based upon many dimensions x, y z: walk_number: Factor representing walk number. x: Step index. y: Normal distribution values. cum_sum: Cumulative sum y. cum_prod: Cumulative product y. cum_min: Cumulative minimum y. cum_max: Cumulative maximum y. tibble includes attributes function parameters.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_walk.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Generate Multiple Random Normal Walks in Multiple Dimensions — random_normal_walk","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_walk.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Generate Multiple Random Normal Walks in Multiple Dimensions — random_normal_walk","text":"","code":"set.seed(123) random_normal_walk() #> # A tibble: 2,000 × 8 #> walk_number step_number y cum_sum_y cum_prod_y cum_min_y cum_max_y #> #> 1 1 1 0.125 0.125 0 0.125 0.125 #> 2 1 2 -0.0628 0.0626 0 -0.0628 0.125 #> 3 1 3 -0.0326 0.0300 0 -0.0628 0.125 #> 4 1 4 0.179 0.209 0 -0.0628 0.179 #> 5 1 5 0.0435 0.252 0 -0.0628 0.179 #> 6 1 6 0.137 0.389 0 -0.0628 0.179 #> 7 1 7 -0.0688 0.320 0 -0.0688 0.179 #> 8 1 8 -0.0467 0.274 0 -0.0688 0.179 #> 9 1 9 -0.0473 0.226 0 -0.0688 0.179 #> 10 1 10 0.0448 0.271 0 -0.0688 0.179 #> # ℹ 1,990 more rows #> # ℹ 1 more variable: cum_mean_y set.seed(123) random_normal_walk(.dimensions = 3) |> head() |> t() #> [,1] [,2] [,3] [,4] #> walk_number \"1\" \"1\" \"1\" \"1\" #> step_number \"1\" \"2\" \"3\" \"4\" #> x \" 0.12538149\" \"-0.06279061\" \"-0.03259316\" \" 0.17869131\" #> y \" 0.06365697\" \"-0.02153805\" \" 0.01192452\" \"-0.01194526\" #> z \"-0.12586486\" \" 0.13785701\" \"-0.19927485\" \" 0.09590054\" #> cum_sum_x \"0.12538149\" \"0.06259088\" \"0.02999773\" \"0.20868904\" #> cum_sum_y \" 0.06365697\" \" 0.04211892\" \" 0.05404344\" \" 0.04209818\" #> cum_sum_z \"-0.12586486\" \" 0.01199215\" \"-0.18728270\" \"-0.09138216\" #> cum_prod_x \"0\" \"0\" \"0\" \"0\" #> cum_prod_y \"0\" \"0\" \"0\" \"0\" #> cum_prod_z \"0\" \"0\" \"0\" \"0\" #> cum_min_x \" 0.12538149\" \"-0.06279061\" \"-0.06279061\" \"-0.06279061\" #> cum_min_y \" 0.06365697\" \"-0.02153805\" \"-0.02153805\" \"-0.02153805\" #> cum_min_z \"-0.1258649\" \"-0.1258649\" \"-0.1992748\" \"-0.1992748\" #> cum_max_x \"0.1253815\" \"0.1253815\" \"0.1253815\" \"0.1786913\" #> cum_max_y \"0.06365697\" \"0.06365697\" \"0.06365697\" \"0.06365697\" #> cum_max_z \"-0.1258649\" \" 0.1378570\" \" 0.1378570\" \" 0.1378570\" #> cum_mean_x \"0.125381492\" \"0.031295442\" \"0.009999242\" \"0.052172260\" #> cum_mean_y \" 0.063656967\" \" 0.021059458\" \" 0.018014480\" \" 0.010524545\" #> cum_mean_z \"-0.125864863\" \" 0.005996075\" \"-0.062427566\" \"-0.022845540\" #> [,5] [,6] #> walk_number \"1\" \"1\" #> step_number \"5\" \"6\" #> x \" 0.04351815\" \" 0.13686023\" #> y \"-0.06647694\" \"-0.02362796\" #> z \" 0.03461036\" \"-0.02007810\" #> cum_sum_x \"0.25220719\" \"0.38906742\" #> cum_sum_y \"-0.02437876\" \"-0.04800672\" #> cum_sum_z \"-0.05677180\" \"-0.07684990\" #> cum_prod_x \"0\" \"0\" #> cum_prod_y \"0\" \"0\" #> cum_prod_z \"0\" \"0\" #> cum_min_x \"-0.06279061\" \"-0.06279061\" #> cum_min_y \"-0.06647694\" \"-0.06647694\" #> cum_min_z \"-0.1992748\" \"-0.1992748\" #> cum_max_x \"0.1786913\" \"0.1786913\" #> cum_max_y \"0.06365697\" \"0.06365697\" #> cum_max_z \" 0.1378570\" \" 0.1378570\" #> cum_mean_x \"0.050441438\" \"0.064844570\" #> cum_mean_y \"-0.004875753\" \"-0.008001120\" #> cum_mean_z \"-0.011354360\" \"-0.012808317\""},{"path":"https://www.spsanderson.com/RandomWalker/reference/rand_walk_column_names.html","id":null,"dir":"Reference","previous_headings":"","what":"Get Column Names — rand_walk_column_names","title":"Get Column Names — rand_walk_column_names","text":"function generates column names rand walk data frame.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/rand_walk_column_names.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get Column Names — rand_walk_column_names","text":"","code":"rand_walk_column_names(.rand_data, .dim_names, .num_sims, .t)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/rand_walk_column_names.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get Column Names — rand_walk_column_names","text":".rand_data data frame column names extracted. .dim_names dimnames passed rand walk function.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/rand_walk_column_names.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Get Column Names — rand_walk_column_names","text":"rand_walk_column_names function takes data frame input returns rand walk data column names.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/rand_walk_column_names.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Get Column Names — rand_walk_column_names","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/rand_walk_helper.html","id":null,"dir":"Reference","previous_headings":"","what":"Random Walk Helper — rand_walk_helper","title":"Random Walk Helper — rand_walk_helper","text":"function help build random walks mutating data frame.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/rand_walk_helper.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Random Walk Helper — rand_walk_helper","text":"","code":"rand_walk_helper(.data, .value)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/rand_walk_helper.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Random Walk Helper — rand_walk_helper","text":".data data frame mutate. .value .initial_value use. passed random walk function called end user.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/rand_walk_helper.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Random Walk Helper — rand_walk_helper","text":"modified data frame/tibble following columns added: cum_sum: Cumulative sum y. cum_prod: Cumulative product y. cum_min: Cumulative minimum y. cum_max: Cumulative maximum y. cum_mean: Cumulative mean y.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/rand_walk_helper.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Random Walk Helper — rand_walk_helper","text":"function help build random walks mutating data frame. mutation adds following columns data frame: cum_sum, cum_prod, cum_min, cum_max, cum_mean. function used internally certain functions generate random walks.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/rand_walk_helper.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Random Walk Helper — rand_walk_helper","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/rand_walk_helper.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Random Walk Helper — rand_walk_helper","text":"","code":"df <- data.frame( walk_number = factor(rep(1L:25L, each = 30L)), x = rep(1L:30L, 25L), y = rnorm(750L, 0L, 1L) ) rand_walk_helper(df, 100) #> # A tibble: 750 × 8 #> walk_number x y cum_sum cum_prod cum_min cum_max cum_mean #> #> 1 1 1 0.406 100. 141. 100. 100. 100. #> 2 1 2 0.947 101. 274. 100. 101. 101. #> 3 1 3 2.06 103. 838. 100. 102. 101. #> 4 1 4 1.35 105. 1972. 100. 102. 101. #> 5 1 5 0.812 106. 3573. 100. 102. 101. #> 6 1 6 0.0815 106. 3865. 100. 102. 101. #> 7 1 7 -1.13 105. -501. 98.9 102. 101. #> 8 1 8 -0.504 104. -248. 98.9 102. 101. #> 9 1 9 2.64 107. -904. 98.9 103. 101. #> 10 1 10 0.595 107. -1442. 98.9 103. 101. #> # ℹ 740 more rows"},{"path":"https://www.spsanderson.com/RandomWalker/reference/running_quantile.html","id":null,"dir":"Reference","previous_headings":"","what":"Running Quantile Calculation — running_quantile","title":"Running Quantile Calculation — running_quantile","text":"running_quantile function calculates quantile vector sliding window, allowing various alignment rule options.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/running_quantile.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Running Quantile Calculation — running_quantile","text":"","code":"running_quantile( .x, .window, .probs = 0.5, .type = 7, .rule = \"quantile\", .align = \"center\" )"},{"path":"https://www.spsanderson.com/RandomWalker/reference/running_quantile.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Running Quantile Calculation — running_quantile","text":".x numeric vector running quantile calculated. .window integer specifying size sliding window. .probs numeric value 0 1 indicating desired quantile probability (default 0.50). .type integer 1 9 specifying quantile algorithm type (default 7). .rule character string indicating rule apply edges window. Possible choices : \"quantile\": Standard quantile calculation. \"trim\": Trims output remove values outside window. \"keep\": Keeps original values edges window. \"constant\": Fills edges constant value nearest valid quantile. \"NA\": Fills edges NA values. \"func\": Applies custom function values window (default \"quantile\"). .align character string specifying alignment window (\"center\", \"left\", \"right\"; default \"center\").","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/running_quantile.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Running Quantile Calculation — running_quantile","text":"numeric vector containing running quantile values.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/running_quantile.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Running Quantile Calculation — running_quantile","text":"function computes running quantile numeric vector using specified window size probability.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/running_quantile.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Running Quantile Calculation — running_quantile","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/running_quantile.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Running Quantile Calculation — running_quantile","text":"","code":"# Example usage of running_quantile set.seed(123) data <- cumsum(rnorm(50)) result <- running_quantile(data, .window = 3, .probs = 0.5) print(result) #> [1] -0.6755644 -0.5604756 0.7680552 0.8385636 0.9678513 2.6829163 #> [7] 2.6829163 1.8787713 1.1919184 1.1919184 1.9703382 2.3301521 #> [13] 2.7309235 2.7309235 2.8416062 4.0726782 4.0726782 3.3052675 #> [19] 2.8324760 2.8324760 1.7646523 1.5466774 0.5206730 -0.2082182 #> [25] -0.8332575 -1.6821638 -1.6821638 -1.6821638 -1.5287907 -1.4131127 #> [31] -1.2817199 -0.9866485 -0.3865943 0.4915392 1.3131203 2.0017605 #> [37] 2.4937665 2.4937665 2.1878038 1.8073328 1.1126258 0.9047086 #> [43] 0.9047086 1.8082682 1.8931216 1.8931216 1.4902368 1.4902368 #> [49] 1.7201775 1.7618620 #> attr(,\"window\") #> [1] 3 #> attr(,\"probs\") #> [1] 0.5 #> attr(,\"type\") #> [1] 7 #> attr(,\"rule\") #> [1] \"quantile\" #> attr(,\"align\") #> [1] \"center\" plot(data, type = \"l\") lines(result, col = \"red\")"},{"path":"https://www.spsanderson.com/RandomWalker/reference/rw30.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate Random Walks — rw30","title":"Generate Random Walks — rw30","text":"Generate Random Walks","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/rw30.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate Random Walks — rw30","text":"","code":"rw30()"},{"path":"https://www.spsanderson.com/RandomWalker/reference/rw30.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate Random Walks — rw30","text":"tibble long format columns walk, x, value, representing random walks. Additionally, attributes num_walks, num_steps, mu, sd attached tibble.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/rw30.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Generate Random Walks — rw30","text":"function generates random walks using normal distribution specified mean (mu) standard deviation (sd). walk generated independently stored tibble. resulting tibble pivoted long format easier analysis.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/rw30.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Generate Random Walks — rw30","text":"Steven P. Sanderson II, MPH function generates 30 random walks 100 steps pivots result long format tibble.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/rw30.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Generate Random Walks — rw30","text":"","code":"# Generate random walks and print the result set.seed(123) rw30() #> # A tibble: 3,000 × 3 #> walk_number step_number y #> #> 1 1 1 0 #> 2 1 2 -0.560 #> 3 1 3 -0.791 #> 4 1 4 0.768 #> 5 1 5 0.839 #> 6 1 6 0.968 #> 7 1 7 2.68 #> 8 1 8 3.14 #> 9 1 9 1.88 #> 10 1 10 1.19 #> # ℹ 2,990 more rows set.seed(123) rw30() |> visualize_walks()"},{"path":"https://www.spsanderson.com/RandomWalker/reference/rw_range.html","id":null,"dir":"Reference","previous_headings":"","what":"Range — rw_range","title":"Range — rw_range","text":"function return range vector.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/rw_range.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Range — rw_range","text":"","code":"rw_range(.x)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/rw_range.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Range — rw_range","text":".x numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/rw_range.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Range — rw_range","text":"numeric vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/rw_range.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Range — rw_range","text":"function return range vector. uses max(.x) - min(.x) basis function.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/rw_range.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Range — rw_range","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/rw_range.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Range — rw_range","text":"","code":"x <- mtcars$mpg rw_range(x) #> [1] 23.5"},{"path":"https://www.spsanderson.com/RandomWalker/reference/skewness_vec.html","id":null,"dir":"Reference","previous_headings":"","what":"Compute Skewness of a Vector — skewness_vec","title":"Compute Skewness of a Vector — skewness_vec","text":"function takes vector input return skewness vector. length vector must least four numbers. skewness explains 'tailedness' distribution data. ((1/n) * sum(x - mu})^3) / ((()1/n) * sum(x - mu)^2)^(3/2)","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/skewness_vec.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Compute Skewness of a Vector — skewness_vec","text":"","code":"skewness_vec(.x)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/skewness_vec.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Compute Skewness of a Vector — skewness_vec","text":".x numeric vector length four .","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/skewness_vec.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Compute Skewness of a Vector — skewness_vec","text":"skewness vector","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/skewness_vec.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Compute Skewness of a Vector — skewness_vec","text":"function return skewness vector.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/skewness_vec.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Compute Skewness of a Vector — skewness_vec","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/skewness_vec.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Compute Skewness of a Vector — skewness_vec","text":"","code":"set.seed(123) skewness_vec(rnorm(100, 3, 2)) #> [1] 0.06049948"},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_max_augment.html","id":null,"dir":"Reference","previous_headings":"","what":"Augment Cumulative Maximum — std_cum_max_augment","title":"Augment Cumulative Maximum — std_cum_max_augment","text":"function augments data frame adding cumulative maximum columns specified variables.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_max_augment.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Augment Cumulative Maximum — std_cum_max_augment","text":"","code":"std_cum_max_augment(.data, .value, .names = \"auto\", .initial_value = 0)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_max_augment.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Augment Cumulative Maximum — std_cum_max_augment","text":".data data frame augment. .value column name names compute cumulative maximum. .names Optional. character vector names new cumulative maximum columns. Defaults \"auto\", generates names based original column names. .initial_value numeric value start cumulative maximum . Defaults 0.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_max_augment.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Augment Cumulative Maximum — std_cum_max_augment","text":"tibble original data additional columns containing cumulative maximums.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_max_augment.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Augment Cumulative Maximum — std_cum_max_augment","text":"function takes data frame column name (names) computes cumulative maximum specified column, starting initial value. column names provided, throw error.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_max_augment.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Augment Cumulative Maximum — std_cum_max_augment","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_max_augment.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Augment Cumulative Maximum — std_cum_max_augment","text":"","code":"df <- data.frame(x = c(1, 3, 2, 5, 4), y = c(10, 7, 6, 12, 5)) std_cum_max_augment(df, .value = x) #> # A tibble: 5 × 3 #> x y cum_max_x #> #> 1 1 10 1 #> 2 3 7 3 #> 3 2 6 3 #> 4 5 12 5 #> 5 4 5 5 std_cum_max_augment(df, .value = y, .names = c(\"cummax_y\")) #> # A tibble: 5 × 3 #> x y cummax_y #> #> 1 1 10 10 #> 2 3 7 10 #> 3 2 6 10 #> 4 5 12 12 #> 5 4 5 12"},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_mean_augment.html","id":null,"dir":"Reference","previous_headings":"","what":"Augment Cumulative Sum — std_cum_mean_augment","title":"Augment Cumulative Sum — std_cum_mean_augment","text":"function augments data frame adding cumulative mean columns specified variables.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_mean_augment.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Augment Cumulative Sum — std_cum_mean_augment","text":"","code":"std_cum_mean_augment(.data, .value, .names = \"auto\", .initial_value = 0)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_mean_augment.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Augment Cumulative Sum — std_cum_mean_augment","text":".data data frame augment. .value column name names compute cumulative mean. .names Optional. character vector names new cumulative mean columns. Defaults \"auto\", generates names based original column names. .initial_value numeric value start cumulative mean . Defaults 0.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_mean_augment.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Augment Cumulative Sum — std_cum_mean_augment","text":"tibble original data additional columns containing cumulative means.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_mean_augment.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Augment Cumulative Sum — std_cum_mean_augment","text":"function takes data frame column name (names) computes cumulative mean specified column, starting initial value. column names provided, throw error.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_mean_augment.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Augment Cumulative Sum — std_cum_mean_augment","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_mean_augment.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Augment Cumulative Sum — std_cum_mean_augment","text":"","code":"df <- data.frame(x = c(1, 2, 3, 4, 5), y = c(10, 20, 30, 40, 50)) std_cum_mean_augment(df, .value = x) #> # A tibble: 5 × 3 #> x y cum_mean_x #> #> 1 1 10 1 #> 2 2 20 1.5 #> 3 3 30 2 #> 4 4 40 2.5 #> 5 5 50 3 std_cum_mean_augment(df, .value = y, .names = c(\"cummean_y\")) #> # A tibble: 5 × 3 #> x y cummean_y #> #> 1 1 10 10 #> 2 2 20 15 #> 3 3 30 20 #> 4 4 40 25 #> 5 5 50 30"},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_min_augment.html","id":null,"dir":"Reference","previous_headings":"","what":"Augment Cumulative Minimum — std_cum_min_augment","title":"Augment Cumulative Minimum — std_cum_min_augment","text":"function augments data frame adding cumulative minimum columns specified variables.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_min_augment.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Augment Cumulative Minimum — std_cum_min_augment","text":"","code":"std_cum_min_augment(.data, .value, .names = \"auto\", .initial_value = 0)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_min_augment.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Augment Cumulative Minimum — std_cum_min_augment","text":".data data frame augment. .value column name names compute cumulative minimum. .names Optional. character vector names new cumulative minimum columns. Defaults \"auto\", generates names based original column names. .initial_value numeric value start cumulative minimum . Defaults 0.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_min_augment.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Augment Cumulative Minimum — std_cum_min_augment","text":"tibble original data additional columns containing cumulative minimums.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_min_augment.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Augment Cumulative Minimum — std_cum_min_augment","text":"function takes data frame column name (names) computes cumulative minimum specified column, starting initial value. column names provided, throw error.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_min_augment.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Augment Cumulative Minimum — std_cum_min_augment","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_min_augment.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Augment Cumulative Minimum — std_cum_min_augment","text":"","code":"df <- data.frame(x = c(5, 3, 8, 1, 4), y = c(10, 7, 6, 12, 5)) std_cum_min_augment(df, .value = x) #> # A tibble: 5 × 3 #> x y cum_min_x #> #> 1 5 10 5 #> 2 3 7 3 #> 3 8 6 3 #> 4 1 12 1 #> 5 4 5 1 std_cum_min_augment(df, .value = y, .names = c(\"cummin_y\")) #> # A tibble: 5 × 3 #> x y cummin_y #> #> 1 5 10 10 #> 2 3 7 7 #> 3 8 6 6 #> 4 1 12 6 #> 5 4 5 5"},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_prod_augment.html","id":null,"dir":"Reference","previous_headings":"","what":"Augment Cumulative Product — std_cum_prod_augment","title":"Augment Cumulative Product — std_cum_prod_augment","text":"function augments data frame adding cumulative product columns specified variables.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_prod_augment.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Augment Cumulative Product — std_cum_prod_augment","text":"","code":"std_cum_prod_augment(.data, .value, .names = \"auto\", .initial_value = 1)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_prod_augment.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Augment Cumulative Product — std_cum_prod_augment","text":".data data frame augment. .value column name names compute cumulative product. .names Optional. character vector names new cumulative product columns. Defaults \"auto\", generates names based original column names. .initial_value numeric value start cumulative product . Defaults 1.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_prod_augment.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Augment Cumulative Product — std_cum_prod_augment","text":"tibble original data additional columns containing cumulative products.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_prod_augment.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Augment Cumulative Product — std_cum_prod_augment","text":"function takes data frame column name (names) computes cumulative product specified column, starting initial value. column names provided, throw error.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_prod_augment.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Augment Cumulative Product — std_cum_prod_augment","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_prod_augment.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Augment Cumulative Product — std_cum_prod_augment","text":"","code":"df <- data.frame(x = 1:5, y = 6:10) std_cum_prod_augment(df, .value = x) #> # A tibble: 5 × 3 #> x y cum_prod_x #> #> 1 1 6 2 #> 2 2 7 6 #> 3 3 8 24 #> 4 4 9 120 #> 5 5 10 720 std_cum_prod_augment(df, .value = y, .names = c(\"cumprod_y\")) #> # A tibble: 5 × 3 #> x y cumprod_y #> #> 1 1 6 7 #> 2 2 7 56 #> 3 3 8 504 #> 4 4 9 5040 #> 5 5 10 55440"},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_sum_augment.html","id":null,"dir":"Reference","previous_headings":"","what":"Augment Cumulative Sum — std_cum_sum_augment","title":"Augment Cumulative Sum — std_cum_sum_augment","text":"function augments data frame adding cumulative sum columns specified variables.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_sum_augment.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Augment Cumulative Sum — std_cum_sum_augment","text":"","code":"std_cum_sum_augment(.data, .value, .names = \"auto\", .initial_value = 0)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_sum_augment.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Augment Cumulative Sum — std_cum_sum_augment","text":".data data frame augment. .value column name names compute cumulative sum. .names Optional. character vector names new cumulative sum columns. Defaults \"auto\", generates names based original column names. .initial_value numeric value start cumulative sum . Defaults 0.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_sum_augment.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Augment Cumulative Sum — std_cum_sum_augment","text":"tibble original data additional columns containing cumulative sums.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_sum_augment.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Augment Cumulative Sum — std_cum_sum_augment","text":"function takes data frame column name (names) computes cumulative sum specified column, starting initial value. column names provided, throw error.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_sum_augment.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Augment Cumulative Sum — std_cum_sum_augment","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/std_cum_sum_augment.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Augment Cumulative Sum — std_cum_sum_augment","text":"","code":"df <- data.frame(x = 1:5, y = 6:10) std_cum_sum_augment(df, .value = x) #> # A tibble: 5 × 3 #> x y cum_sum_x #> #> 1 1 6 1 #> 2 2 7 3 #> 3 3 8 6 #> 4 4 9 10 #> 5 5 10 15 std_cum_sum_augment(df, .value = y, .names = c(\"cumsum_y\")) #> # A tibble: 5 × 3 #> x y cumsum_y #> #> 1 1 6 6 #> 2 2 7 13 #> 3 3 8 21 #> 4 4 9 30 #> 5 5 10 40"},{"path":"https://www.spsanderson.com/RandomWalker/reference/summarize_walks.html","id":null,"dir":"Reference","previous_headings":"","what":"Summarize Walks Data — summarize_walks","title":"Summarize Walks Data — summarize_walks","text":"Summarizes random walk data computing statistical measures.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/summarize_walks.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Summarize Walks Data — summarize_walks","text":"","code":"summarize_walks(.data, .value, .group_var) summarise_walks(.data, .value, .group_var)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/summarize_walks.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Summarize Walks Data — summarize_walks","text":".data data frame tibble containing random walk data. .value column name (unquoted) representing value summarize. .group_var column name (unquoted) representing grouping variable.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/summarize_walks.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Summarize Walks Data — summarize_walks","text":"tibble containing summarized statistics group, including mean, median, range, quantiles, variance, standard deviation, .","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/summarize_walks.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Summarize Walks Data — summarize_walks","text":"function requires input data frame contains column named 'walk_number' value summarize provided. computes statistics mean, median, variance, quantiles specified value variable. #' function summarizes data frame containing random walk data computing various statistical measures specified value variable, grouped specified grouping variable. checks necessary attributes ensures data frame structured correctly.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/summarize_walks.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Summarize Walks Data — summarize_walks","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/summarize_walks.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Summarize Walks Data — summarize_walks","text":"","code":"library(dplyr) #> #> Attaching package: 'dplyr' #> The following objects are masked from 'package:stats': #> #> filter, lag #> The following objects are masked from 'package:base': #> #> intersect, setdiff, setequal, union # Example data frame walk_data <- random_normal_walk(.initial_value = 100) # Summarize the walks summarize_walks(walk_data, cum_sum_y, walk_number) |> glimpse() #> Registered S3 method overwritten by 'quantmod': #> method from #> as.zoo.data.frame zoo #> Rows: 25 #> Columns: 16 #> $ walk_number 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, … #> $ fns \"random_normal_walk\", \"random_normal_walk\", \"random_nor… #> $ fns_name \"Random Normal Walk\", \"Random Normal Walk\", \"Random Nor… #> $ mean_val 99.37422, 99.14832, 99.30183, 99.54731, 100.00967, 100.… #> $ median 99.22507, 99.12260, 99.14530, 99.56916, 100.03673, 100.… #> $ range 1.6702035, 1.7192108, 1.3793621, 1.0936667, 0.7246319, … #> $ quantile_lo 98.72405, 98.55386, 98.64469, 98.97943, 99.68817, 99.86… #> $ quantile_hi 100.27413, 100.11414, 99.95320, 100.03119, 100.24455, 1… #> $ variance 0.24567887, 0.14426274, 0.17370115, 0.08828192, 0.02889… #> $ sd 0.4956600, 0.3798194, 0.4167747, 0.2971227, 0.1699798, … #> $ min_val 98.67767, 98.49835, 98.60665, 98.95722, 99.66696, 99.85… #> $ max_val 100.34787, 100.21756, 99.98601, 100.05089, 100.39159, 1… #> $ harmonic_mean 99.37178, 99.14689, 99.30010, 99.54644, 100.00938, 100.… #> $ geometric_mean 99.37300, 99.14760, 99.30096, 99.54688, 100.00952, 100.… #> $ skewness 0.529493030, 0.913117028, 0.180208987, -0.190895194, -0… #> $ kurtosis -1.14650249, 0.87761015, -1.32915687, -0.84946617, -0.7… summarize_walks(walk_data, y) |> glimpse() #> Warning: There was 1 warning in `dplyr::summarize()`. #> ℹ In argument: `geometric_mean = exp(mean(log(y)))`. #> Caused by warning in `log()`: #> ! NaNs produced #> Rows: 1 #> Columns: 15 #> $ fns \"random_normal_walk\" #> $ fns_name \"Random Normal Walk\" #> $ mean_val -0.0005154536 #> $ median 0.002946834 #> $ range 0.6436037 #> $ quantile_lo -0.1943871 #> $ quantile_hi 0.1900136 #> $ variance 0.009756546 #> $ sd 0.09877523 #> $ min_val -0.314552 #> $ max_val 0.3290517 #> $ harmonic_mean -0.04812531 #> $ geometric_mean NaN #> $ skewness -0.09677662 #> $ kurtosis -0.07893013 # Example with missing value variable # summarize_walks(walk_data, NULL, group) # This will trigger an error."},{"path":"https://www.spsanderson.com/RandomWalker/reference/visualize_walks.html","id":null,"dir":"Reference","previous_headings":"","what":"Visualize Walks — visualize_walks","title":"Visualize Walks — visualize_walks","text":"visualize_walks() visualizes output random walk functions RandomWalker package, resulting one ggplot2 plots put together patchwork composed 1 patches.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/visualize_walks.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Visualize Walks — visualize_walks","text":"","code":"visualize_walks(.data, .alpha = 0.7, .interactive = FALSE, .pluck = FALSE)"},{"path":"https://www.spsanderson.com/RandomWalker/reference/visualize_walks.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Visualize Walks — visualize_walks","text":".data input data. Assumed created one random walk functions RandomWalker package, can data frame tibble contains columns walk_number, x, one numeric columns like y, cum_sum, cum_prod, cum_min, cum_max cum_mean, instance. .alpha alpha value line charts visualization. Values range 0 1. Default 0.7. .interactive boolean value. TRUE want patches interactive. FALSE . Default FALSE. .pluck want visualize one can choose one values (y, cum_sum, cum_prod, cum_min, cum_max, cum_mean). Default FALSE.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/visualize_walks.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Visualize Walks — visualize_walks","text":"patchwork composed 1 patches","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/visualize_walks.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Visualize Walks — visualize_walks","text":"visualize_walks() generates visualizations random walks generated random walk functions RandomWalker package. functions moment writing: brownian_motion() discrete_walk() geometric_brownian_motion() random_normal_drift_walk() random_normal_walk() rw30() possible read , can check rest documentation current situation. visualization function meant easy use. parameters needed, can set .alpha default value 0.7 liking. can also choose whether want visualization interactive setting .interactive TRUE. function uses ggiraph package making patches interactive. want visualize one attributes, can choose use one values (y, cum_sum, cum_prod, cum_min, cum_max, cum_mean) .pluck parameter.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/visualize_walks.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Visualize Walks — visualize_walks","text":"Antti Lennart Rask","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/visualize_walks.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Visualize Walks — visualize_walks","text":"","code":"# Generate random walks and visualize the result set.seed(123) rw30() |> visualize_walks() # Set the alpha value to be other than the default 0.7 set.seed(123) rw30() |> visualize_walks(.alpha = 0.5) # Use the function with an input that has alternatives for y set.seed(123) random_normal_walk(.num_walks = 5, .initial_value = 100) |> visualize_walks() # Use the function to create interactive visualizations set.seed(123) random_normal_walk(.num_walks = 5, .initial_value = 100) |> visualize_walks(.interactive = TRUE) {\"x\":{\"html\":\"\\n\\n \\n \\n \\n <\\/clipPath>\\n \\n \\n <\\/clipPath>\\n \\n \\n <\\/clipPath>\\n \\n \\n <\\/clipPath>\\n \\n \\n <\\/clipPath>\\n \\n \\n <\\/clipPath>\\n \\n \\n <\\/clipPath>\\n \\n \\n <\\/clipPath>\\n \\n \\n <\\/clipPath>\\n \\n \\n <\\/clipPath>\\n \\n \\n <\\/clipPath>\\n \\n \\n <\\/clipPath>\\n \\n \\n <\\/clipPath>\\n \\n \\n <\\/clipPath>\\n <\\/defs>\\n \\n \\n \\n \\n <\\/g>\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n <\\/g>\\n \\n -0.2<\\/text>\\n -0.1<\\/text>\\n 0.0<\\/text>\\n 0.1<\\/text>\\n 0.2<\\/text>\\n 0<\\/text>\\n 20<\\/text>\\n 40<\\/text>\\n 60<\\/text>\\n 80<\\/text>\\n Step<\\/text>\\n y<\\/text>\\n <\\/g>\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n <\\/g>\\n \\n 99<\\/text>\\n 100<\\/text>\\n 101<\\/text>\\n 102<\\/text>\\n 0<\\/text>\\n 20<\\/text>\\n 40<\\/text>\\n 60<\\/text>\\n 80<\\/text>\\n Step<\\/text>\\n Cumulative Sum Y<\\/text>\\n <\\/g>\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n <\\/g>\\n \\n 0<\\/text>\\n 50<\\/text>\\n 100<\\/text>\\n 150<\\/text>\\n 200<\\/text>\\n 0<\\/text>\\n 20<\\/text>\\n 40<\\/text>\\n 60<\\/text>\\n 80<\\/text>\\n Step<\\/text>\\n Cumulative Prod Y<\\/text>\\n <\\/g>\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n <\\/g>\\n \\n 99.8<\\/text>\\n 99.9<\\/text>\\n 100.0<\\/text>\\n 100.1<\\/text>\\n 0<\\/text>\\n 20<\\/text>\\n 40<\\/text>\\n 60<\\/text>\\n 80<\\/text>\\n Step<\\/text>\\n Cumulative Min Y<\\/text>\\n <\\/g>\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n <\\/g>\\n \\n 100.12<\\/text>\\n 100.16<\\/text>\\n 100.20<\\/text>\\n 100.24<\\/text>\\n 0<\\/text>\\n 20<\\/text>\\n 40<\\/text>\\n 60<\\/text>\\n 80<\\/text>\\n Step<\\/text>\\n Cumulative Max Y<\\/text>\\n <\\/g>\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n <\\/g>\\n \\n 100.02<\\/text>\\n 100.06<\\/text>\\n 100.10<\\/text>\\n 0<\\/text>\\n 20<\\/text>\\n 40<\\/text>\\n 60<\\/text>\\n 80<\\/text>\\n Step<\\/text>\\n Cumulative Mean Y<\\/text>\\n 1 dimensions, mu = 0, sd = 0.1.<\\/text>\\n Function: Random Normal Walk<\\/text>\\n 5 Random Walks<\\/text>\\n <\\/g>\\n <\\/g>\\n<\\/svg>\",\"js\":null,\"uid\":\"svg_c988a3f9_a001_4854_90a8_c271123c3763\",\"ratio\":1.2,\"settings\":{\"tooltip\":{\"css\":\".tooltip_SVGID_ { padding:5px;background:black;color:white;border-radius:2px 2px 2px 2px;text-align:left; ; position:absolute;pointer-events:none;z-index:999;}\",\"placement\":\"doc\",\"opacity\":0.7,\"offx\":200,\"offy\":5,\"use_cursor_pos\":false,\"use_fill\":false,\"use_stroke\":false,\"delay_over\":200,\"delay_out\":500},\"hover\":{\"css\":\".hover_data_SVGID_ { stroke:black;stroke-width:2pt; }\",\"reactive\":false,\"nearest_distance\":null},\"hover_inv\":{\"css\":\".hover_inv_SVGID_ { opacity:0.4; }\"},\"hover_key\":{\"css\":\".hover_key_SVGID_ { fill:orange;stroke:black;cursor:pointer; }\\ntext.hover_key_SVGID_ { stroke:none;fill:orange; }\\ncircle.hover_key_SVGID_ { fill:orange;stroke:black; }\\nline.hover_key_SVGID_, polyline.hover_key_SVGID_ { fill:none;stroke:orange; }\\nrect.hover_key_SVGID_, polygon.hover_key_SVGID_, path.hover_key_SVGID_ { fill:orange;stroke:none; }\\nimage.hover_key_SVGID_ { stroke:orange; }\",\"reactive\":true},\"hover_theme\":{\"css\":\".hover_theme_SVGID_ { fill:orange;stroke:black;cursor:pointer; }\\ntext.hover_theme_SVGID_ { stroke:none;fill:orange; }\\ncircle.hover_theme_SVGID_ { fill:orange;stroke:black; }\\nline.hover_theme_SVGID_, polyline.hover_theme_SVGID_ { fill:none;stroke:orange; }\\nrect.hover_theme_SVGID_, polygon.hover_theme_SVGID_, path.hover_theme_SVGID_ { fill:orange;stroke:none; }\\nimage.hover_theme_SVGID_ { stroke:orange; }\",\"reactive\":true},\"select\":{\"css\":\".select_data_SVGID_ { fill:red;stroke:black;cursor:pointer; }\\ntext.select_data_SVGID_ { stroke:none;fill:red; }\\ncircle.select_data_SVGID_ { fill:red;stroke:black; }\\nline.select_data_SVGID_, polyline.select_data_SVGID_ { fill:none;stroke:red; }\\nrect.select_data_SVGID_, polygon.select_data_SVGID_, path.select_data_SVGID_ { fill:red;stroke:none; }\\nimage.select_data_SVGID_ { stroke:red; }\",\"type\":\"multiple\",\"only_shiny\":true,\"selected\":[]},\"select_inv\":{\"css\":\"\"},\"select_key\":{\"css\":\".select_key_SVGID_ { fill:red;stroke:black;cursor:pointer; }\\ntext.select_key_SVGID_ { stroke:none;fill:red; }\\ncircle.select_key_SVGID_ { fill:red;stroke:black; }\\nline.select_key_SVGID_, polyline.select_key_SVGID_ { fill:none;stroke:red; }\\nrect.select_key_SVGID_, polygon.select_key_SVGID_, path.select_key_SVGID_ { fill:red;stroke:none; }\\nimage.select_key_SVGID_ { stroke:red; }\",\"type\":\"single\",\"only_shiny\":true,\"selected\":[]},\"select_theme\":{\"css\":\".select_theme_SVGID_ { fill:red;stroke:black;cursor:pointer; }\\ntext.select_theme_SVGID_ { stroke:none;fill:red; }\\ncircle.select_theme_SVGID_ { fill:red;stroke:black; }\\nline.select_theme_SVGID_, polyline.select_theme_SVGID_ { fill:none;stroke:red; }\\nrect.select_theme_SVGID_, polygon.select_theme_SVGID_, path.select_theme_SVGID_ { fill:red;stroke:none; }\\nimage.select_theme_SVGID_ { stroke:red; }\",\"type\":\"single\",\"only_shiny\":true,\"selected\":[]},\"zoom\":{\"min\":1,\"max\":5,\"duration\":300},\"toolbar\":{\"position\":\"topright\",\"pngname\":\"diagram\",\"tooltips\":null,\"fixed\":false,\"hidden\":[],\"delay_over\":200,\"delay_out\":500},\"sizing\":{\"rescale\":true,\"width\":1}}},\"evals\":[],\"jsHooks\":[]} # Use .pluck to pick just one visualization set.seed(123) random_normal_walk(.num_walks = 5, .initial_value = 100) |> visualize_walks(.pluck = \"cum_sum\")"},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/news/index.html","id":"breaing-changes-development-version","dir":"Changelog","previous_headings":"","what":"Breaing Changes","title":"RandomWalker (development version)","text":"Fix #107 - change allows generation random walks 3 dimensions. Due x column now called step_number random walk functions including rw30(). x column now first dimension 2d/3d random walk.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/news/index.html","id":"new-features-development-version","dir":"Changelog","previous_headings":"","what":"New Features","title":"RandomWalker (development version)","text":"Fix #105 - Add internal function rand_walk_column_names() generate column names random walks.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/news/index.html","id":"minor-fixes-and-improvements-development-version","dir":"Changelog","previous_headings":"","what":"Minor Fixes and Improvements","title":"RandomWalker (development version)","text":"Fix #107 - Add .dimensions parameter random walk functions allow generation random walks 3 dimensions.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/news/index.html","id":"randomwalker-020","dir":"Changelog","previous_headings":"","what":"RandomWalker 0.2.0","title":"RandomWalker 0.2.0","text":"CRAN release: 2024-10-23","code":""},{"path":"https://www.spsanderson.com/RandomWalker/news/index.html","id":"breaking-changes-0-2-0","dir":"Changelog","previous_headings":"","what":"Breaking Changes","title":"RandomWalker 0.2.0","text":"None","code":""},{"path":"https://www.spsanderson.com/RandomWalker/news/index.html","id":"new-features-0-2-0","dir":"Changelog","previous_headings":"","what":"New Features","title":"RandomWalker 0.2.0","text":"Fix #92 - Add Function std_cum_sum_augment() calculate cumulative sum random walk. Fix #93 - Add Function std_cum_prod_augment() calculate cumulative product random walk. Fix #94 - Add Function std_cum_min_augment() calculate cumulative minimum random walk. Fix #95 - Add Function std_cum_max_augment() calculate cumulative maximum random walk. Fix #96 - Add Function std_cum_mean_augment() calculate cumulative mean random walk. Fix #113 - Add Function get_attributes() get attributes without row.names Fix #123 - Add Function running_quantile() calculate running quantile given vector.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/news/index.html","id":"minor-improvements-and-fixes-0-2-0","dir":"Changelog","previous_headings":"","what":"Minor Improvements and Fixes","title":"RandomWalker 0.2.0","text":"Fix #117 - Add .interactive parameter visualize_walks() allow interactive plots. Fix #120 - Add .pluck parameter visualize_walks() allow plucking specific graph walks.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/news/index.html","id":"release-blog-post-0-2-0","dir":"Changelog","previous_headings":"","what":"Release Blog Post","title":"RandomWalker 0.2.0","text":"https://www.spsanderson.com/steveondata/posts/2024-10-24/","code":""},{"path":"https://www.spsanderson.com/RandomWalker/news/index.html","id":"randomwalker-010","dir":"Changelog","previous_headings":"","what":"RandomWalker 0.1.0","title":"RandomWalker 0.1.0","text":"CRAN release: 2024-09-15","code":""},{"path":"https://www.spsanderson.com/RandomWalker/news/index.html","id":"breaking-changes-0-1-0","dir":"Changelog","previous_headings":"","what":"Breaking Changes","title":"RandomWalker 0.1.0","text":"None","code":""},{"path":"https://www.spsanderson.com/RandomWalker/news/index.html","id":"new-features-0-1-0","dir":"Changelog","previous_headings":"","what":"New Features","title":"RandomWalker 0.1.0","text":"Fix #9 - Add Function rw30() generate 30 random walks 100 steps Fix #17 - Add Function geometric_brownian_motion() generate Geometric Brownian Motion Fix #18 - Add Function random_normal_drift_walk() generate Random Walk Drift Fix #16 - Add Function brownian_motion() generate Brownian Motion Fix #13 - Add Function random_normal_walk() generate Random Walk Fix #30 - Add Function discrete_walk() generate Discrete Random Walk Fix #43 - Add vectorized functions Fix #44 - Add Function internal_rand_walk_helper() help generate common columns random walks. Fix #34 - Add Function euclidean_distance() calculate Euclidean distance random walk. Fix #33 - Add Function visualize_walks() visualize random walks. Fix #66 - Add Function summarize_walks() summarize random walks.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/news/index.html","id":"minor-improvements-and-fixes-0-1-0","dir":"Changelog","previous_headings":"","what":"Minor Improvements and Fixes","title":"RandomWalker 0.1.0","text":"None","code":""}] diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 0d53cea..9a36768 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -29,6 +29,7 @@ https://www.spsanderson.com/RandomWalker/reference/name.html https://www.spsanderson.com/RandomWalker/reference/random_normal_drift_walk.html https://www.spsanderson.com/RandomWalker/reference/random_normal_walk.html +https://www.spsanderson.com/RandomWalker/reference/rand_walk_column_names.html https://www.spsanderson.com/RandomWalker/reference/rand_walk_helper.html https://www.spsanderson.com/RandomWalker/reference/running_quantile.html https://www.spsanderson.com/RandomWalker/reference/rw30.html diff --git a/man/brownian_motion.Rd b/man/brownian_motion.Rd index 442af29..cdcdcb0 100644 --- a/man/brownian_motion.Rd +++ b/man/brownian_motion.Rd @@ -9,7 +9,7 @@ brownian_motion( .n = 100, .delta_time = 1, .initial_value = 0, - .return_tibble = TRUE + .dimensions = 1 ) } \arguments{ @@ -21,11 +21,26 @@ brownian_motion( \item{.initial_value}{Integer representing the initial value.} -\item{.return_tibble}{The default is TRUE. If set to FALSE then an object -of class matrix will be returned.} +\item{.dimensions}{The default is 1. Allowable values are 1, 2 and 3.} } \value{ -A tibble/matrix +A tibble containing the generated random walks with columns depending on the number of dimensions: +\itemize{ +\item \code{walk_number}: Factor representing the walk number. +\item \code{step_number}: Step index. +\item \code{y}: If \code{.dimensions = 1}, the value of the walk at each step. +\item \code{x}, \code{y}: If \code{.dimensions = 2}, the values of the walk in two dimensions. +\item \code{x}, \code{y}, \code{z}: If \code{.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: +\itemize{ +\item \code{cum_sum}: Cumulative sum of \code{dplyr::all_of(.dimensions)}. +\item \code{cum_prod}: Cumulative product of \code{dplyr::all_of(.dimensions)}. +\item \code{cum_min}: Cumulative minimum of \code{dplyr::all_of(.dimensions)}. +\item \code{cum_max}: Cumulative maximum of \code{dplyr::all_of(.dimensions)}. +\item \code{cum_mean}: Cumulative mean of \code{dplyr::all_of(.dimensions)}. +} } \description{ Create a Brownian Motion Tibble @@ -55,8 +70,9 @@ set.seed(123) brownian_motion() set.seed(123) -brownian_motion(.num_walks = 5) |> - visualize_walks() +brownian_motion(.dimensions = 3) |> + head() |> + t() } \seealso{ diff --git a/man/discrete_walk.Rd b/man/discrete_walk.Rd index 11adb8d..8f7a332 100644 --- a/man/discrete_walk.Rd +++ b/man/discrete_walk.Rd @@ -10,7 +10,8 @@ discrete_walk( .upper_bound = 1, .lower_bound = -1, .upper_probability = 0.5, - .initial_value = 100 + .initial_value = 100, + .dimensions = 1 ) } \arguments{ @@ -26,10 +27,29 @@ discrete_walk( The lower bound is calculated as 1 - .upper_probability.} \item{.initial_value}{The initial value of the random walk. Default is 100.} + +\item{.dimensions}{The default is 1. Allowable values are 1, 2 and 3.} } \value{ -A tibble containing the simulated walks, with columns for the walk number, -time period, and various cumulative metrics (sum, product, min, max). +A tibble containing the generated random walks with columns depending +on the number of dimensions: +\itemize{ +\item \code{walk_number}: Factor representing the walk number. +\item \code{step_number}: Step index. +\item \code{y}: If \code{.dimensions = 1}, the value of the walk at each step. +\item \code{x}, \code{y}: If \code{.dimensions = 2}, the values of the walk in two dimensions. +\item \code{x}, \code{y}, \code{z}: If \code{.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: +\itemize{ +\item \code{cum_sum}: Cumulative sum of \code{dplyr::all_of(.dimensions)}. +\item \code{cum_prod}: Cumulative product of \code{dplyr::all_of(.dimensions)}. +\item \code{cum_min}: Cumulative minimum of \code{dplyr::all_of(.dimensions)}. +\item \code{cum_max}: Cumulative maximum of \code{dplyr::all_of(.dimensions)}. +\item \code{cum_mean}: Cumulative mean of \code{dplyr::all_of(.dimensions)}. +} } \description{ The \code{discrete_walk} function generates multiple random walks over discrete time periods. @@ -46,15 +66,13 @@ minimum, and maximum of the steps are calculated for each walk. The results are in a tibble with detailed attributes, including the parameters used for the simulation. } \examples{ -library(ggplot2) - set.seed(123) discrete_walk() set.seed(123) -discrete_walk(.num_walks = 10, .n = 250, .upper_probability = 0.51, -.initial_value = 100) |> -visualize_walks() +discrete_walk(.dimensions = 3) |> + head() |> + t() } \seealso{ diff --git a/man/euclidean_distance.Rd b/man/euclidean_distance.Rd index 03386d0..e9d6c76 100644 --- a/man/euclidean_distance.Rd +++ b/man/euclidean_distance.Rd @@ -31,8 +31,8 @@ the data frame with a new column called \code{distance}. \examples{ set.seed(123) df <- rw30() -euclidean_distance(df, x, y) -euclidean_distance(df, x, y, TRUE) |> head(10) +euclidean_distance(df, step_number, y) +euclidean_distance(df, step_number, y, TRUE) |> head(10) } \seealso{ diff --git a/man/geometric_brownian_motion.Rd b/man/geometric_brownian_motion.Rd index 1a1b2e9..cc157e4 100644 --- a/man/geometric_brownian_motion.Rd +++ b/man/geometric_brownian_motion.Rd @@ -11,7 +11,7 @@ geometric_brownian_motion( .sigma = 0.1, .initial_value = 100, .delta_time = 0.003, - .return_tibble = TRUE + .dimensions = 1 ) } \arguments{ @@ -27,11 +27,28 @@ geometric_brownian_motion( \item{.delta_time}{Time step size.} -\item{.return_tibble}{The default is TRUE. If set to FALSE then an object -of class matrix will be returned.} +\item{.dimensions}{The default is 1. Allowable values are 1, 2 and 3.} } \value{ -A tibble/matrix +A tibble containing the generated random walks with columns depending +on the number of dimensions: +\itemize{ +\item \code{walk_number}: Factor representing the walk number. +\item \code{step_number}: Step index. +\item \code{y}: If \code{.dimensions = 1}, the value of the walk at each step. +\item \code{x}, \code{y}: If \code{.dimensions = 2}, the values of the walk in two dimensions. +\item \code{x}, \code{y}, \code{z}: If \code{.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: +\itemize{ +\item \code{cum_sum}: Cumulative sum of \code{dplyr::all_of(.dimensions)}. +\item \code{cum_prod}: Cumulative product of \code{dplyr::all_of(.dimensions)}. +\item \code{cum_min}: Cumulative minimum of \code{dplyr::all_of(.dimensions)}. +\item \code{cum_max}: Cumulative maximum of \code{dplyr::all_of(.dimensions)}. +\item \code{cum_mean}: Cumulative mean of \code{dplyr::all_of(.dimensions)}. +} } \description{ Create a Geometric Brownian Motion. @@ -66,12 +83,14 @@ of a GBM process. It can be used to analyze the behavior of financial assets and to make informed investment decisions. } \examples{ + set.seed(123) geometric_brownian_motion() set.seed(123) -geometric_brownian_motion(.num_walks = 5) |> - visualize_walks() +geometric_brownian_motion(.dimensions = 3) |> + head() |> + t() } \seealso{ diff --git a/man/random_normal_drift_walk.Rd b/man/random_normal_drift_walk.Rd index 4d7ad39..dd7e37e 100644 --- a/man/random_normal_drift_walk.Rd +++ b/man/random_normal_drift_walk.Rd @@ -10,7 +10,8 @@ random_normal_drift_walk( .mu = 0, .sd = 1, .drift = 0.1, - .initial_value = 0 + .initial_value = 0, + .dimensions = 1 ) } \arguments{ @@ -25,11 +26,29 @@ random_normal_drift_walk( \item{.drift}{Numeric. The drift term to be added to each step. Default is 0.1.} \item{.initial_value}{A numeric value indicating the initial value of the walks. Default is 0.} + +\item{.dimensions}{The default is 1. Allowable values are 1, 2 and 3.} } \value{ -A tibble in long format with columns \code{walk_number}, \code{x} (step index), -and \code{y} (walk value). The tibble has attributes for the number of walks, -number of steps, mean, standard deviation, and drift. +A tibble containing the generated random walks with columns depending +on the number of dimensions: +\itemize{ +\item \code{walk_number}: Factor representing the walk number. +\item \code{step_number}: Step index. +\item \code{y}: If \code{.dimensions = 1}, the value of the walk at each step. +\item \code{x}, \code{y}: If \code{.dimensions = 2}, the values of the walk in two dimensions. +\item \code{x}, \code{y}, \code{z}: If \code{.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: +\itemize{ +\item \code{cum_sum}: Cumulative sum of \code{dplyr::all_of(.dimensions)}. +\item \code{cum_prod}: Cumulative product of \code{dplyr::all_of(.dimensions)}. +\item \code{cum_min}: Cumulative minimum of \code{dplyr::all_of(.dimensions)}. +\item \code{cum_max}: Cumulative maximum of \code{dplyr::all_of(.dimensions)}. +\item \code{cum_mean}: Cumulative mean of \code{dplyr::all_of(.dimensions)}. +} } \description{ This function generates a specified number of random walks, each consisting @@ -45,9 +64,12 @@ additional drift term added to each step. } \examples{ 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() +random_normal_drift_walk() + +set.seed(123) +random_normal_drift_walk(.dimensions = 3) |> + head() |> + t() } \seealso{ diff --git a/man/random_normal_walk.Rd b/man/random_normal_walk.Rd index dd12eb2..a8afb68 100644 --- a/man/random_normal_walk.Rd +++ b/man/random_normal_walk.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/gen-random-normal-walk.R \name{random_normal_walk} \alias{random_normal_walk} -\title{Generate Multiple Random Normal Walks} +\title{Generate Multiple Random Normal Walks in Multiple Dimensions} \usage{ random_normal_walk( .num_walks = 25, @@ -12,7 +12,8 @@ random_normal_walk( .initial_value = 0, .samp = TRUE, .replace = TRUE, - .sample_size = 0.8 + .sample_size = 0.8, + .dimensions = 1 ) } \arguments{ @@ -31,9 +32,20 @@ random_normal_walk( \item{.replace}{A logical value indicating whether sampling is with replacement. Default is TRUE.} \item{.sample_size}{A numeric value between 0 and 1 specifying the proportion of \code{.n} to sample. Default is 0.8.} + +\item{.dimensions}{An integer specifying the number of dimensions (1, 2, or 3). Default is 1.} } \value{ -A tibble containing the generated random walks with the following columns: +A tibble containing the generated random walks with columns depending on the number of dimensions: +\itemize{ +\item \code{walk_number}: Factor representing the walk number. +\item \code{step_number}: Step index. +\item \code{y}: If \code{.dimensions = 1}, the value of the walk at each step. +\item \code{x}, \code{y}: If \code{.dimensions = 2}, the values of the walk in two dimensions. +\item \code{x}, \code{y}, \code{z}: If \code{.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: \itemize{ \item \code{walk_number}: Factor representing the walk number. \item \code{x}: Step index. @@ -43,38 +55,24 @@ A tibble containing the generated random walks with the following columns: \item \code{cum_min}: Cumulative minimum of \code{y}. \item \code{cum_max}: Cumulative maximum of \code{y}. } + The tibble includes attributes for the function parameters. } \description{ -The \code{random_normal_walk} function is useful for simulating random processes -and can be applied in various fields such as finance, physics, and biology -to model different stochastic behaviors. -} -\details{ -This function generates multiple random walks, which are sequences of steps -where each step is a random draw from a normal distribution. The user can -specify the number of walks, the number of steps in each walk, and the -parameters of the normal distribution (mean and standard deviation). The -function also allows for sampling a proportion of the steps and optionally -sampling with replacement. - -The output tibble includes several computed columns for each walk, such as the -cumulative sum, product, minimum, and maximum of the steps. +The \code{random_normal_walk} function generates multiple random walks in 1, 2, or 3 dimensions. +Each walk is a sequence of steps where each step is a random draw from a normal distribution. +The user can specify the number of walks, the number of steps in each walk, and the +parameters of the normal distribution (mean and standard deviation). The function +also allows for sampling a proportion of the steps and optionally sampling with replacement. } \examples{ -library(ggplot2) - -# Generate 10 random walks with 50 steps each -set.seed(123) -random_normal_walk(.num_walks = 10, .n = 50) - -# Generate random walks with different mean and standard deviation set.seed(123) -random_normal_walk(.num_walks = 10, .n = 50, .samp = FALSE) +random_normal_walk() set.seed(123) -random_normal_walk(.num_walks = 2, .n = 100, .initial_value = 100) |> - visualize_walks() +random_normal_walk(.dimensions = 3) |> + head() |> + t() } \seealso{ diff --git a/man/summarize_walks.Rd b/man/summarize_walks.Rd index c89916f..8e4387d 100644 --- a/man/summarize_walks.Rd +++ b/man/summarize_walks.Rd @@ -40,7 +40,7 @@ library(dplyr) walk_data <- random_normal_walk(.initial_value = 100) # Summarize the walks -summarize_walks(walk_data, cum_sum, walk_number) |> +summarize_walks(walk_data, cum_sum_y, walk_number) |> glimpse() summarize_walks(walk_data, y) |> glimpse()