From bc53a5b31112aca007a5489773e17d7295aabb18 Mon Sep 17 00:00:00 2001 From: "Steven Paul Sanderson II, MPH" Date: Mon, 29 Jul 2024 16:04:56 -0400 Subject: [PATCH] Fixes #34 --- NAMESPACE | 1 + NEWS.md | 2 + ...functions.R => vec-cumulative-functions.R} | 0 R/vec-distance.R | 56 +++++++ docs/news/index.html | 1 + docs/pkgdown.yml | 2 +- docs/reference/cgmean.html | 3 +- docs/reference/chmean.html | 3 +- docs/reference/ckurtosis.html | 3 +- docs/reference/cmean.html | 3 +- docs/reference/cmedian.html | 3 +- docs/reference/crange.html | 3 +- docs/reference/csd.html | 3 +- docs/reference/cskewness.html | 3 +- docs/reference/cvar.html | 3 +- docs/reference/euclidean_distance.html | 143 ++++++++++++++++++ docs/reference/index.html | 6 + docs/reference/kurtosis_vec.html | 3 +- docs/reference/rw_range.html | 3 +- docs/reference/skewness_vec.html | 3 +- docs/search.json | 2 +- docs/sitemap.xml | 1 + man/cgmean.Rd | 3 +- man/chmean.Rd | 3 +- man/ckurtosis.Rd | 3 +- man/cmean.Rd | 3 +- man/cmedian.Rd | 3 +- man/crange.Rd | 3 +- man/csd.Rd | 3 +- man/cskewness.Rd | 3 +- man/cvar.Rd | 3 +- man/euclidean_distance.Rd | 56 +++++++ man/kurtosis_vec.Rd | 3 +- man/rw_range.Rd | 3 +- man/skewness_vec.Rd | 3 +- 35 files changed, 316 insertions(+), 26 deletions(-) rename R/{vec-functions.R => vec-cumulative-functions.R} (100%) create mode 100644 R/vec-distance.R create mode 100644 docs/reference/euclidean_distance.html create mode 100644 man/euclidean_distance.Rd diff --git a/NAMESPACE b/NAMESPACE index a7d71a0..0a5f507 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -11,6 +11,7 @@ export(csd) export(cskewness) export(cvar) export(discrete_walk) +export(euclidean_distance) export(geometric_brownian_motion) export(kurtosis_vec) export(rand_walk_helper) diff --git a/NEWS.md b/NEWS.md index a20f350..b2b87a5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -13,6 +13,8 @@ None 7. Fix #43 - Add vectorized functions 8. Fix #44 - Add Function `internal_rand_walk_helper()` to help generate common columns for random walks. +9. Fix #34 - Add Function `euclidean_distance()` to calculate the Euclidean distance +of a random walk. ## Minor Improvements and Fixes None diff --git a/R/vec-functions.R b/R/vec-cumulative-functions.R similarity index 100% rename from R/vec-functions.R rename to R/vec-cumulative-functions.R diff --git a/R/vec-distance.R b/R/vec-distance.R new file mode 100644 index 0000000..2fc701e --- /dev/null +++ b/R/vec-distance.R @@ -0,0 +1,56 @@ +#' Distance Calculations +#' +#' @family Vector Function +#' +#' @author Steven P. Sanderson II, MPH +#' +#' @details +#' A function to calculate the Euclidean distance between two vectors. It uses +#' the formula `sqrt((x - lag(x))^2 + (y - lag(y))^2)`. The function uses augments +#' the data frame with a new column called `distance`. +#' +#' @description +#' A function to calculate the Euclidean distance between two vectors. +#' +#' @param .data A data frame +#' @param .x A numeric vector +#' @param .y A numeric vector +#' @param .pull_vector A boolean of TRUE or FALSE. Default is FALSE which will +#' augment the distance to the data frame. TRUE will return a vector of the distances +#' as the return. +#' +#' @examples +#' set.seed(123) +#' df <- rw30() +#' euclidean_distance(df, x, y) +#' euclidean_distance(df, x, y, TRUE) |> head(10) +#' +#' @return +#' A numeric Vector of ditances +#' +#' @name euclidean_distance +NULL +#' @rdname euclidean_distance +#' @export + +euclidean_distance <- function(.data, .x, .y, .pull_vector = FALSE) { + + # Tidyeval --- + x_var <- rlang::enquo(.x) + y_var <- rlang::enquo(.y) + + # Calculate the distance --- + ret <- dplyr::as_tibble(.data) |> + dplyr::mutate( + distance = sqrt( + (!!x_var - dplyr::lag(!!x_var, 1))^2 + (!!y_var - dplyr::lag(!!y_var, 1))^2 + ) + ) + + # Return the distance vector --- + if (.pull_vector) { + return(ret[["distance"]]) + } + + return(ret) +} diff --git a/docs/news/index.html b/docs/news/index.html index 60a42a6..3fceee6 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -49,6 +49,7 @@

New FeaturesFix #30 - Add Function discrete_walk() to generate Discrete Random Walk
  • Fix #43 - Add vectorized functions
  • Fix #44 - Add Function internal_rand_walk_helper() to help generate common columns for random walks.
  • +
  • Fix #34 - Add Function euclidean_distance() to calculate the Euclidean distance of a random walk.
  • Minor Improvements and Fixes

    diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 0ae3e0c..152f45f 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -3,7 +3,7 @@ pkgdown: 2.1.0 pkgdown_sha: ~ articles: getting-started: getting-started.html -last_built: 2024-07-29T19:09Z +last_built: 2024-07-29T20:03Z urls: reference: https://www.spsanderson.com/RandomWalker/reference article: https://www.spsanderson.com/RandomWalker/articles diff --git a/docs/reference/cgmean.html b/docs/reference/cgmean.html index f2831e7..15febd8 100644 --- a/docs/reference/cgmean.html +++ b/docs/reference/cgmean.html @@ -30,7 +30,7 @@
    @@ -71,6 +71,7 @@

    See alsocsd(), cskewness(), cvar(), +euclidean_distance(), kurtosis_vec(), rw_range(), skewness_vec()

    diff --git a/docs/reference/chmean.html b/docs/reference/chmean.html index cc82fbb..de5b55c 100644 --- a/docs/reference/chmean.html +++ b/docs/reference/chmean.html @@ -30,7 +30,7 @@
    @@ -71,6 +71,7 @@

    See alsocsd(), cskewness(), cvar(), +euclidean_distance(), kurtosis_vec(), rw_range(), skewness_vec()

    diff --git a/docs/reference/ckurtosis.html b/docs/reference/ckurtosis.html index 2167caf..2a79825 100644 --- a/docs/reference/ckurtosis.html +++ b/docs/reference/ckurtosis.html @@ -30,7 +30,7 @@
    @@ -70,6 +70,7 @@

    See alsocsd(), cskewness(), cvar(), +euclidean_distance(), kurtosis_vec(), rw_range(), skewness_vec()

    diff --git a/docs/reference/cmean.html b/docs/reference/cmean.html index 0e8a3e2..9be3dd1 100644 --- a/docs/reference/cmean.html +++ b/docs/reference/cmean.html @@ -30,7 +30,7 @@
    @@ -71,6 +71,7 @@

    See alsocsd(), cskewness(), cvar(), +euclidean_distance(), kurtosis_vec(), rw_range(), skewness_vec()

    diff --git a/docs/reference/cmedian.html b/docs/reference/cmedian.html index 1db6602..10ce871 100644 --- a/docs/reference/cmedian.html +++ b/docs/reference/cmedian.html @@ -30,7 +30,7 @@
    @@ -70,6 +70,7 @@

    See alsocsd(), cskewness(), cvar(), +euclidean_distance(), kurtosis_vec(), rw_range(), skewness_vec()

    diff --git a/docs/reference/crange.html b/docs/reference/crange.html index 23c9132..5eec45d 100644 --- a/docs/reference/crange.html +++ b/docs/reference/crange.html @@ -30,7 +30,7 @@
    @@ -71,6 +71,7 @@

    See alsocsd(), cskewness(), cvar(), +euclidean_distance(), kurtosis_vec(), rw_range(), skewness_vec()

    diff --git a/docs/reference/csd.html b/docs/reference/csd.html index 866a778..02cadc2 100644 --- a/docs/reference/csd.html +++ b/docs/reference/csd.html @@ -30,7 +30,7 @@
    @@ -71,6 +71,7 @@

    See alsocrange(), cskewness(), cvar(), +euclidean_distance(), kurtosis_vec(), rw_range(), skewness_vec()

    diff --git a/docs/reference/cskewness.html b/docs/reference/cskewness.html index ae94ab5..afe83cc 100644 --- a/docs/reference/cskewness.html +++ b/docs/reference/cskewness.html @@ -30,7 +30,7 @@
    @@ -70,6 +70,7 @@

    See alsocrange(), csd(), cvar(), +euclidean_distance(), kurtosis_vec(), rw_range(), skewness_vec()

    diff --git a/docs/reference/cvar.html b/docs/reference/cvar.html index 1e1c142..b9a63aa 100644 --- a/docs/reference/cvar.html +++ b/docs/reference/cvar.html @@ -30,7 +30,7 @@
    @@ -72,6 +72,7 @@

    See alsocrange(), csd(), cskewness(), +euclidean_distance(), kurtosis_vec(), rw_range(), skewness_vec()

    diff --git a/docs/reference/euclidean_distance.html b/docs/reference/euclidean_distance.html new file mode 100644 index 0000000..ccc3f6b --- /dev/null +++ b/docs/reference/euclidean_distance.html @@ -0,0 +1,143 @@ + +Distance Calculations — euclidean_distance • RandomWalker + Skip to contents + + +
    +
    +
    + +
    +

    A function to calculate the Euclidean distance between two vectors.

    +
    + +
    +

    Usage

    +
    euclidean_distance(.data, .x, .y, .pull_vector = FALSE)
    +
    + +
    +

    Arguments

    + + +
    .data
    +

    A data frame

    + + +
    .x
    +

    A numeric vector

    + + +
    .y
    +

    A numeric vector

    + + +
    .pull_vector
    +

    A boolean of TRUE or FALSE. Default is FALSE which will +augment the distance to the data frame. TRUE will return a vector of the distances +as the return.

    + +
    +
    +

    Value

    +

    A numeric Vector of ditances

    +
    +
    +

    Details

    +

    A function to calculate the Euclidean distance between two vectors. It uses +the formula sqrt((x - lag(x))^2 + (y - lag(y))^2). The function uses augments +the data frame with a new column called distance.

    +
    +
    +

    See also

    +

    Other Vector Function: +cgmean(), +chmean(), +ckurtosis(), +cmean(), +cmedian(), +crange(), +csd(), +cskewness(), +cvar(), +kurtosis_vec(), +rw_range(), +skewness_vec()

    +
    +
    +

    Author

    +

    Steven P. Sanderson II, MPH

    +
    + +
    +

    Examples

    +
    set.seed(123)
    +df <- rw30()
    +euclidean_distance(df, x, 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
    +#> # ℹ 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
    +
    +
    +
    +
    + + +
    + + + +
    + + + + + + + diff --git a/docs/reference/index.html b/docs/reference/index.html index a952799..2a755dd 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -157,6 +157,12 @@

    Vector FunctionsCumulative Variance
    + euclidean_distance() + +
    +
    Distance Calculations
    +
    + kurtosis_vec()
    diff --git a/docs/reference/kurtosis_vec.html b/docs/reference/kurtosis_vec.html index a91e200..405ddbf 100644 --- a/docs/reference/kurtosis_vec.html +++ b/docs/reference/kurtosis_vec.html @@ -36,7 +36,7 @@
    @@ -81,6 +81,7 @@

    See alsocsd(), cskewness(), cvar(), +euclidean_distance(), rw_range(), skewness_vec()

    diff --git a/docs/reference/rw_range.html b/docs/reference/rw_range.html index bec014c..a5a158c 100644 --- a/docs/reference/rw_range.html +++ b/docs/reference/rw_range.html @@ -30,7 +30,7 @@
    @@ -72,6 +72,7 @@

    See alsocsd(), cskewness(), cvar(), +euclidean_distance(), kurtosis_vec(), skewness_vec()

    diff --git a/docs/reference/skewness_vec.html b/docs/reference/skewness_vec.html index 8f6fff2..f49d76c 100644 --- a/docs/reference/skewness_vec.html +++ b/docs/reference/skewness_vec.html @@ -36,7 +36,7 @@
    @@ -81,6 +81,7 @@

    See alsocsd(), cskewness(), cvar(), +euclidean_distance(), kurtosis_vec(), rw_range()

    diff --git a/docs/search.json b/docs/search.json index 5722a2f..6f01741 100644 --- a/docs/search.json +++ b/docs/search.json @@ -1 +1 @@ -[{"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.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Sanderson S (2024). RandomWalker: Generate Random Walks Compatible 'tidyverse'. https://www.spsanderson.com/RandomWalker/, https://github.com/spsanderson/RandomWalker.","code":"@Manual{, title = {RandomWalker: Generate Random Walks Compatible With The 'tidyverse'}, author = {Steven Sanderson}, year = {2024}, note = {https://www.spsanderson.com/RandomWalker/, https://github.com/spsanderson/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 development version RandomWalker GitHub :","code":"# 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:","code":"library(RandomWalker) ## basic example code rw30() |> head(10) #> # A tibble: 10 × 3 #> walk_number x y #> #> 1 1 1 0 #> 2 1 2 -0.821 #> 3 1 3 -0.969 #> 4 1 4 -2.08 #> 5 1 5 -3.58 #> 6 1 6 -2.50 #> 7 1 7 -4.65 #> 8 1 8 -4.68 #> 9 1 9 -5.75 #> 10 1 10 -6.49"},{"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":"library(ggplot2) set.seed(123) brownian_motion() #> # A tibble: 2,525 × 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,515 more rows set.seed(123) brownian_motion() |> ggplot(aes(x = x, y = y, group = walk_number, color = walk_number)) + geom_line() + labs(title = \"Brownian Motion\", x = \"Time\", y = \"Value\") + theme_minimal() + theme(legend.position = \"none\")"},{"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/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 = 30, .n = 250, .upper_probability = 0.55) |> ggplot(aes(x = x, y = cum_sum)) + geom_line(aes(group = walk_number), alpha = .618, color = \"steelblue\") + theme_minimal() + theme(legend.position = \"none\") + geom_smooth(method = \"lm\", se = FALSE) #> `geom_smooth()` using formula = 'y ~ x'"},{"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":"library(ggplot2) set.seed(123) geometric_brownian_motion() #> # A tibble: 2,525 × 3 #> walk_number x y #> #> 1 1 1 100 #> 2 1 2 99.7 #> 3 1 3 99.6 #> 4 1 4 100. #> 5 1 5 100. #> 6 1 6 101. #> 7 1 7 101. #> 8 1 8 102. #> 9 1 9 101. #> 10 1 10 101. #> # ℹ 2,515 more rows set.seed(123) geometric_brownian_motion() |> ggplot(aes(x = x, y = y, group = walk_number, color = walk_number)) + geom_line() + labs(title = \"Geometric Brownian Motion\", x = \"Time\", y = \"Value\") + theme_minimal() + theme(legend.position = \"none\")"},{"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 )"},{"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.","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":"library(ggplot2) set.seed(123) walks <- random_normal_drift_walk(.num_walks = 10, .n = 50, .mu = 0, .sd = 1, .drift = 0.05) #> Error in rand_walk_helper(dplyr::ungroup(dplyr::arrange(dplyr::select(dplyr::mutate(tidyr::pivot_longer(walks_tibble, cols = -x, names_to = \"walk_number\", values_to = \"y\"), walk_number = factor(walk_number, levels = 1:num_walks)), walk_number, x, y, dplyr::everything()), walk_number, x)), .value = initial_value): object 'initial_value' not found ggplot(walks, aes(x = x, y = y, group = walk_number, color = walk_number)) + geom_line() + labs(title = \"Random Walks with Drift\", x = \"Time\", y = \"Value\") + theme_minimal() + theme(legend.position = \"none\") #> Error in ggplot(walks, aes(x = x, y = y, group = walk_number, color = walk_number)): object 'walks' not found"},{"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":"# 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) |> ggplot(aes(x = x, y = y, group = walk_number, color = walk_number)) + geom_line() + labs(title = \"Random Normal Walk\", x = \"Time\", y = \"Value\") + theme_minimal() + theme(legend.position = \"none\")"},{"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":"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/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":"library(ggplot2) # 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() |> ggplot(aes(x = x, y = y, color = walk_number, group = walk_number)) + geom_line() + theme_minimal() + theme(legend.position = \"none\") + labs( title = \"30 Random Walks\", x = \"Step\", y = \"Value\", color = \"Walk Number\" )"},{"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":[]},{"path":"https://www.spsanderson.com/RandomWalker/news/index.html","id":"breaking-changes-development-version","dir":"Changelog","previous_headings":"","what":"Breaking Changes","title":"RandomWalker (development version)","text":"None","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 #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.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/news/index.html","id":"minor-improvements-and-fixes-development-version","dir":"Changelog","previous_headings":"","what":"Minor Improvements and Fixes","title":"RandomWalker (development version)","text":"None","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.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Sanderson S (2024). RandomWalker: Generate Random Walks Compatible 'tidyverse'. https://www.spsanderson.com/RandomWalker/, https://github.com/spsanderson/RandomWalker.","code":"@Manual{, title = {RandomWalker: Generate Random Walks Compatible With The 'tidyverse'}, author = {Steven Sanderson}, year = {2024}, note = {https://www.spsanderson.com/RandomWalker/, https://github.com/spsanderson/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 development version RandomWalker GitHub :","code":"# 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:","code":"library(RandomWalker) ## basic example code rw30() |> head(10) #> # A tibble: 10 × 3 #> walk_number x y #> #> 1 1 1 0 #> 2 1 2 -0.821 #> 3 1 3 -0.969 #> 4 1 4 -2.08 #> 5 1 5 -3.58 #> 6 1 6 -2.50 #> 7 1 7 -4.65 #> 8 1 8 -4.68 #> 9 1 9 -5.75 #> 10 1 10 -6.49"},{"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":"library(ggplot2) set.seed(123) brownian_motion() #> # A tibble: 2,525 × 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,515 more rows set.seed(123) brownian_motion() |> ggplot(aes(x = x, y = y, group = walk_number, color = walk_number)) + geom_line() + labs(title = \"Brownian Motion\", x = \"Time\", y = \"Value\") + theme_minimal() + theme(legend.position = \"none\")"},{"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/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 = 30, .n = 250, .upper_probability = 0.55) |> ggplot(aes(x = x, y = cum_sum)) + geom_line(aes(group = walk_number), alpha = .618, color = \"steelblue\") + theme_minimal() + theme(legend.position = \"none\") + geom_smooth(method = \"lm\", se = FALSE) #> `geom_smooth()` using formula = 'y ~ x'"},{"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/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":"library(ggplot2) set.seed(123) geometric_brownian_motion() #> # A tibble: 2,525 × 3 #> walk_number x y #> #> 1 1 1 100 #> 2 1 2 99.7 #> 3 1 3 99.6 #> 4 1 4 100. #> 5 1 5 100. #> 6 1 6 101. #> 7 1 7 101. #> 8 1 8 102. #> 9 1 9 101. #> 10 1 10 101. #> # ℹ 2,515 more rows set.seed(123) geometric_brownian_motion() |> ggplot(aes(x = x, y = y, group = walk_number, color = walk_number)) + geom_line() + labs(title = \"Geometric Brownian Motion\", x = \"Time\", y = \"Value\") + theme_minimal() + theme(legend.position = \"none\")"},{"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 )"},{"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.","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":"library(ggplot2) set.seed(123) walks <- random_normal_drift_walk(.num_walks = 10, .n = 50, .mu = 0, .sd = 1, .drift = 0.05) #> Error in rand_walk_helper(dplyr::ungroup(dplyr::arrange(dplyr::select(dplyr::mutate(tidyr::pivot_longer(walks_tibble, cols = -x, names_to = \"walk_number\", values_to = \"y\"), walk_number = factor(walk_number, levels = 1:num_walks)), walk_number, x, y, dplyr::everything()), walk_number, x)), .value = initial_value): object 'initial_value' not found ggplot(walks, aes(x = x, y = y, group = walk_number, color = walk_number)) + geom_line() + labs(title = \"Random Walks with Drift\", x = \"Time\", y = \"Value\") + theme_minimal() + theme(legend.position = \"none\") #> Error in ggplot(walks, aes(x = x, y = y, group = walk_number, color = walk_number)): object 'walks' not found"},{"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":"# 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) |> ggplot(aes(x = x, y = y, group = walk_number, color = walk_number)) + geom_line() + labs(title = \"Random Normal Walk\", x = \"Time\", y = \"Value\") + theme_minimal() + theme(legend.position = \"none\")"},{"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":"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/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":"library(ggplot2) # 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() |> ggplot(aes(x = x, y = y, color = walk_number, group = walk_number)) + geom_line() + theme_minimal() + theme(legend.position = \"none\") + labs( title = \"30 Random Walks\", x = \"Step\", y = \"Value\", color = \"Walk Number\" )"},{"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":[]},{"path":"https://www.spsanderson.com/RandomWalker/news/index.html","id":"breaking-changes-development-version","dir":"Changelog","previous_headings":"","what":"Breaking Changes","title":"RandomWalker (development version)","text":"None","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 #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.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/news/index.html","id":"minor-improvements-and-fixes-development-version","dir":"Changelog","previous_headings":"","what":"Minor Improvements and Fixes","title":"RandomWalker (development version)","text":"None","code":""}] diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 66dfe66..ad3d1eb 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -18,6 +18,7 @@ https://www.spsanderson.com/RandomWalker/reference/cskewness.html https://www.spsanderson.com/RandomWalker/reference/cvar.html https://www.spsanderson.com/RandomWalker/reference/discrete_walk.html +https://www.spsanderson.com/RandomWalker/reference/euclidean_distance.html https://www.spsanderson.com/RandomWalker/reference/geometric_brownian_motion.html https://www.spsanderson.com/RandomWalker/reference/index.html https://www.spsanderson.com/RandomWalker/reference/internal_rand_walk_helper.html diff --git a/man/cgmean.Rd b/man/cgmean.Rd index 17dad71..226fc81 100644 --- a/man/cgmean.Rd +++ b/man/cgmean.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/vec-functions.R +% Please edit documentation in R/vec-cumulative-functions.R \name{cgmean} \alias{cgmean} \title{Cumulative Geometric Mean} @@ -35,6 +35,7 @@ Other Vector Function: \code{\link{csd}()}, \code{\link{cskewness}()}, \code{\link{cvar}()}, +\code{\link{euclidean_distance}()}, \code{\link{kurtosis_vec}()}, \code{\link{rw_range}()}, \code{\link{skewness_vec}()} diff --git a/man/chmean.Rd b/man/chmean.Rd index f3e4c01..d9cb331 100644 --- a/man/chmean.Rd +++ b/man/chmean.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/vec-functions.R +% Please edit documentation in R/vec-cumulative-functions.R \name{chmean} \alias{chmean} \title{Cumulative Harmonic Mean} @@ -35,6 +35,7 @@ Other Vector Function: \code{\link{csd}()}, \code{\link{cskewness}()}, \code{\link{cvar}()}, +\code{\link{euclidean_distance}()}, \code{\link{kurtosis_vec}()}, \code{\link{rw_range}()}, \code{\link{skewness_vec}()} diff --git a/man/ckurtosis.Rd b/man/ckurtosis.Rd index 7c60cbf..8593dbe 100644 --- a/man/ckurtosis.Rd +++ b/man/ckurtosis.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/vec-functions.R +% Please edit documentation in R/vec-cumulative-functions.R \name{ckurtosis} \alias{ckurtosis} \title{Cumulative Kurtosis} @@ -34,6 +34,7 @@ Other Vector Function: \code{\link{csd}()}, \code{\link{cskewness}()}, \code{\link{cvar}()}, +\code{\link{euclidean_distance}()}, \code{\link{kurtosis_vec}()}, \code{\link{rw_range}()}, \code{\link{skewness_vec}()} diff --git a/man/cmean.Rd b/man/cmean.Rd index a2bbfce..d154d6b 100644 --- a/man/cmean.Rd +++ b/man/cmean.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/vec-functions.R +% Please edit documentation in R/vec-cumulative-functions.R \name{cmean} \alias{cmean} \title{Cumulative Mean} @@ -35,6 +35,7 @@ Other Vector Function: \code{\link{csd}()}, \code{\link{cskewness}()}, \code{\link{cvar}()}, +\code{\link{euclidean_distance}()}, \code{\link{kurtosis_vec}()}, \code{\link{rw_range}()}, \code{\link{skewness_vec}()} diff --git a/man/cmedian.Rd b/man/cmedian.Rd index 151f291..4b67bcc 100644 --- a/man/cmedian.Rd +++ b/man/cmedian.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/vec-functions.R +% Please edit documentation in R/vec-cumulative-functions.R \name{cmedian} \alias{cmedian} \title{Cumulative Median} @@ -34,6 +34,7 @@ Other Vector Function: \code{\link{csd}()}, \code{\link{cskewness}()}, \code{\link{cvar}()}, +\code{\link{euclidean_distance}()}, \code{\link{kurtosis_vec}()}, \code{\link{rw_range}()}, \code{\link{skewness_vec}()} diff --git a/man/crange.Rd b/man/crange.Rd index 6d73dab..9e73a4a 100644 --- a/man/crange.Rd +++ b/man/crange.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/vec-functions.R +% Please edit documentation in R/vec-cumulative-functions.R \name{crange} \alias{crange} \title{Cumulative Range} @@ -36,6 +36,7 @@ Other Vector Function: \code{\link{csd}()}, \code{\link{cskewness}()}, \code{\link{cvar}()}, +\code{\link{euclidean_distance}()}, \code{\link{kurtosis_vec}()}, \code{\link{rw_range}()}, \code{\link{skewness_vec}()} diff --git a/man/csd.Rd b/man/csd.Rd index fad2d6d..fb7f703 100644 --- a/man/csd.Rd +++ b/man/csd.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/vec-functions.R +% Please edit documentation in R/vec-cumulative-functions.R \name{csd} \alias{csd} \title{Cumulative Standard Deviation} @@ -35,6 +35,7 @@ Other Vector Function: \code{\link{crange}()}, \code{\link{cskewness}()}, \code{\link{cvar}()}, +\code{\link{euclidean_distance}()}, \code{\link{kurtosis_vec}()}, \code{\link{rw_range}()}, \code{\link{skewness_vec}()} diff --git a/man/cskewness.Rd b/man/cskewness.Rd index 035021d..b524482 100644 --- a/man/cskewness.Rd +++ b/man/cskewness.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/vec-functions.R +% Please edit documentation in R/vec-cumulative-functions.R \name{cskewness} \alias{cskewness} \title{Cumulative Skewness} @@ -34,6 +34,7 @@ Other Vector Function: \code{\link{crange}()}, \code{\link{csd}()}, \code{\link{cvar}()}, +\code{\link{euclidean_distance}()}, \code{\link{kurtosis_vec}()}, \code{\link{rw_range}()}, \code{\link{skewness_vec}()} diff --git a/man/cvar.Rd b/man/cvar.Rd index 8e479b9..830f0e7 100644 --- a/man/cvar.Rd +++ b/man/cvar.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/vec-functions.R +% Please edit documentation in R/vec-cumulative-functions.R \name{cvar} \alias{cvar} \title{Cumulative Variance} @@ -36,6 +36,7 @@ Other Vector Function: \code{\link{crange}()}, \code{\link{csd}()}, \code{\link{cskewness}()}, +\code{\link{euclidean_distance}()}, \code{\link{kurtosis_vec}()}, \code{\link{rw_range}()}, \code{\link{skewness_vec}()} diff --git a/man/euclidean_distance.Rd b/man/euclidean_distance.Rd new file mode 100644 index 0000000..03386d0 --- /dev/null +++ b/man/euclidean_distance.Rd @@ -0,0 +1,56 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/vec-distance.R +\name{euclidean_distance} +\alias{euclidean_distance} +\title{Distance Calculations} +\usage{ +euclidean_distance(.data, .x, .y, .pull_vector = FALSE) +} +\arguments{ +\item{.data}{A data frame} + +\item{.x}{A numeric vector} + +\item{.y}{A numeric vector} + +\item{.pull_vector}{A boolean of TRUE or FALSE. Default is FALSE which will +augment the distance to the data frame. TRUE will return a vector of the distances +as the return.} +} +\value{ +A numeric Vector of ditances +} +\description{ +A function to calculate the Euclidean distance between two vectors. +} +\details{ +A function to calculate the Euclidean distance between two vectors. It uses +the formula \code{sqrt((x - lag(x))^2 + (y - lag(y))^2)}. The function uses augments +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) + +} +\seealso{ +Other Vector Function: +\code{\link{cgmean}()}, +\code{\link{chmean}()}, +\code{\link{ckurtosis}()}, +\code{\link{cmean}()}, +\code{\link{cmedian}()}, +\code{\link{crange}()}, +\code{\link{csd}()}, +\code{\link{cskewness}()}, +\code{\link{cvar}()}, +\code{\link{kurtosis_vec}()}, +\code{\link{rw_range}()}, +\code{\link{skewness_vec}()} +} +\author{ +Steven P. Sanderson II, MPH +} +\concept{Vector Function} diff --git a/man/kurtosis_vec.Rd b/man/kurtosis_vec.Rd index 0abb2d9..c6ac6aa 100644 --- a/man/kurtosis_vec.Rd +++ b/man/kurtosis_vec.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/vec-functions.R +% Please edit documentation in R/vec-cumulative-functions.R \name{kurtosis_vec} \alias{kurtosis_vec} \title{Compute Kurtosis of a Vector} @@ -40,6 +40,7 @@ Other Vector Function: \code{\link{csd}()}, \code{\link{cskewness}()}, \code{\link{cvar}()}, +\code{\link{euclidean_distance}()}, \code{\link{rw_range}()}, \code{\link{skewness_vec}()} } diff --git a/man/rw_range.Rd b/man/rw_range.Rd index 9d6d0e1..f348533 100644 --- a/man/rw_range.Rd +++ b/man/rw_range.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/vec-functions.R +% Please edit documentation in R/vec-cumulative-functions.R \name{rw_range} \alias{rw_range} \title{Range} @@ -36,6 +36,7 @@ Other Vector Function: \code{\link{csd}()}, \code{\link{cskewness}()}, \code{\link{cvar}()}, +\code{\link{euclidean_distance}()}, \code{\link{kurtosis_vec}()}, \code{\link{skewness_vec}()} } diff --git a/man/skewness_vec.Rd b/man/skewness_vec.Rd index 02a7d4f..0fb5444 100644 --- a/man/skewness_vec.Rd +++ b/man/skewness_vec.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/vec-functions.R +% Please edit documentation in R/vec-cumulative-functions.R \name{skewness_vec} \alias{skewness_vec} \title{Compute Skewness of a Vector} @@ -40,6 +40,7 @@ Other Vector Function: \code{\link{csd}()}, \code{\link{cskewness}()}, \code{\link{cvar}()}, +\code{\link{euclidean_distance}()}, \code{\link{kurtosis_vec}()}, \code{\link{rw_range}()} }