Random walks are stochastic models that describe a path through a mathematical space that consists of random, discrete steps. This compendium contains simple functions that can be used to simulate, plot, or fit one-dimensional random walks.
Please cite this compendium as:
Randomwalk Enthusiast, (2021). Introduction to random walks. Accessed 09 Dec 2021. Online at https://doi.org/xxx/xxx
This research compendium has been developed using the statistical programming language R. To work with the compendium, you will need installed on your computer the R software itself and optionally RStudio Desktop.
You can download the compendium as a zip from from this URL:
simplerc. After unzipping: - open
the .Rproj
file in RStudio - run devtools::install()
to ensure you
have the packages this analysis depends on (also listed in the
DESCRIPTION file).
The simulate_walk()
function takes as arguments the number of steps
t
, and the mean (mu
) and standard deviation (sigma
) of the normal
distribution that each step size is drawn from, and returns a series of
values that represent a random walk in a one-dimensional space. Example
code is shown below:
t <- 100
mu <- 0.5
sigma <- 2
walk <- simulate_walk(t, mu, sigma)
The plot_walk()
function can be used to plot a simulated walk:
plot_walk(walk)
The fit_walk()
function takes a simulated walk as an argument, and
estimates the parameters (mu
and sigma
) of the normal distributions
that were used to simulate the random walk.
params <- fit_walk(walk)
The analysis directory contains:
- 📁 paper: R Markdown source document
for manuscript. Includes code to reproduce the figures and tables
generated by the analysis. It also has a rendered version,
paper.docx
, suitable for reading (the code is replaced by figures and tables in this file) - 📁 data: Data used in the analysis.
- 📁 figures: Plots and other illustrations
- 📁 supplementary-materials: Supplementary materials including notes and other documents prepared and collected during the analysis.
Text and figures : CC-BY-4.0
Code : See the DESCRIPTION file
Data : CC-0 attribution requested in reuse
We welcome contributions from everyone. Before you get started, please see our contributor guidelines. Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.