fx_ABM(x0_, mu_, sigma_, T_, n_, [paths_], [direction_])
Simulates arithmetic Brownian motion paths, X(t) = x0 + mu t + sigma W(t).
x0_- Starting value of every path.
mu_- Drift per year of X.
sigma_- Volatility per year.
T_- Horizon in years.
n_- Number of time steps of length T_/n_.
paths_- Optional. Number of paths; default 1.
direction_- Optional. "V" (default): time in rows, one column per path. "H": the transpose.
- Returns
- An (n_+1) x paths_ array that includes time zero; with "H", its transpose.
- Example
=fx_ABM(0, 0, 1, 1, 252)
=LAMBDA(x0_, mu_, sigma_, T_, n_, [paths_], [direction_],
LET(
Text1_, "Default to one path and vertical output",
m_, IF(ISOMITTED(paths_), 1, paths_),
layout_, IF(ISOMITTED(direction_), "V", UPPER(direction_)),
Text2_, "Length of each time step",
dt_, T_ / n_,
Text3_, "Generate uniform r.v.: one row per step, one column per path",
U_, RANDARRAY(n_, m_),
Text4_, "Inverse method: uniform -> standard normal (endpoints protected)",
Z_, NORM.S.INV(IF(U_ = 0, 2^-53, IF(U_ = 1, 1 - 2^-53, U_))),
Text5_, "ABM increments: drift plus a normal shock",
dX_, mu_*dt_ + sigma_*SQRT(dt_)*Z_,
Text6_, "Cumulative sums path by path: lower-triangular matrix of ones",
L_, --(SEQUENCE(n_) >= SEQUENCE(1, n_)),
cum_, MMULT(L_, dX_),
Text7_, "Every path starts at x0_",
path_, x0_ + VSTACK(SEQUENCE(1, m_, 0, 0), cum_),
Text8_, "V: time in rows, paths in columns; H: the transpose",
IF(layout_ = "V", path_, IF(layout_ = "H", TRANSPOSE(path_), NA()))
)
)