LIVE
connecting to the live quote stream…
--:--:--UTC
easyMaths○
#32

GBM path

easyMathsacceptance —~15 min

Implement gbm_path(S0, mu, sigma, dt, steps, seed) — a geometric Brownian motion path. Call random.seed(seed), then for each step draw z = random.gauss(0, 1) and set S = S·exp((mu - sigma²/2)·dt + sigma·sqrt(dt)·z). Return the steps simulated prices (not including S0).

It is the null model every option price and every Monte Carlo VaR in the workbench is built on. Return the prices rounded to 4 decimal places.

example 1
input
S0=100.0, mu=0.05, sigma=0.2, dt=1.0, steps=4, seed=7
output
[97.9047, 111.7518, 110.0639, 106.4896]
example 2
input
S0=100.0, mu=0.05, sigma=0.2, dt=0.25, steps=4, seed=7
output
[98.2075, 104.1389, 102.5772, 100.144]
constraints
  • S0 > 0
  • 0 < dt ≤ 1
  • 1 ≤ steps ≤ 252
teacher · 2 hints · the first is free
↗ read the theory
the chapter this problem is cut from
▶ open in the workbench
run the same math on a real tape
●solution.py· utf-8 · spaces:4
ln 1, col 1tab indent · esc leave editor
python 3.13 · pyodide
+ 6 hidden on submit
input · keyword arguments to gbm_path()
S0=100.0, mu=0.05, sigma=0.2, dt=1.0, steps=4, seed=7
expected
[97.9047, 111.7518, 110.0639, 106.4896]

the judge calls gbm_path() with exactly these inputs · outputs are compared to 6 decimal places

● standing bypython 3.13 in your browser · pyodide 0.28.3 · judged on the server to 6 dp⌘↵ run · ⌘⇧↵ submit
paper only · educational · not advice