if(!require(pacman))install.packages("pacman")
## Loading required package: pacman
pacman::p_load(tidyverse,
               sde,
               prettydoc,janitor)

Introduction

Brownian motion is a fundamental concept in the theory of stochastic processes, describing the random motion of particles suspended in a fluid. It has broad applications in various fields, including physics, finance, and biology. In this mini project, we explore the mathematical foundations of Brownian motion, simulate its paths using R, and discuss its extensions and applications.

Mathematical Foundation

Definition of Brownian Motion

Brownian motion, often denoted as \(W(t)\), is a continuous-time stochastic process with the following properties:

  1. \(W(0) = 0\).
  2. \(W(t)\) has independent increments.
  3. The increments \(W(t + s) - W(s)\) are normally distributed with mean 0 and variance \(t\).
  4. \(W(t)\) has continuous paths.

Mathematically, this can be expressed as:

\[ W(t) \sim N(0, t) \]

Key Properties

  • Markov Property: The future state of the process depends only on the current state, not on the past.
  • Martingales: A Brownian motion is a martingale, meaning that the expected value of the process at any future time, given the current information, is equal to the current value.

Simulation of Brownian Motion

In this section, we simulate paths of standard Brownian motion using R and visualize the results.

# Set seed for reproducibility
set.seed(123)

# Simulate a single path of standard Brownian motion
B <- BM(x = 0, T = 1, N = 1000)

# Create a time vector
time <- seq(0, 1, length.out = 1001)

# Plot the single path
plot(time, B, type = "l", col = "blue", lwd = 2,
     xlab = "Time", ylab = "Brownian Motion",
    main = "Single Path of Brownian Motion")

Analysis of Properties

Let’s calculate and analyze the mean and variance of the Brownian motion at the final time step \[𝑇=1\]

# Calculate mean and variance
mean_B <- mean(B)
var_B <- var(B)

cat("Mean at T = 1:", mean_B, "\n")
## Mean at T = 1: 0.2523405
cat("Variance at T = 1:", var_B, "\n")
## Variance at T = 1: 0.05314153

Theoretically, the mean should be close to 0, and the variance should be approximately equal to the final time𝑇

Brownian Motion with Drift

Brownian motion can be extended by adding a drift term, resulting in the following stochastic differential equation: \[dX(t)=μdt+σdW(t)\] where μ is the drift parameter and σ is the diffusion coefficient.

Simulation with Drift

Here we simulate a Brownian motion with drift using the sde package.

# Parameters for drift
mu <- 0.5
sigma <- 1

# Simulate Brownian motion with drift
B_drift <- sde.sim(X0 = 0, model = "BS", theta = c(mu, sigma), T = 1, N = 1000)

# Plot the Brownian motion with drift
plot(time, B_drift, type = "l", col = "red", lwd = 2,
     xlab = "Time", ylab = "Brownian Motion with Drift",
     main = "Brownian Motion with Drift (mu = 0.5)")

Applications and Extensions

Geometric Brownian Motion in Finance

One of the most well-known applications of Brownian motion is in the modeling of stock prices using the geometric Brownian motion (GBM). The GBM model is used in the Black-Scholes option pricing model, which is a cornerstone of modern financial theory.

The stochastic differential equation for GBM is:

\[dS(t)=μS(t)dt+σS(t)dW(t)\] where S(t) represents the stock price at time 𝑡

Simulation of GBM

# Initial stock price
S0 <- 100

# Simulate GBM
S <- GBM(x = S0, r = mu, sigma = sigma, T = 1, N = 1000)

# Plot GBM
plot(time, S, type = "l", col = "green", lwd = 2,
     xlab = "Time", ylab = "Stock Price",
     main = "Geometric Brownian Motion (GBM) Simulation")

Conclusion

In this mini project, we explored the theoretical foundation of Brownian motion, simulated its paths using R, and discussed its applications in finance through the geometric Brownian motion model. Brownian motion is a powerful tool in stochastic processes, with widespread applications in various fields.

References