Exercise: Simulating a GBM Path and Checking Closed-Form Moments
Prerequisites: Geometric Brownian Motion, Log-Normal Distribution
Problem
Fix , , , years.
- Using the exact log-space scheme (Example 2 in the lesson), simulate independent GBM paths with time steps each (two years at 252 trading days per year). Record only the terminal values .
- Compute the sample mean, sample median, and sample standard deviation of . Compare each to the closed-form values , , and from the lesson.
- Verify empirically that is approximately Gaussian. Compute the sample mean and standard deviation of and compare to and .
- Estimate — the probability that the stock has fallen after two years. Compare to the closed-form value .
Hint
Use
rng = np.random.default_rng(2026) for reproducibility. Since only terminal values are needed, simulate with a single step per path: with . For part 4, use from scipy.stats import norm and compare (S_T < S0).mean() to norm.cdf(-((mu - 0.5*sigma**2)*T) / (sigma*np.sqrt(T))).Jump to the solution when you're ready.