import LogNormal from '../dist/log-normal'; import Process from './_process'; /** * Geometric Brownian Motion with drift, using an exact discrete-time sampler. * * The underlying SDE is * * $\mathrm{d}X_t = \mu X_t \mathrm{d}t + \sigma X_t \mathrm{d}W_t.$ * * By Itô's formula, $\log X_t$ follows Brownian motion with drift, yielding the closed-form * solution $X_t = X_0\exp((\mu - \sigma^2/2)t + \sigma W_t)$. Each step is therefore an * independent lognormal draw * * $X_{t+\mathrm{d}t} = X_t \exp\!\left((\mu - \tfrac{\sigma^2}{2})\,\mathrm{d}t + \sigma\sqrt{\mathrm{d}t}\,Z\right),$ * * where $Z \sim \mathcal{N}(0, 1)$. There is no step-size discretization error. * * @class GeometricBrownianMotion * @memberof ran.process * @constructor */ export default class GeometricBrownianMotion extends Process { p: { mu: number; sigma: number; dt: number; }; x: number; x0: number; c: { drift: number; noise: number; logNoise: number; }; /** * @param {number} mu Drift rate. * @param {number} sigma Volatility (must be > 0). * @param {number} [dt=1] Time step (must be > 0). */ constructor(mu: number, sigma: number, dt?: number); _next(): number; /** * log(X_{i+1}/X_i) | X_i is Normal(drift, noise^2), the same law _next() draws from; the * transition density in X_{i+1} itself picks up a 1/X_{i+1} Jacobian term. Mirrors pdf(x,t)'s * x <= 0 => 0 convention: the log-density of an impossible (non-positive) state is -Infinity, * not a thrown error (decisions/0015-return-value-and-error-conventions.md). * * @method _transitionLnPdf * @memberof ran.process.GeometricBrownianMotion * @param {number} xPrev State at the start of the step. * @param {number} xNext State at the end of the step. * @returns {number} Log-density of the transition xPrev -> xNext, or -Infinity if xPrev <= 0 or xNext <= 0. * @protected * @ignore */ protected _transitionLnPdf(xPrev: number, xNext: number): number; /** @inheritdoc */ mean(t: any): number; /** @inheritdoc */ variance(t: any): number; /** @inheritdoc */ pdf(x: any, t: any): number; /** @inheritdoc */ covariogram(s: any, t: any): number; /** @inheritdoc */ marginal(t: any): LogNormal; /** * Estimates mu and sigma from an observed path via the exact MLE: log-returns are i.i.d. * Normal((mu-sigma^2/2)*dt, sigma^2*dt) by Ito's lemma, so sample mean/variance of the * log-returns (divided by dt) recovers the parameters to machine precision as the path * length grows. * * @method fit * @memberof ran.process.GeometricBrownianMotion * @param {Array} path Array of observed states (as returned by path()); every value must be > 0. * @param {number} [dt=1] Time step between consecutive path observations (must be > 0). * @returns {GeometricBrownianMotion} A new instance with estimated mu and sigma. * @throws {Error} If path has fewer than 3 states, contains a non-positive state, or if dt is not > 0. */ static fit(path: any[], dt?: number): GeometricBrownianMotion; }