-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathREADME.Rmd
More file actions
231 lines (174 loc) · 6.96 KB
/
README.Rmd
File metadata and controls
231 lines (174 loc) · 6.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
message = FALSE,
warning = FALSE
)
```
# RandomWalker <img src="man/figures/logo.png" width="147" height="170" align="right" />
<!-- badges: start -->
[](https://cran.r-project.org/package=RandomWalker)


[](https://lifecycle.r-lib.org/articles/stages.html#stable)
[](https://makeapullrequest.com)
<!-- badges: end -->
> **Generate random walks of various types with tidyverse compatibility**
To view the full wiki, click here: [Full RandomWalker Wiki](https://github.com/spsanderson/RandomWalker/blob/main/wiki/Home.md)
RandomWalker is a comprehensive R package that makes it easy to generate, visualize, and analyze random walks. Whether you're modeling stock prices, simulating particle movements, or exploring stochastic processes, RandomWalker provides a unified, tidyverse-compatible interface with extensive distribution support.
## ✨ Key Features
- **🎲 27+ Distribution Types**: Generate random walks from Normal, Brownian Motion, Geometric Brownian Motion, Cauchy, Beta, Gamma, Poisson, and many more distributions
- **📐 Multi-Dimensional Support**: Create walks in 1D, 2D, or 3D space
- **📊 Rich Visualizations**: Built-in plotting functions with support for both static and interactive visualizations
- **📈 Statistical Analysis**: Comprehensive summary statistics including cumulative functions, confidence intervals, and distance metrics
- **🔧 Tidyverse Compatible**: Works seamlessly with dplyr, tidyr, and ggplot2
- **⚡ Easy to Use**: Sensible defaults with extensive customization options
## 📦 Installation
Install the stable version from CRAN:
```r
install.packages("RandomWalker")
```
Or get the development version from GitHub for the latest features and bug fixes:
```r
# install.packages("devtools")
devtools::install_github("spsanderson/RandomWalker")
```
## 🚀 Quick Start
### Generate 30 Random Walks
The `rw30()` function provides a quick way to generate 30 random walks with 100 steps each:
```{r rw30_example}
library(RandomWalker)
# Generate random walks
walks <- rw30()
head(walks, 10)
```
### Visualize Random Walks
Create beautiful visualizations with a single function call:
```{r random_walk_visual_example, fig.height=6, fig.width=8}
#| fig.alt: >
#| Line plot showing 30 different random walk paths over time with varying trajectories
rw30() |>
visualize_walks()
```
### Summarize Statistics
Get comprehensive statistical summaries of your random walks:
```{r random_walk_summary}
# Overall summary
rw30() |>
summarize_walks(.value = y)
# Summary by walk
rw30() |>
summarize_walks(.value = y, .group_var = walk_number) |>
head(10)
```
## 🎯 Common Use Cases
### 1. Custom Random Walks with Specific Distributions
```{r custom_examples}
# Normal walk with custom parameters
random_normal_walk(
.num_walks = 5,
.n = 50,
.mu = 0,
.sd = 0.1,
.initial_value = 100
) |>
visualize_walks()
# Geometric Brownian Motion (great for stock prices!)
geometric_brownian_motion(
.num_walks = 10,
.n = 100,
.mu = 0.05,
.sigma = 0.2,
.initial_value = 100
) |>
visualize_walks()
```
### 2. Multi-Dimensional Random Walks
```{r multidim_examples}
# 2D random walk
random_normal_walk(.num_walks = 3, .n = 100, .dimensions = 2) |>
head(10)
# 3D random walk
random_normal_walk(.num_walks = 2, .n = 50, .dimensions = 3) |>
head(10)
```
### 3. Discrete Random Walks
```{r discrete_examples}
# Discrete walk with upper/lower bounds
discrete_walk(
.num_walks = 5,
.n = 100,
.upper_bound = 1,
.lower_bound = -1,
.upper_probability = 0.55,
.initial_value = 0
) |>
visualize_walks()
```
## 📚 Available Random Walk Types
RandomWalker supports a wide variety of random walk types:
### Continuous Distributions
- **Normal**: `random_normal_walk()`, `random_normal_drift_walk()`
- **Brownian Motion**: `brownian_motion()`, `geometric_brownian_motion()`
- **Beta**: `random_beta_walk()`
- **Cauchy**: `random_cauchy_walk()`
- **Chi-Squared**: `random_chisquared_walk()`
- **Exponential**: `random_exponential_walk()`
- **F-Distribution**: `random_f_walk()`
- **Gamma**: `random_gamma_walk()`
- **Log-Normal**: `random_lognormal_walk()`
- **Logistic**: `random_logistic_walk()`
- **Student's t**: `random_t_walk()`
- **Uniform**: `random_uniform_walk()`
- **Weibull**: `random_weibull_walk()`
- **And more!**
### Discrete Distributions
- **Binomial**: `random_binomial_walk()`
- **Discrete**: `discrete_walk()`
- **Geometric**: `random_geometric_walk()`
- **Hypergeometric**: `random_hypergeometric_walk()`
- **Multinomial**: `random_multinomial_walk()`
- **Negative Binomial**: `random_negbinomial_walk()`
- **Poisson**: `random_poisson_walk()`
### Custom Walks
- **Custom Displacement**: `custom_walk()`, `random_displacement_walk()`
## 🛠️ Key Functions
| Function | Description |
|----------|-------------|
| `rw30()` | Quickly generate 30 random walks |
| `visualize_walks()` | Create visualizations (static or interactive) |
| `summarize_walks()` | Generate comprehensive statistics |
| `subset_walks()` | Subset walks by max/min values |
| `euclidean_distance()` | Calculate distances in multi-dimensional walks |
| `confidence_interval()` | Compute confidence intervals |
| `running_quantile()` | Calculate running quantiles |
## 📖 Documentation
- **Getting Started Guide**: See `vignette("getting-started")`
- **Function Reference**: [Online Documentation](https://www.spsanderson.com/RandomWalker/)
- **Package Website**: [RandomWalker](https://www.spsanderson.com/RandomWalker/)
- **News and Updates**: Check [NEWS.md](NEWS.md) for latest changes
## 🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
## 📄 License
This package is licensed under the MIT License. See [LICENSE.md](LICENSE.md) for details.
## 👥 Authors
- **Steven P. Sanderson II, MPH** - *Author, Creator, Maintainer* - [GitHub](https://github.com/spsanderson)
- **Antti Rask** - *Contributor* - Visualization functions
## 📞 Getting Help
- **Bug Reports**: [GitHub Issues](https://github.com/spsanderson/RandomWalker/issues)
- **Questions**: Use GitHub Discussions or Stack Overflow with the `randomwalker` tag
- **Website**: [https://www.spsanderson.com/RandomWalker/](https://www.spsanderson.com/RandomWalker/)
## 🌟 Citation
If you use RandomWalker in your research, please cite:
```r
citation("RandomWalker")
```
---
**Made with ❤️ for the R community**