Geometric Brownian Motion (GBM) is a continuous-time stochastic process in which the logarithm of the randomly varying quantity follows a Brownian motion (also called a Wiener process). In software engineering and quantitative finance, GBM is the standard mathematical model used to simulate asset prices over time, notably serving as the foundation for the Black-Scholes Model and Monte Carlo Retirement Planning simulations.
A stochastic process S_t(representing the price of an asset at timet) is said to follow a Geometric Brownian Motion if it satisfies the following stochastic differential equation:
Where:*S_t: The asset price at timet. *\mu: The percentage drift (expected return). A constant deterministic trend. *\sigma: The percentage volatility (standard deviation). A constant representing market noise. *W_t: A standard Wiener process (Brownian motion), representing the random shock.dW_t \sim \mathcal{N}(0, dt).
Unlike standard Brownian motion, which can result in negative values, GBM is strictly positive (S_t > 0for alltifS_0 > 0). The term\mu S_tand\sigma S_tmean that the magnitude of the drift and volatility scale proportionally with the current price, which accurately reflects percentage-based returns in financial markets.
To simulate GBM in software, we cannot directly integrate the SDE because thedW_tterm is nowhere differentiable. We must apply Itô's Lemma, a foundational theorem in stochastic calculus.
Applying Itô's Lemma to the natural logarithm of the priceY_t = \ln(S_t)yields:
This equation is highly significant for software engineers building Monte Carlo engines: the right side of the equation consists entirely of constants and a standard normal distribution. This allows us to integrate directly to find the exact analytical solution forS_t:
When building a Monte Carlo engine, continuous time is discretized into finite steps (\Delta t). The discrete-time approximation (Euler-Maruyama method) derived from the exact solution is:
WhereZis a random draw from the Standard Normal Distribution\mathcal{N}(0,1).
In 2026 high-performance systems, this is typically implemented using vectorized operations on GPUs or highly optimized CPU libraries:
import numpy as np
def simulate_gbm(S0, mu, sigma, T, dt, num_simulations):
# Number of time steps
N = int(T / dt)
# Generate standard normal random variables for the entire matrix
Z = np.random.standard_normal((N, num_simulations))
# Calculate the deterministic drift and the stochastic shock
drift = (mu - 0.5 * sigma**2) * dt
shock = sigma * np.sqrt(dt) * Z
# Pre-allocate price array
S = np.zeros((N + 1, num_simulations))
S[0] = S0
# Vectorized cumulative sum of the log returns, then exponentiated
# S_t = S_0 * exp(cumsum(drift + shock))
log_returns = drift + shock
S[1:] = S0 * np.exp(np.cumsum(log_returns, axis=0))
return S
While GBM is computationally efficient, its assumption of constant volatility and normally distributed log-returns fails to capture real-world market dynamics (fat tails and volatility clustering). Modern computational finance systems often extend GBM using: