diff --git a/NAMESPACE b/NAMESPACE index b1f7d2d..b5db2eb 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -12,6 +12,7 @@ export(cskewness) export(cvar) export(discrete_walk) export(geometric_brownian_motion) +export(internal_rand_walk_helper) export(kurtosis_vec) export(random_normal_drift_walk) export(random_normal_walk) diff --git a/NEWS.md b/NEWS.md index 6631fe3..a20f350 100644 --- a/NEWS.md +++ b/NEWS.md @@ -10,6 +10,9 @@ None 4. Fix #16 - Add Function `brownian_motion()` to generate Brownian Motion 5. Fix #13 - Add Function `random_normal_walk()` to generate Random Walk 6. Fix #30 - Add Function `discrete_walk()` to generate Discrete Random Walk +7. Fix #43 - Add vectorized functions +8. Fix #44 - Add Function `internal_rand_walk_helper()` to help generate common +columns for random walks. ## Minor Improvements and Fixes None diff --git a/R/gen-geom-brown-motion.R b/R/gen-brown-motion-geometric.R similarity index 100% rename from R/gen-geom-brown-motion.R rename to R/gen-brown-motion-geometric.R diff --git a/R/gen-discrete-walk.R b/R/gen-discrete-walk.R index cfde65e..bff5cb8 100644 --- a/R/gen-discrete-walk.R +++ b/R/gen-discrete-walk.R @@ -69,7 +69,7 @@ discrete_walk <- function(.num_walks = 25, .n = 100, .upper_bound = 1, x = c(upper_bound, lower_bound), size = 1, prob = c(upper_probability, lower_probability)) - ) + ) ) |> dplyr::mutate(cum_sum = initial_value + cumsum(y)) |> dplyr::mutate(cum_prod = initial_value * cumprod(1 + y)) |> diff --git a/R/gen-random-drift-walk.R b/R/gen-random-normal-walk-drift.R similarity index 100% rename from R/gen-random-drift-walk.R rename to R/gen-random-normal-walk-drift.R diff --git a/R/helpers.R b/R/helpers.R new file mode 100644 index 0000000..5a7b027 --- /dev/null +++ b/R/helpers.R @@ -0,0 +1,60 @@ +#' Random Walk Helper +#' +#' @family Helper Functions +#' +#' @author Steven P. Sanderson II, MPH +#' +#' @details +#' A function to help build random walks by mutating a data frame. This mutation +#' adds the following columns to the data frame: `cum_sum`, `cum_prod`, `cum_min`, +#' `cum_max`, and `cum_mean`. The function is used internally by certain functions +#' that generate random walks. +#' +#' @description +#' A function to help build random walks by mutating a data frame. +#' +#' @param .data The data frame to mutate. +#' @param .value The .initial_value to use. This is passed from the random walk +#' function being called by the end user. +#' +#' @examples +#' df <- tibble( +#' walk_number = factor(rep(1L:25L, each = 30L)), +#' x = rep(1L:30L, 25L), +#' y = rnorm(750L, 0L, 1L) +#' ) +#' +#' internal_rand_walk_helper(df, 100) +#' +#' @return +#' A modified data frame/tibble with the following columns added: +#' \itemize{ +#' \item `cum_sum`: Cumulative sum of `y`. +#' \item `cum_prod`: Cumulative product of `y`. +#' \item `cum_min`: Cumulative minimum of `y`. +#' \item `cum_max`: Cumulative maximum of `y`. +#' \item `cum_mean`: Cumulative mean of `y`. +#' } +#' +#' @name internal_rand_walk_helper +NULL +#' @rdname internal_rand_walk_helper +#' @export + +internal_rand_walk_helper <- function(.data, .value) { + + value = as.numeric(.value) + + df <- .data |> + dplyr::group_by(walk_number) |> + dplyr::mutate( + cum_sum = initial_value + cumsum(y), + cum_prod = initial_value * cumprod(1 + y), + cum_min = initial_value + cummin(y), + cum_max = initial_value + cummax(y), + cum_mean = initial_value + cmean(y) + ) |> + dplyr::ungroup() + + return(df) +} diff --git a/R/vec-functions.R b/R/vec-functions.R index a04253b..f57921b 100644 --- a/R/vec-functions.R +++ b/R/vec-functions.R @@ -338,7 +338,7 @@ rw_range <- function(.x) { #' @return #' A numeric vector #' -#' @name name +#' @name crange NULL #' @rdname crange #' @export diff --git a/_pkgdown.yml b/_pkgdown.yml index c99b84b..5ef5042 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -30,5 +30,9 @@ reference: desc: Functions that generate random walks in vector form contents: - has_concept("Vector Function") + - title: Helpers + desc: Functions that help with random walks + contents: + - has_concept("Helper Functions") search: diff --git a/docs/news/index.html b/docs/news/index.html index 6d2226d..61b52dc 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -47,6 +47,8 @@

New FeaturesFix #16 - Add Function brownian_motion() to generate Brownian Motion
  • Fix #13 - Add Function random_normal_walk() to generate Random Walk
  • Fix #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.
  • Minor Improvements and Fixes

    diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 26bdc6d..7635231 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-29T14:42Z +last_built: 2024-07-29T16:17Z 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 b20529f..f2831e7 100644 --- a/docs/reference/cgmean.html +++ b/docs/reference/cgmean.html @@ -67,11 +67,11 @@

    See alsockurtosis(), cmean(), cmedian(), +crange(), csd(), cskewness(), cvar(), kurtosis_vec(), -name, rw_range(), skewness_vec()

    diff --git a/docs/reference/chmean.html b/docs/reference/chmean.html index ef12c4f..cc82fbb 100644 --- a/docs/reference/chmean.html +++ b/docs/reference/chmean.html @@ -67,11 +67,11 @@

    See alsockurtosis(), cmean(), cmedian(), +crange(), csd(), cskewness(), cvar(), kurtosis_vec(), -name, rw_range(), skewness_vec()

    diff --git a/docs/reference/ckurtosis.html b/docs/reference/ckurtosis.html index 5cf3c61..2167caf 100644 --- a/docs/reference/ckurtosis.html +++ b/docs/reference/ckurtosis.html @@ -66,11 +66,11 @@

    See alsochmean(), cmean(), cmedian(), +crange(), csd(), cskewness(), cvar(), kurtosis_vec(), -name, rw_range(), skewness_vec()

    diff --git a/docs/reference/cmean.html b/docs/reference/cmean.html index 990fe3d..0e8a3e2 100644 --- a/docs/reference/cmean.html +++ b/docs/reference/cmean.html @@ -67,11 +67,11 @@

    See alsochmean(), ckurtosis(), cmedian(), +crange(), csd(), cskewness(), cvar(), kurtosis_vec(), -name, rw_range(), skewness_vec()

    diff --git a/docs/reference/cmedian.html b/docs/reference/cmedian.html index 63e31b0..1db6602 100644 --- a/docs/reference/cmedian.html +++ b/docs/reference/cmedian.html @@ -66,11 +66,11 @@

    See alsochmean(), ckurtosis(), cmean(), +crange(), csd(), cskewness(), cvar(), kurtosis_vec(), -name, rw_range(), skewness_vec()

    diff --git a/docs/reference/crange.html b/docs/reference/crange.html new file mode 100644 index 0000000..23c9132 --- /dev/null +++ b/docs/reference/crange.html @@ -0,0 +1,114 @@ + +Cumulative Range — crange • RandomWalker + Skip to contents + + +
    +
    +
    + +
    +

    A function to return the cumulative range of a vector.

    +
    + +
    +

    Usage

    +
    crange(.x)
    +
    + +
    +

    Arguments

    + + +
    .x
    +

    A numeric vector

    + +
    +
    +

    Value

    +

    A numeric vector

    +
    +
    +

    Details

    +

    A function to return the cumulative range of a vector. It uses max(.x[1:k]) - min(.x[1:k]) as +the basis of the function.

    +
    +
    +

    See also

    +

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

    +
    +
    +

    Author

    +

    Steven P. Sanderson II, MPH

    +
    + +
    +

    Examples

    +
    
    +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
    +
    +
    +
    +
    + + +
    + + + + + + + diff --git a/docs/reference/csd.html b/docs/reference/csd.html index a4ee7eb..866a778 100644 --- a/docs/reference/csd.html +++ b/docs/reference/csd.html @@ -68,10 +68,10 @@

    See alsockurtosis(), cmean(), cmedian(), +crange(), cskewness(), cvar(), kurtosis_vec(), -name, rw_range(), skewness_vec()

    diff --git a/docs/reference/cskewness.html b/docs/reference/cskewness.html index 52484f9..ae94ab5 100644 --- a/docs/reference/cskewness.html +++ b/docs/reference/cskewness.html @@ -67,10 +67,10 @@

    See alsockurtosis(), cmean(), cmedian(), +crange(), csd(), cvar(), kurtosis_vec(), -name, rw_range(), skewness_vec()

    diff --git a/docs/reference/cvar.html b/docs/reference/cvar.html index 1a4e0f6..1e1c142 100644 --- a/docs/reference/cvar.html +++ b/docs/reference/cvar.html @@ -69,10 +69,10 @@

    See alsockurtosis(), cmean(), cmedian(), +crange(), csd(), cskewness(), kurtosis_vec(), -name, rw_range(), skewness_vec()

    diff --git a/docs/reference/geometric_brownian_motion.html b/docs/reference/geometric_brownian_motion.html index 42f231e..005281e 100644 --- a/docs/reference/geometric_brownian_motion.html +++ b/docs/reference/geometric_brownian_motion.html @@ -30,7 +30,7 @@
    diff --git a/docs/reference/index.html b/docs/reference/index.html index ac7ecba..b6c9fb8 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -133,6 +133,12 @@

    Vector FunctionsCumulative Median
    + crange() + +
    +
    Cumulative Range
    +
    + csd()
    @@ -157,12 +163,6 @@

    Vector FunctionsCompute Kurtosis of a Vector

    - name - -
    -
    Cumulative Range
    -
    - rw_range()
    @@ -173,6 +173,23 @@

    Vector Functions
    Compute Skewness of a Vector
    +

    +

    Helpers

    + +

    Functions that help with random walks

    + + +
    + + + + +
    + + internal_rand_walk_helper() + +
    +
    Random Walk Helper
    diff --git a/docs/reference/internal_rand_walk_helper.html b/docs/reference/internal_rand_walk_helper.html new file mode 100644 index 0000000..4104d77 --- /dev/null +++ b/docs/reference/internal_rand_walk_helper.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/reference/kurtosis_vec.html b/docs/reference/kurtosis_vec.html index 60471ae..a91e200 100644 --- a/docs/reference/kurtosis_vec.html +++ b/docs/reference/kurtosis_vec.html @@ -77,10 +77,10 @@

    See alsockurtosis(), cmean(), cmedian(), +crange(), csd(), cskewness(), cvar(), -name, rw_range(), skewness_vec()

    @@ -91,8 +91,9 @@

    Author<

    Examples

    -
    kurtosis_vec(rnorm(100, 3, 2))
    -#> [1] 3.075538
    +    
    set.seed(123)
    +kurtosis_vec(rnorm(100, 3, 2))
    +#> [1] 2.838947
     
     
    diff --git a/docs/reference/random_normal_drift_walk-1.png b/docs/reference/random_normal_drift_walk-1.png index 410d3d1..6495f24 100644 Binary files a/docs/reference/random_normal_drift_walk-1.png and b/docs/reference/random_normal_drift_walk-1.png differ diff --git a/docs/reference/random_normal_drift_walk.html b/docs/reference/random_normal_drift_walk.html index ceffb86..e8ffb8a 100644 --- a/docs/reference/random_normal_drift_walk.html +++ b/docs/reference/random_normal_drift_walk.html @@ -38,7 +38,7 @@
    diff --git a/docs/reference/random_normal_walk-1.png b/docs/reference/random_normal_walk-1.png index 327cda7..fe1ac23 100644 Binary files a/docs/reference/random_normal_walk-1.png and b/docs/reference/random_normal_walk-1.png differ diff --git a/docs/reference/random_normal_walk.html b/docs/reference/random_normal_walk.html index ee44171..15f348b 100644 --- a/docs/reference/random_normal_walk.html +++ b/docs/reference/random_normal_walk.html @@ -134,35 +134,35 @@

    Examples
    # Generate 10 random walks with 50 steps each
     random_normal_walk(.num_walks = 10, .n = 50)
     #> # A tibble: 400 × 7
    -#>    walk_number     x       y cum_sum cum_prod cum_min cum_max
    -#>    <fct>       <int>   <dbl>   <dbl>    <dbl>   <dbl>   <dbl>
    -#>  1 1               1  0.0209  0.0209        0  0.0209  0.0209
    -#>  2 1               2 -0.0625 -0.0416        0 -0.0625  0.0209
    -#>  3 1               3  0.0621  0.0205        0 -0.0625  0.0621
    -#>  4 1               4 -0.0626 -0.0421        0 -0.0626  0.0621
    -#>  5 1               5  0.0209 -0.0212        0 -0.0626  0.0621
    -#>  6 1               6  0.162   0.141         0 -0.0626  0.162 
    -#>  7 1               7 -0.0522  0.0888        0 -0.0626  0.162 
    -#>  8 1               8 -0.0625  0.0263        0 -0.0626  0.162 
    -#>  9 1               9 -0.107  -0.0812        0 -0.107   0.162 
    -#> 10 1              10  0.0533 -0.0279        0 -0.107   0.162 
    +#>    walk_number     x        y cum_sum cum_prod cum_min  cum_max
    +#>    <fct>       <int>    <dbl>   <dbl>    <dbl>   <dbl>    <dbl>
    +#>  1 1               1 -0.157    -0.157        0  -0.157 -0.157  
    +#>  2 1               2 -0.0625   -0.219        0  -0.157 -0.0625 
    +#>  3 1               3 -0.0191   -0.238        0  -0.157 -0.0191 
    +#>  4 1               4 -0.00702  -0.245        0  -0.157 -0.00702
    +#>  5 1               5  0.140    -0.106        0  -0.157  0.140  
    +#>  6 1               6 -0.0982   -0.204        0  -0.157  0.140  
    +#>  7 1               7  0.0161   -0.188        0  -0.157  0.140  
    +#>  8 1               8 -0.140    -0.328        0  -0.157  0.140  
    +#>  9 1               9 -0.0274   -0.355        0  -0.157  0.140  
    +#> 10 1              10  0.0161   -0.339        0  -0.157  0.140  
     #> # ℹ 390 more rows
     
     # Generate random walks with different mean and standard deviation
     random_normal_walk(.num_walks = 10, .n = 50, .samp = FALSE)
     #> # A tibble: 500 × 7
    -#>    walk_number     x        y  cum_sum cum_prod  cum_min cum_max
    -#>    <fct>       <int>    <dbl>    <dbl>    <dbl>    <dbl>   <dbl>
    -#>  1 1               1  0.00633  0.00633        0  0.00633 0.00633
    -#>  2 1               2  0.0805   0.0869         0  0.00633 0.0805 
    -#>  3 1               3  0.0968   0.184          0  0.00633 0.0968 
    -#>  4 1               4 -0.0597   0.124          0 -0.0597  0.0968 
    -#>  5 1               5 -0.0661   0.0579         0 -0.0661  0.0968 
    -#>  6 1               6 -0.136   -0.0777         0 -0.136   0.0968 
    -#>  7 1               7 -0.283   -0.361          0 -0.283   0.0968 
    -#>  8 1               8  0.00198 -0.359          0 -0.283   0.0968 
    -#>  9 1               9 -0.114   -0.473          0 -0.283   0.0968 
    -#> 10 1              10 -0.0823  -0.555          0 -0.283   0.0968 
    +#>    walk_number     x       y   cum_sum cum_prod cum_min cum_max
    +#>    <fct>       <int>   <dbl>     <dbl>    <dbl>   <dbl>   <dbl>
    +#>  1 1               1  0.0432  0.0432          0  0.0432  0.0432
    +#>  2 1               2 -0.124  -0.0808          0 -0.124   0.0432
    +#>  3 1               3  0.150   0.0688          0 -0.124   0.150 
    +#>  4 1               4  0.0159  0.0848          0 -0.124   0.150 
    +#>  5 1               5 -0.0856 -0.000845        0 -0.124   0.150 
    +#>  6 1               6  0.0309  0.0301          0 -0.124   0.150 
    +#>  7 1               7  0.0870  0.117           0 -0.124   0.150 
    +#>  8 1               8 -0.138  -0.0213          0 -0.138   0.150 
    +#>  9 1               9  0.169   0.148           0 -0.138   0.169 
    +#> 10 1              10 -0.0158  0.132           0 -0.138   0.169 
     #> # ℹ 490 more rows
     
     random_normal_walk(.num_walks = 2, .n = 100) |>
    diff --git a/docs/reference/rw30-1.png b/docs/reference/rw30-1.png
    index 134c65f..d251a70 100644
    Binary files a/docs/reference/rw30-1.png and b/docs/reference/rw30-1.png differ
    diff --git a/docs/reference/rw30.html b/docs/reference/rw30.html
    index d56585a..0400826 100644
    --- a/docs/reference/rw30.html
    +++ b/docs/reference/rw30.html
    @@ -73,15 +73,15 @@ 

    Examples#> walk_number x y #> <fct> <int> <dbl> #> 1 1 1 0 -#> 2 1 2 -0.141 -#> 3 1 3 -0.144 -#> 4 1 4 -0.464 -#> 5 1 5 -0.886 -#> 6 1 6 -1.07 -#> 7 1 7 -1.82 -#> 8 1 8 -1.63 -#> 9 1 9 -1.28 -#> 10 1 10 -1.20 +#> 2 1 2 0.572 +#> 3 1 3 -1.14 +#> 4 1 4 -0.788 +#> 5 1 5 -0.683 +#> 6 1 6 -3.15 +#> 7 1 7 -3.19 +#> 8 1 8 -3.78 +#> 9 1 9 -4.67 +#> 10 1 10 -4.43 #> # ℹ 2,990 more rows rw30() |> diff --git a/docs/reference/rw_range.html b/docs/reference/rw_range.html index ba410e0..bec014c 100644 --- a/docs/reference/rw_range.html +++ b/docs/reference/rw_range.html @@ -68,11 +68,11 @@

    See alsockurtosis(), cmean(), cmedian(), +crange(), csd(), cskewness(), cvar(), kurtosis_vec(), -name, skewness_vec()

    diff --git a/docs/reference/skewness_vec.html b/docs/reference/skewness_vec.html index 6dced7d..8f6fff2 100644 --- a/docs/reference/skewness_vec.html +++ b/docs/reference/skewness_vec.html @@ -77,11 +77,11 @@

    See alsockurtosis(), cmean(), cmedian(), +crange(), csd(), cskewness(), cvar(), kurtosis_vec(), -name, rw_range()

    @@ -91,8 +91,9 @@

    Author<

    Examples

    -
    skewness_vec(rnorm(100, 3, 2))
    -#> [1] -0.0218902
    +    
    set.seed(123)
    +skewness_vec(rnorm(100, 3, 2))
    +#> [1] 0.06049948
     
     
    diff --git a/docs/search.json b/docs/search.json index 402af05..becdaf6 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) brownian_motion() #> # A tibble: 2,525 × 3 #> walk_number x y #> #> 1 1 1 0 #> 2 1 2 -1.40 #> 3 1 3 -1.14 #> 4 1 4 -3.58 #> 5 1 5 -3.59 #> 6 1 6 -2.97 #> 7 1 7 -1.82 #> 8 1 8 -3.64 #> 9 1 9 -3.89 #> 10 1 10 -4.13 #> # ℹ 2,515 more rows 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/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) discrete_walk() #> # A tibble: 2,500 × 7 #> walk_number x y cum_sum cum_prod cum_min cum_max #> #> 1 1 1 1 101 200 101 101 #> 2 1 2 -1 100 0 99 101 #> 3 1 3 -1 99 0 99 101 #> 4 1 4 1 100 0 99 101 #> 5 1 5 -1 99 0 99 101 #> 6 1 6 -1 98 0 99 101 #> 7 1 7 -1 97 0 99 101 #> 8 1 8 1 98 0 99 101 #> 9 1 9 1 99 0 99 101 #> 10 1 10 1 100 0 99 101 #> # ℹ 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) geometric_brownian_motion() #> # A tibble: 2,525 × 3 #> walk_number x y #> #> 1 1 1 100 #> 2 1 2 99.2 #> 3 1 3 99.8 #> 4 1 4 100. #> 5 1 5 100. #> 6 1 6 100. #> 7 1 7 100. #> 8 1 8 101. #> 9 1 9 99.7 #> 10 1 10 100. #> # ℹ 2,515 more rows 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":"kurtosis_vec(rnorm(100, 3, 2)) #> [1] 3.075538"},{"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) walks <- random_normal_drift_walk(.num_walks = 10, .n = 50, .mu = 0, .sd = 1, .drift = 0.05) 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\")"},{"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 random_normal_walk(.num_walks = 10, .n = 50) #> # A tibble: 400 × 7 #> walk_number x y cum_sum cum_prod cum_min cum_max #> #> 1 1 1 0.0209 0.0209 0 0.0209 0.0209 #> 2 1 2 -0.0625 -0.0416 0 -0.0625 0.0209 #> 3 1 3 0.0621 0.0205 0 -0.0625 0.0621 #> 4 1 4 -0.0626 -0.0421 0 -0.0626 0.0621 #> 5 1 5 0.0209 -0.0212 0 -0.0626 0.0621 #> 6 1 6 0.162 0.141 0 -0.0626 0.162 #> 7 1 7 -0.0522 0.0888 0 -0.0626 0.162 #> 8 1 8 -0.0625 0.0263 0 -0.0626 0.162 #> 9 1 9 -0.107 -0.0812 0 -0.107 0.162 #> 10 1 10 0.0533 -0.0279 0 -0.107 0.162 #> # ℹ 390 more rows # Generate random walks with different mean and standard deviation random_normal_walk(.num_walks = 10, .n = 50, .samp = FALSE) #> # A tibble: 500 × 7 #> walk_number x y cum_sum cum_prod cum_min cum_max #> #> 1 1 1 0.00633 0.00633 0 0.00633 0.00633 #> 2 1 2 0.0805 0.0869 0 0.00633 0.0805 #> 3 1 3 0.0968 0.184 0 0.00633 0.0968 #> 4 1 4 -0.0597 0.124 0 -0.0597 0.0968 #> 5 1 5 -0.0661 0.0579 0 -0.0661 0.0968 #> 6 1 6 -0.136 -0.0777 0 -0.136 0.0968 #> 7 1 7 -0.283 -0.361 0 -0.283 0.0968 #> 8 1 8 0.00198 -0.359 0 -0.283 0.0968 #> 9 1 9 -0.114 -0.473 0 -0.283 0.0968 #> 10 1 10 -0.0823 -0.555 0 -0.283 0.0968 #> # ℹ 490 more rows 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/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 rw30() #> # A tibble: 3,000 × 3 #> walk_number x y #> #> 1 1 1 0 #> 2 1 2 -0.141 #> 3 1 3 -0.144 #> 4 1 4 -0.464 #> 5 1 5 -0.886 #> 6 1 6 -1.07 #> 7 1 7 -1.82 #> 8 1 8 -1.63 #> 9 1 9 -1.28 #> 10 1 10 -1.20 #> # ℹ 2,990 more rows 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":"skewness_vec(rnorm(100, 3, 2)) #> [1] -0.0218902"},{"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","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) brownian_motion() #> # A tibble: 2,525 × 3 #> walk_number x y #> #> 1 1 1 0 #> 2 1 2 -1.40 #> 3 1 3 -1.14 #> 4 1 4 -3.58 #> 5 1 5 -3.59 #> 6 1 6 -2.97 #> 7 1 7 -1.82 #> 8 1 8 -3.64 #> 9 1 9 -3.89 #> 10 1 10 -4.13 #> # ℹ 2,515 more rows 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) discrete_walk() #> # A tibble: 2,500 × 7 #> walk_number x y cum_sum cum_prod cum_min cum_max #> #> 1 1 1 1 101 200 101 101 #> 2 1 2 -1 100 0 99 101 #> 3 1 3 -1 99 0 99 101 #> 4 1 4 1 100 0 99 101 #> 5 1 5 -1 99 0 99 101 #> 6 1 6 -1 98 0 99 101 #> 7 1 7 -1 97 0 99 101 #> 8 1 8 1 98 0 99 101 #> 9 1 9 1 99 0 99 101 #> 10 1 10 1 100 0 99 101 #> # ℹ 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) geometric_brownian_motion() #> # A tibble: 2,525 × 3 #> walk_number x y #> #> 1 1 1 100 #> 2 1 2 99.2 #> 3 1 3 99.8 #> 4 1 4 100. #> 5 1 5 100. #> 6 1 6 100. #> 7 1 7 100. #> 8 1 8 101. #> 9 1 9 99.7 #> 10 1 10 100. #> # ℹ 2,515 more rows 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) walks <- random_normal_drift_walk(.num_walks = 10, .n = 50, .mu = 0, .sd = 1, .drift = 0.05) 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\")"},{"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 random_normal_walk(.num_walks = 10, .n = 50) #> # A tibble: 400 × 7 #> walk_number x y cum_sum cum_prod cum_min cum_max #> #> 1 1 1 -0.157 -0.157 0 -0.157 -0.157 #> 2 1 2 -0.0625 -0.219 0 -0.157 -0.0625 #> 3 1 3 -0.0191 -0.238 0 -0.157 -0.0191 #> 4 1 4 -0.00702 -0.245 0 -0.157 -0.00702 #> 5 1 5 0.140 -0.106 0 -0.157 0.140 #> 6 1 6 -0.0982 -0.204 0 -0.157 0.140 #> 7 1 7 0.0161 -0.188 0 -0.157 0.140 #> 8 1 8 -0.140 -0.328 0 -0.157 0.140 #> 9 1 9 -0.0274 -0.355 0 -0.157 0.140 #> 10 1 10 0.0161 -0.339 0 -0.157 0.140 #> # ℹ 390 more rows # Generate random walks with different mean and standard deviation random_normal_walk(.num_walks = 10, .n = 50, .samp = FALSE) #> # A tibble: 500 × 7 #> walk_number x y cum_sum cum_prod cum_min cum_max #> #> 1 1 1 0.0432 0.0432 0 0.0432 0.0432 #> 2 1 2 -0.124 -0.0808 0 -0.124 0.0432 #> 3 1 3 0.150 0.0688 0 -0.124 0.150 #> 4 1 4 0.0159 0.0848 0 -0.124 0.150 #> 5 1 5 -0.0856 -0.000845 0 -0.124 0.150 #> 6 1 6 0.0309 0.0301 0 -0.124 0.150 #> 7 1 7 0.0870 0.117 0 -0.124 0.150 #> 8 1 8 -0.138 -0.0213 0 -0.138 0.150 #> 9 1 9 0.169 0.148 0 -0.138 0.169 #> 10 1 10 -0.0158 0.132 0 -0.138 0.169 #> # ℹ 490 more rows 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/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 rw30() #> # A tibble: 3,000 × 3 #> walk_number x y #> #> 1 1 1 0 #> 2 1 2 0.572 #> 3 1 3 -1.14 #> 4 1 4 -0.788 #> 5 1 5 -0.683 #> 6 1 6 -3.15 #> 7 1 7 -3.19 #> 8 1 8 -3.78 #> 9 1 9 -4.67 #> 10 1 10 -4.43 #> # ℹ 2,990 more rows 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":""}] diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 6922165..50236cb 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -13,12 +13,14 @@ https://www.spsanderson.com/RandomWalker/reference/ckurtosis.html https://www.spsanderson.com/RandomWalker/reference/cmean.html https://www.spsanderson.com/RandomWalker/reference/cmedian.html +https://www.spsanderson.com/RandomWalker/reference/crange.html https://www.spsanderson.com/RandomWalker/reference/csd.html 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/geometric_brownian_motion.html https://www.spsanderson.com/RandomWalker/reference/index.html +https://www.spsanderson.com/RandomWalker/reference/internal_rand_walk_helper.html https://www.spsanderson.com/RandomWalker/reference/kurtosis_vec.html https://www.spsanderson.com/RandomWalker/reference/name.html https://www.spsanderson.com/RandomWalker/reference/random_normal_drift_walk.html diff --git a/man/cgmean.Rd b/man/cgmean.Rd index bdfb5d0..17dad71 100644 --- a/man/cgmean.Rd +++ b/man/cgmean.Rd @@ -31,11 +31,11 @@ Other Vector Function: \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{name}}, \code{\link{rw_range}()}, \code{\link{skewness_vec}()} } diff --git a/man/chmean.Rd b/man/chmean.Rd index e9a22eb..f3e4c01 100644 --- a/man/chmean.Rd +++ b/man/chmean.Rd @@ -31,11 +31,11 @@ Other Vector Function: \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{name}}, \code{\link{rw_range}()}, \code{\link{skewness_vec}()} } diff --git a/man/ckurtosis.Rd b/man/ckurtosis.Rd index 5bc53f5..7c60cbf 100644 --- a/man/ckurtosis.Rd +++ b/man/ckurtosis.Rd @@ -30,11 +30,11 @@ Other Vector Function: \code{\link{chmean}()}, \code{\link{cmean}()}, \code{\link{cmedian}()}, +\code{\link{crange}()}, \code{\link{csd}()}, \code{\link{cskewness}()}, \code{\link{cvar}()}, \code{\link{kurtosis_vec}()}, -\code{\link{name}}, \code{\link{rw_range}()}, \code{\link{skewness_vec}()} } diff --git a/man/cmean.Rd b/man/cmean.Rd index cb7acf8..a2bbfce 100644 --- a/man/cmean.Rd +++ b/man/cmean.Rd @@ -31,11 +31,11 @@ Other Vector Function: \code{\link{chmean}()}, \code{\link{ckurtosis}()}, \code{\link{cmedian}()}, +\code{\link{crange}()}, \code{\link{csd}()}, \code{\link{cskewness}()}, \code{\link{cvar}()}, \code{\link{kurtosis_vec}()}, -\code{\link{name}}, \code{\link{rw_range}()}, \code{\link{skewness_vec}()} } diff --git a/man/cmedian.Rd b/man/cmedian.Rd index 6f78f4e..151f291 100644 --- a/man/cmedian.Rd +++ b/man/cmedian.Rd @@ -30,11 +30,11 @@ Other Vector Function: \code{\link{chmean}()}, \code{\link{ckurtosis}()}, \code{\link{cmean}()}, +\code{\link{crange}()}, \code{\link{csd}()}, \code{\link{cskewness}()}, \code{\link{cvar}()}, \code{\link{kurtosis_vec}()}, -\code{\link{name}}, \code{\link{rw_range}()}, \code{\link{skewness_vec}()} } diff --git a/man/name.Rd b/man/crange.Rd similarity index 94% rename from man/name.Rd rename to man/crange.Rd index b054910..6d73dab 100644 --- a/man/name.Rd +++ b/man/crange.Rd @@ -1,8 +1,11 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/vec-functions.R -\name{name} -\alias{name} +\name{crange} +\alias{crange} \title{Cumulative Range} +\usage{ +crange(.x) +} \arguments{ \item{.x}{A numeric vector} } diff --git a/man/csd.Rd b/man/csd.Rd index f1c1dcf..fad2d6d 100644 --- a/man/csd.Rd +++ b/man/csd.Rd @@ -32,10 +32,10 @@ Other Vector Function: \code{\link{ckurtosis}()}, \code{\link{cmean}()}, \code{\link{cmedian}()}, +\code{\link{crange}()}, \code{\link{cskewness}()}, \code{\link{cvar}()}, \code{\link{kurtosis_vec}()}, -\code{\link{name}}, \code{\link{rw_range}()}, \code{\link{skewness_vec}()} } diff --git a/man/cskewness.Rd b/man/cskewness.Rd index 4e4fb03..035021d 100644 --- a/man/cskewness.Rd +++ b/man/cskewness.Rd @@ -31,10 +31,10 @@ Other Vector Function: \code{\link{ckurtosis}()}, \code{\link{cmean}()}, \code{\link{cmedian}()}, +\code{\link{crange}()}, \code{\link{csd}()}, \code{\link{cvar}()}, \code{\link{kurtosis_vec}()}, -\code{\link{name}}, \code{\link{rw_range}()}, \code{\link{skewness_vec}()} } diff --git a/man/cvar.Rd b/man/cvar.Rd index 6c8e582..8e479b9 100644 --- a/man/cvar.Rd +++ b/man/cvar.Rd @@ -33,10 +33,10 @@ Other Vector Function: \code{\link{ckurtosis}()}, \code{\link{cmean}()}, \code{\link{cmedian}()}, +\code{\link{crange}()}, \code{\link{csd}()}, \code{\link{cskewness}()}, \code{\link{kurtosis_vec}()}, -\code{\link{name}}, \code{\link{rw_range}()}, \code{\link{skewness_vec}()} } diff --git a/man/geometric_brownian_motion.Rd b/man/geometric_brownian_motion.Rd index 7365868..e31a558 100644 --- a/man/geometric_brownian_motion.Rd +++ b/man/geometric_brownian_motion.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/gen-geom-brown-motion.R +% Please edit documentation in R/gen-brown-motion-geometric.R \name{geometric_brownian_motion} \alias{geometric_brownian_motion} \title{Geometric Brownian Motion} diff --git a/man/internal_rand_walk_helper.Rd b/man/internal_rand_walk_helper.Rd new file mode 100644 index 0000000..917045e --- /dev/null +++ b/man/internal_rand_walk_helper.Rd @@ -0,0 +1,47 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/helpers.R +\name{internal_rand_walk_helper} +\alias{internal_rand_walk_helper} +\title{Random Walk Helper} +\usage{ +internal_rand_walk_helper(.data, .value) +} +\arguments{ +\item{.data}{The data frame to mutate.} + +\item{.value}{The .initial_value to use. This is passed from the random walk +function being called by the end user.} +} +\value{ +A modified data frame/tibble with the following columns added: +\itemize{ +\item \code{cum_sum}: Cumulative sum of \code{y}. +\item \code{cum_prod}: Cumulative product of \code{y}. +\item \code{cum_min}: Cumulative minimum of \code{y}. +\item \code{cum_max}: Cumulative maximum of \code{y}. +\item \code{cum_mean}: Cumulative mean of \code{y}. +} +} +\description{ +A function to help build random walks by mutating a data frame. +} +\details{ +A function to help build random walks by mutating a data frame. This mutation +adds the following columns to the data frame: \code{cum_sum}, \code{cum_prod}, \code{cum_min}, +\code{cum_max}, and \code{cum_mean}. The function is used internally by certain functions +that generate random walks. +} +\examples{ +df <- tibble( + walk_number = factor(rep(1L:25L, each = 30L)), + x = rep(1L:30L, 25L), + y = rnorm(750L, 0L, 1L) + ) + +internal_rand_walk_helper(df, 100) + +} +\author{ +Steven P. Sanderson II, MPH +} +\concept{Helper Functions} diff --git a/man/kurtosis_vec.Rd b/man/kurtosis_vec.Rd index 191f7a4..0abb2d9 100644 --- a/man/kurtosis_vec.Rd +++ b/man/kurtosis_vec.Rd @@ -23,6 +23,7 @@ kurtosis explains the sharpness of the peak of a distribution of data. A function to return the kurtosis of a vector. } \examples{ +set.seed(123) kurtosis_vec(rnorm(100, 3, 2)) } @@ -35,10 +36,10 @@ Other Vector Function: \code{\link{ckurtosis}()}, \code{\link{cmean}()}, \code{\link{cmedian}()}, +\code{\link{crange}()}, \code{\link{csd}()}, \code{\link{cskewness}()}, \code{\link{cvar}()}, -\code{\link{name}}, \code{\link{rw_range}()}, \code{\link{skewness_vec}()} } diff --git a/man/random_normal_drift_walk.Rd b/man/random_normal_drift_walk.Rd index 3724631..a7d8278 100644 --- a/man/random_normal_drift_walk.Rd +++ b/man/random_normal_drift_walk.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/gen-random-drift-walk.R +% Please edit documentation in R/gen-random-normal-walk-drift.R \name{random_normal_drift_walk} \alias{random_normal_drift_walk} \title{Generate Multiple Random Walks with Drift} diff --git a/man/rw_range.Rd b/man/rw_range.Rd index 2b6ad3a..9d6d0e1 100644 --- a/man/rw_range.Rd +++ b/man/rw_range.Rd @@ -32,11 +32,11 @@ Other Vector Function: \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{name}}, \code{\link{skewness_vec}()} } \author{ diff --git a/man/skewness_vec.Rd b/man/skewness_vec.Rd index 0400d25..02a7d4f 100644 --- a/man/skewness_vec.Rd +++ b/man/skewness_vec.Rd @@ -23,6 +23,7 @@ skewness explains the 'tailedness' of the distribution of data. A function to return the skewness of a vector. } \examples{ +set.seed(123) skewness_vec(rnorm(100, 3, 2)) } @@ -35,11 +36,11 @@ Other Vector Function: \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{name}}, \code{\link{rw_range}()} } \author{