The aim of this package is to provide a way to create and manipulate either discrete Random Walk or Brownian Motion or even list of them. It would be noticed that the construction of Brownian Motion is made by taking the limit of a Scaled Random Walk as its step size goes to zero. The Brownian Motion could therefore be read as a continously stepped Random Walk.

By convention the *time step size* of a Random Walk (with no scale
defined) is 1. It means that the value of the Non-Scaled Random Walk
updates each *time increment* of one. Furthermore the *increments* of a
*Non-Scaled (Unscaled) Random Walk* are either 1 or -1, depending on
chance (with a Symmetric Non-Scaled Random Walk, getting 1 or -1 as
increment is just as likely to occur.) All that preceed points out that
at each time step the value of the random walk is sure to be the former
one plus or minus 1.

Unlike the Unscaled Random Walk the *increments* of a *Scaled Random
Walk* is defined by the following formula: $\sqrt{scale}^{-1}$. Further
more its *time step size* is no longer one but are defined by the value
of *scale* and is $\frac{time\_to\_maturity}{scale}$

Finally and Also in contrast with the Scaled / Unscaled Random Walk, the
*Brownian Motion* has neither natural *increments* not *discrete time
step*. Each value taken by its increments, from time *t**k*
to *t**l* (with *k* < *l*) is randomly computed using the
Normal Law with *m ean = 0 and
variance* =

The package also implements some properties of the Random Walk and Brownian Motion Either to validate some test cases or directly for added functionalities.

Among the following ones:

- Expectation and variance of Random Walk/Brownian Motion
- Expectation and variance of increments
*Quadratic Variation*(Source of the Black-Scholes-Merton volatility. Computed path by path, where probabilities are not taken into account.)

:exclamation: The special case of Brownian Motion and Random Walk is
that they incur *the same Quadratic Variation* among all the different
paths.

**For more technical informations and example of usage** of the
RandomWalk package, feel free to have a look inside the
vignettes repository.

- Multiple Sampled Radom Walks generator: srwalkGenerator
- Sampled Radom Walk constructor: srwalk
- Theoretical Radom Walk generator: trwalkGenerator
- Multiple Brownian Motions generator: sbmotionGenerator
- Brownian Motion constructor: sbmotion
- Joint Distribution Function to characterize the distribution of brownian motion:
- Quadratic Variation: qvar

- To use for retrieving a specific value of one the previous process: get_values

The following lines do not fully give a bunch of examples of usage of the package functions.

Instead of giving such examples, they provide an brief description of the arguments the package functions take as well as the way these agruments are defined (along with the default value they take)

This function return a R *list* of multiple *data.frame* s. Each one
contains the following variables:

*time_periods*: Ordered vector from 0 up to T(time_to_maturity). It represents a partition of the period of time where the random walk evolved. The partition step of this vector depends on the variable*scale*.*random_walk_path*: Provides all the random values taken by the sampled random walk.

```
library(RandomWalk)
# The following line set the variable @sampled with a list of 20
# data.frame of Adapted random walk.
Sampled <- srwalkGenerator(time_to_maturity = 500,
seed = 7,
n = 20)
```

The previous Sampled Random Walks could be reduce to its graphical representation:

```
ggplot2::ggplot(dplyr::bind_rows(Sampled, .id = "uid")
, ggplot2::aes(x = time_periods,
y = random_walk_path,
group = uid)) +
ggplot2::geom_line(alpha = .5) +
ggplot2::labs(title = "Random Walk paths from multiple random experiments",
caption = "Random Walks",
x = 'Time periods',
y = 'Random Walk')
```

This function is defined to be the constructor of a unique Sampled Random Walk. It returns a unique S3 object with classes as follow:

```
## [1] "sampled_randomwalk" "data.frame"
```

srwalk() outputs a data.frame which contains each time step along with the associated Sampled Random Walk value, arranged as follow:

*time_periods*: Ordered vector from 0 up to T(time_to_maturity). It represents a partition of the period of time where the random walk evolved. The partition step of this vector depends on the variable*scale*.*random_walk_path*: Provides all the random values taken by the sampled random walk.

```
library(RandomWalk)
# Generate a 150 steps Unscale Symmetric Random Walk
srw <- srwalk(time_to_maturity = 150)
```

time_periods
random_walk_path
0
0
1
1
2
2
3
1
4
0
5
1
This function returns all the values the Random Walk could take along with their associated probabilities. Either the argument full is set to FALSE and only the last time period is return or it is set to TRUE and all the periods are then provided.

It returns a uniq S3 object with classes as follow:

```
## [1] "theoretical_randomwalk" "data.frame"
```

```
library(RandomWalk)
# Generate the distribution of a 150 steps Symmetric Random Walk
trwalkGenerator(time_to_maturity = 150, full = T)
# Generate the distribution of a Symmetric Random walk from time 0 to 4.
# It only returns the last time distribution along with the associated
# probabilities
trwalkGenerator(time_to_maturity = 4, scale = 2)
```

The last example gives the following result:

Mt Pr 5.656854 0.0039062 4.242641 0.0312500 2.828427 0.1093750 1.414214 0.2187500 0.000000 0.2734375 -1.414214 0.2187500 -2.828427 0.1093750 -4.242641 0.0312500 -5.656854 0.0039062With expectation and variance:

```
# Declare the Theoretical Random Walk
trw <- trwalkGenerator(time_to_maturity = 4, scale = 2)
# Expectation:
(Exp <- sum(trw[, 'Pr'] * trw[, 'Mt']))
## [1] 0
# Variance (Which is, according to the theory, equal to time_to_maturity):
sum(trw[, 'Pr'] * trw[, 'Mt'] ^ 2) - Exp
## [1] 4
```

This function returns a R *list* of multiple *data.frame*s. Each one
contains the following variables:

*time_period*: Ordered vector from 0 up to T(time_to_maturity). It represents the time period in which the Brownian Motion evolved. The partition step of this vector depends on the variable*scale*.*brownian_motion_path*: All random values taken by the Sampled Brownian Motion.

```
library(RandomWalk)
# The following line set the variable @sampled with a list of 20
# data.frame of Adapted random walk.
Sampled <- sbmotionGenerator(time_to_maturity = 4, scale = 100, n = 30)
```

The above example generates a list of 5 specifics Brownian Motion. To get an idea of what it represents, the following chart presents the pathes of those previous Brownian motion:

This function returns a *data.frame* containing the following variables:

*time_period*: Ordered vector from 0 up to T(time_to_maturity). It represents the time period in which the Brownian Motion evolved. The partition step of this vector depends on the variable*scale*.*brownian_motion_path*: All random values taken by the Sampled Brownian Motion.

```
library(RandomWalk)
# The following line set the variable @sampled with a list of 20
# data.frame of Adapted random walk.
Sampled <- sbmotion(time_to_maturity = 4, scale = 100)
```

The above example generates a list of 5 specifics Brownian Motion. To get an idea of what it represents, the following chart presents the pathes of those previous Brownian motion:

AnthonyTedde/RandomProcesses documentation built on Oct. 30, 2019, 4:56 a.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.