Simulating Geometric Brownian Motion Efficiently in R
Summary
The article presents two R approaches for simulating geometric Brownian motion price paths. A nested-loop version generates one random shock at a time for each path and time step. A vectorized version draws the shocks in a matrix, applies the per-step growth factors, and uses cumulative products to construct paths from the starting price. The article also illustrates plotting simulated paths and comparing their terminal prices with a density plot.
For the stated example of 50,000 simulations, the reported vectorized run took about 0.9 seconds, compared with about 10 seconds for the loop-based version. It then demonstrates using the simulated terminal-price distribution to calculate a probability-weighted payoff for a call-like payoff above a strike. These examples show a coding technique and a possible use in payoff analysis, not a validated market forecast or option valuation model. The document does not discuss calibration to market data, discounting, or model risk, and its illustrative payoff calculation should not be treated as a complete pricing framework.
Key ideas
- A loop-based GBM simulator draws a random shock for each path and time step.
- The vectorized approach generates shocks in a matrix and compounds growth factors across time.
- The article reports a faster runtime for its vectorized example than for its loop-based example.
- Simulated terminal prices can be used to estimate a payoff distribution under the chosen model inputs.
- The illustrated payoff calculation does not include a full option valuation framework.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.