diff --git a/R/auto-rw30.R b/R/auto-rw30.R index 8d0e2b4..96c011b 100644 --- a/R/auto-rw30.R +++ b/R/auto-rw30.R @@ -80,7 +80,7 @@ rw30 <- function() { attr(walks_long, "mu") <- mu attr(walks_long, "sd") <- sd attr(walks_long, "fns") <- "rw30" - attr(res, "dimension") <- 1 + attr(walks_long, "dimension") <- 1 return(walks_long) } diff --git a/R/gen-brown-motion.R b/R/gen-brown-motion.R index 4ef90ca..92f6b0b 100644 --- a/R/gen-brown-motion.R +++ b/R/gen-brown-motion.R @@ -84,11 +84,11 @@ brownian_motion <- function(.num_walks = 10, .n = 100, .delta_time = 1, colnames(rand_matrix) <- 1:num_sims # Get the Brownian Motion and convert to price paths - ret <- apply(rbind(rep(initial_value, num_sims), rand_matrix), 2, cumsum) + res <- apply(rbind(rep(initial_value, num_sims), rand_matrix), 2, cumsum) # Return if (return_tibble){ - ret <- ret |> + res <- res |> dplyr::as_tibble() |> dplyr::mutate(t = 1:(t+1)) |> tidyr::pivot_longer(-t) |> @@ -99,13 +99,13 @@ brownian_motion <- function(.num_walks = 10, .n = 100, .delta_time = 1, } # Return ---- - attr(ret, "n") <- .n - attr(ret, "num_walks") <- .num_walks - attr(ret, "delta_time") <- .delta_time - attr(ret, "initial_value") <- .initial_value - attr(ret, "return_tibble") <- .return_tibble - attr(ret, "fns") <- "brownian_motion" + attr(res, "n") <- .n + attr(res, "num_walks") <- .num_walks + attr(res, "delta_time") <- .delta_time + attr(res, "initial_value") <- .initial_value + attr(res, "return_tibble") <- .return_tibble + attr(res, "fns") <- "brownian_motion" attr(res, "dimension") <- 1 - return(ret) + return(res) } diff --git a/R/gen-geom-brown-motion.R b/R/gen-geom-brown-motion.R index 8280fca..d762cff 100644 --- a/R/gen-geom-brown-motion.R +++ b/R/gen-geom-brown-motion.R @@ -106,7 +106,7 @@ geometric_brownian_motion <- function(.num_walks = 25, .n = 100, # Return if (return_tibble){ - ret <- ret |> + res <- res |> dplyr::as_tibble() |> dplyr::mutate(t = 1:(t+1)) |> tidyr::pivot_longer(-t) |> @@ -116,15 +116,15 @@ geometric_brownian_motion <- function(.num_walks = 25, .n = 100, dplyr::arrange(walk_number, x) } - attr(ret, "n") <- .n - attr(ret, "num_walks") <- .num_walks - attr(ret, "mean") <- .mu - attr(ret, "sigma") <- .sigma - attr(ret, "initial_value") <- .initial_value - attr(ret, "delta_time") <- .delta_time - attr(ret, "return_tibble") <- .return_tibble - attr(ret, "fns") <- "geometric_brownian_motion" + attr(res, "n") <- .n + attr(res, "num_walks") <- .num_walks + attr(res, "mean") <- .mu + attr(res, "sigma") <- .sigma + attr(res, "initial_value") <- .initial_value + attr(res, "delta_time") <- .delta_time + attr(res, "return_tibble") <- .return_tibble + attr(res, "fns") <- "geometric_brownian_motion" attr(res, "dimension") <- 1 - return(ret) + return(res) } diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 0790f2a..2f132bb 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-19T21:36Z +last_built: 2024-07-19T21:52Z urls: reference: https://www.spsanderson.com/RandomWalker/reference article: https://www.spsanderson.com/RandomWalker/articles diff --git a/docs/reference/Rplot001.png b/docs/reference/Rplot001.png index 17a3580..e620dfd 100644 Binary files a/docs/reference/Rplot001.png and b/docs/reference/Rplot001.png differ diff --git a/docs/reference/brownian_motion.html b/docs/reference/brownian_motion.html index ff38a39..5583882 100644 --- a/docs/reference/brownian_motion.html +++ b/docs/reference/brownian_motion.html @@ -41,8 +41,8 @@

Usage

brownian_motion(
-  .n = 100,
   .num_walks = 10,
+  .n = 100,
   .delta_time = 1,
   .initial_value = 0,
   .return_tibble = TRUE
@@ -53,12 +53,12 @@ 

Usage

Arguments

-
.n
-

Total time of the simulation.

+
.num_walks
+

Total number of simulations.

-
.num_walks
-

Total number of simulations.

+
.n
+

Total time of the simulation.

.delta_time
@@ -112,7 +112,20 @@

Examples
library(ggplot2)
 
 brownian_motion()
-#> Error: object 'res' not found
+#> # A tibble: 1,010 × 3
+#>    walk_number     x     y
+#>    <fct>       <int> <dbl>
+#>  1 1               1  0   
+#>  2 1               2 -1.40
+#>  3 1               3 -1.14
+#>  4 1               4 -3.58
+#>  5 1               5 -3.59
+#>  6 1               6 -2.97
+#>  7 1               7 -1.82
+#>  8 1               8 -3.64
+#>  9 1               9 -3.89
+#> 10 1              10 -4.13
+#> # ℹ 1,000 more rows
 
 brownian_motion() |>
   ggplot(aes(x = x, y = y, group = walk_number, color = walk_number)) +
@@ -120,7 +133,7 @@ 

Examples labs(title = "Brownian Motion", x = "Time", y = "Value") + theme_minimal() + theme(legend.position = "none") -#> Error: object 'res' not found +

diff --git a/docs/reference/geometric_brownian_motion.html b/docs/reference/geometric_brownian_motion.html index 7a84ad8..e33569d 100644 --- a/docs/reference/geometric_brownian_motion.html +++ b/docs/reference/geometric_brownian_motion.html @@ -129,7 +129,7 @@

Examples
library(ggplot2)
 
 geometric_brownian_motion()
-#> Error: object 'res' not found
+#> Error in geometric_brownian_motion(): object 'res' not found
 
 geometric_brownian_motion() |>
   ggplot(aes(x = x, y = y, group = walk_number, color = walk_number)) +
@@ -137,7 +137,7 @@ 

Examples labs(title = "Geometric Brownian Motion", x = "Time", y = "Value") + theme_minimal() + theme(legend.position = "none") -#> Error: object 'res' not found +#> Error in geometric_brownian_motion(): object 'res' not found

diff --git a/docs/reference/random_normal_drift_walk-1.png b/docs/reference/random_normal_drift_walk-1.png index 219bdf3..2f94703 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 bdb9a25..ceffb86 100644 --- a/docs/reference/random_normal_drift_walk.html +++ b/docs/reference/random_normal_drift_walk.html @@ -116,13 +116,12 @@

Examples walks <- random_normal_drift_walk(.num_walks = 10, .n = 50, .mu = 0, .sd = 1, .drift = 0.05) -#> Error: object 'res' not found ggplot(walks, aes(x = x, y = y, group = walk_number, color = walk_number)) + geom_line() + labs(title = "Random Walks with Drift", x = "Time", y = "Value") + theme_minimal() + theme(legend.position = "none") -#> Error in eval(expr, envir, enclos): object 'walks' not found + diff --git a/docs/reference/rw30-1.png b/docs/reference/rw30-1.png index 705e7a0..7f6bfbd 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 f9bd482..17af765 100644 --- a/docs/reference/rw30.html +++ b/docs/reference/rw30.html @@ -69,7 +69,20 @@

Examples # Generate random walks and print the result rw30() -#> Error: object 'res' not found +#> # A tibble: 3,000 × 3 +#> walk_number x y +#> <fct> <int> <dbl> +#> 1 1 1 0 +#> 2 1 2 0.254 +#> 3 1 3 2.91 +#> 4 1 4 4.07 +#> 5 1 5 3.55 +#> 6 1 6 3.96 +#> 7 1 7 4.31 +#> 8 1 8 5.04 +#> 9 1 9 5.31 +#> 10 1 10 4.04 +#> # ℹ 2,990 more rows rw30() |> ggplot(aes(x = x, y = y, color = walk_number, group = walk_number)) + @@ -82,7 +95,7 @@

Examples y = "Value", color = "Walk Number" ) -#> Error: object 'res' not found + diff --git a/docs/search.json b/docs/search.json index bce846f..bbde58a 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'. R package version 0.0.0.9000, https://github.com/spsanderson/RandomWalker, https://www.spsanderson.com/RandomWalker/.","code":"@Manual{, title = {RandomWalker: Generate Random Walks Compatible With The 'tidyverse'}, author = {Steven Sanderson}, year = {2024}, note = {R package version 0.0.0.9000, https://github.com/spsanderson/RandomWalker}, url = {https://www.spsanderson.com/RandomWalker/}, }"},{"path":"https://www.spsanderson.com/RandomWalker/index.html","id":"randomwalker-","dir":"","previous_headings":"","what":"Generate Random Walks Compatible With The tidyverse","title":"Generate Random Walks Compatible With The tidyverse","text":"goal RandomWalker allow users easily create Random Walks different types compatible tidyverse suite packages. package currently experimental stage development.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Generate Random Walks Compatible With The tidyverse","text":"can install 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( .n = 100, .num_walks = 10, .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":".n Total time simulation. .num_walks Total number simulations. .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() #> Error: object 'res' not found 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\") #> Error: object 'res' not found"},{"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 99 0 99 99 #> 2 1 2 -1 98 0 99 99 #> 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 100 0 99 101 #> 7 1 7 -1 99 0 99 101 #> 8 1 8 1 100 0 99 101 #> 9 1 9 -1 99 0 99 101 #> 10 1 10 -1 98 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() #> Error: object 'res' not found 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\") #> Error: object 'res' not found"},{"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) #> Error: object 'res' not found ggplot(walks, aes(x = x, y = y, group = walk_number, color = walk_number)) + geom_line() + labs(title = \"Random Walks with Drift\", x = \"Time\", y = \"Value\") + theme_minimal() + theme(legend.position = \"none\") #> Error in eval(expr, envir, enclos): object 'walks' not found"},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_walk.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate Multiple Random Normal Walks — random_normal_walk","title":"Generate Multiple Random Normal Walks — random_normal_walk","text":"random_normal_walk function useful simulating random processes can applied various fields finance, physics, biology model different stochastic behaviors.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_walk.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate Multiple Random Normal Walks — random_normal_walk","text":"","code":"random_normal_walk( .num_walks = 25, .n = 100, .mu = 0, .sd = 0.1, .initial_value = 0, .samp = TRUE, .replace = TRUE, .sample_size = 0.8 )"},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_walk.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generate Multiple Random Normal Walks — random_normal_walk","text":".num_walks integer specifying number random walks generate. Default 25. .n integer specifying number steps walk. Default 100. .mu numeric value indicating mean normal distribution. Default 0. .sd numeric value indicating standard deviation normal distribution. Default 0.1. .initial_value numeric value indicating initial value walks. Default 0. .samp logical value indicating whether sample normal distribution values. Default TRUE. .replace logical value indicating whether sampling replacement. Default TRUE. .sample_size numeric value 0 1 specifying proportion .n sample. Default 0.8.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_walk.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate Multiple Random Normal Walks — random_normal_walk","text":"tibble containing generated random walks following columns: walk_number: Factor representing walk number. x: Step index. y: Normal distribution values. cum_sum: Cumulative sum y. cum_prod: Cumulative product y. cum_min: Cumulative minimum y. cum_max: Cumulative maximum y. tibble includes attributes function parameters.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_walk.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Generate Multiple Random Normal Walks — random_normal_walk","text":"function generates multiple random walks, sequences steps step random draw normal distribution. user can specify number walks, number steps walk, parameters normal distribution (mean standard deviation). function also allows sampling proportion steps optionally sampling replacement. output tibble includes several computed columns walk, cumulative sum, product, minimum, maximum steps.","code":""},{"path":[]},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_walk.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Generate Multiple Random Normal Walks — random_normal_walk","text":"Steven P. Sanderson II, MPH","code":""},{"path":"https://www.spsanderson.com/RandomWalker/reference/random_normal_walk.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Generate Multiple Random Normal Walks — random_normal_walk","text":"","code":"# Generate 10 random walks with 50 steps each 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.0653 0.0653 0 0.0653 0.0653 #> 2 1 2 0.103 0.169 0 0.0653 0.103 #> 3 1 3 -0.0947 0.0741 0 -0.0947 0.103 #> 4 1 4 0.0831 0.157 0 -0.0947 0.103 #> 5 1 5 -0.160 -0.00283 0 -0.160 0.103 #> 6 1 6 -0.0612 -0.0640 0 -0.160 0.103 #> 7 1 7 -0.00677 -0.0708 0 -0.160 0.103 #> 8 1 8 0.0380 -0.0328 0 -0.160 0.103 #> 9 1 9 0.0380 0.00519 0 -0.160 0.103 #> 10 1 10 -0.0551 -0.0499 0 -0.160 0.103 #> # ℹ 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.127 -0.127 0 -0.127 -0.127 #> 2 1 2 0.182 0.0553 0 -0.127 0.182 #> 3 1 3 0.0770 0.132 0 -0.127 0.182 #> 4 1 4 -0.0245 0.108 0 -0.127 0.182 #> 5 1 5 -0.0399 0.0680 0 -0.127 0.182 #> 6 1 6 0.147 0.215 0 -0.127 0.182 #> 7 1 7 0.0258 0.241 0 -0.127 0.182 #> 8 1 8 -0.0774 0.164 0 -0.127 0.182 #> 9 1 9 -0.0126 0.151 0 -0.127 0.182 #> 10 1 10 0.00426 0.155 0 -0.127 0.182 #> # ℹ 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() #> Error: object 'res' not found 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\" ) #> Error: object 'res' not found"},{"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'. R package version 0.0.0.9000, https://github.com/spsanderson/RandomWalker, https://www.spsanderson.com/RandomWalker/.","code":"@Manual{, title = {RandomWalker: Generate Random Walks Compatible With The 'tidyverse'}, author = {Steven Sanderson}, year = {2024}, note = {R package version 0.0.0.9000, https://github.com/spsanderson/RandomWalker}, url = {https://www.spsanderson.com/RandomWalker/}, }"},{"path":"https://www.spsanderson.com/RandomWalker/index.html","id":"randomwalker-","dir":"","previous_headings":"","what":"Generate Random Walks Compatible With The tidyverse","title":"Generate Random Walks Compatible With The tidyverse","text":"goal RandomWalker allow users easily create Random Walks different types compatible tidyverse suite packages. package currently experimental stage development.","code":""},{"path":"https://www.spsanderson.com/RandomWalker/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Generate Random Walks Compatible With The tidyverse","text":"can install 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 = 10, .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: 1,010 × 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 #> # ℹ 1,000 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/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 99 0 99 99 #> 2 1 2 -1 98 0 99 99 #> 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 100 0 99 101 #> 7 1 7 -1 99 0 99 101 #> 8 1 8 1 100 0 99 101 #> 9 1 9 -1 99 0 99 101 #> 10 1 10 -1 98 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() #> Error in geometric_brownian_motion(): object 'res' not found 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\") #> Error in geometric_brownian_motion(): object 'res' not found"},{"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.0653 0.0653 0 0.0653 0.0653 #> 2 1 2 0.103 0.169 0 0.0653 0.103 #> 3 1 3 -0.0947 0.0741 0 -0.0947 0.103 #> 4 1 4 0.0831 0.157 0 -0.0947 0.103 #> 5 1 5 -0.160 -0.00283 0 -0.160 0.103 #> 6 1 6 -0.0612 -0.0640 0 -0.160 0.103 #> 7 1 7 -0.00677 -0.0708 0 -0.160 0.103 #> 8 1 8 0.0380 -0.0328 0 -0.160 0.103 #> 9 1 9 0.0380 0.00519 0 -0.160 0.103 #> 10 1 10 -0.0551 -0.0499 0 -0.160 0.103 #> # ℹ 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.127 -0.127 0 -0.127 -0.127 #> 2 1 2 0.182 0.0553 0 -0.127 0.182 #> 3 1 3 0.0770 0.132 0 -0.127 0.182 #> 4 1 4 -0.0245 0.108 0 -0.127 0.182 #> 5 1 5 -0.0399 0.0680 0 -0.127 0.182 #> 6 1 6 0.147 0.215 0 -0.127 0.182 #> 7 1 7 0.0258 0.241 0 -0.127 0.182 #> 8 1 8 -0.0774 0.164 0 -0.127 0.182 #> 9 1 9 -0.0126 0.151 0 -0.127 0.182 #> 10 1 10 0.00426 0.155 0 -0.127 0.182 #> # ℹ 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.254 #> 3 1 3 2.91 #> 4 1 4 4.07 #> 5 1 5 3.55 #> 6 1 6 3.96 #> 7 1 7 4.31 #> 8 1 8 5.04 #> 9 1 9 5.31 #> 10 1 10 4.04 #> # ℹ 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":[]},{"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":""}]