import Normal from '../dist/normal'; import Process from './_process'; /** * Brownian bridge process conditioned to return to 0 at time T, using an exact discrete-time sampler. * * The underlying SDE is * * $\mathrm{d}X_t = -\frac{X_t}{T - t} \mathrm{d}t + \sigma \mathrm{d}W_t.$ * * Because the SDE is linear, the conditional distribution $X_{t+\mathrm{d}t} \mid X_t = x, X_T = 0$ * is Gaussian, derived from the covariance structure of the Wiener process. The sampler draws * from that distribution directly * * $X_{t+\mathrm{d}t} = X_t \frac{T - t - \mathrm{d}t}{T - t} + \sigma\sqrt{\frac{\mathrm{d}t (T - t - \mathrm{d}t)}{T - t}}\,Z,$ * * where $Z \sim \mathcal{N}(0, 1)$. There is no step-size discretization error. The process pins to 0 at step $N = T/\mathrm{d}t$. * * @class BrownianBridge * @memberof ran.process * @constructor */ export default class BrownianBridge extends Process { p: { sigma: number; T: number; dt: number; }; n: number; x: number; x0: number; c: { N: number; }; /** * @param {number} sigma Volatility (must be > 0). * @param {number} T Terminal time (must be > 0). * @param {number} [dt=0.1] Time step (must be > 0; T/dt must be a positive integer). */ constructor(sigma: number, T: number, dt?: number); _next(): number; /** @inheritdoc */ reset(): void; /** @inheritdoc */ path(n: any): any[]; /** @inheritdoc */ mean(t: any): number; /** @inheritdoc */ variance(t: any): number; /** @inheritdoc */ covariogram(s: any, t: any): number; /** @inheritdoc */ pdf(x: any, t: any): number; /** @inheritdoc */ marginal(t: any): Normal; /** * Estimates sigma from an observed path via the exact MLE. Unlike BrownianMotion/ * OrnsteinUhlenbeck/CoxIngersollRoss, T is a given/fixed endpoint (the bridge is conditioned * to return to 0 at T), not something to estimate from data — so it is a required argument, * mirroring the constructor. Each step's conditional variance is known exactly from _next()'s * own formula (sigma^2 * dt * ratio, ratio = (remaining-dt)/remaining), leaving sigma as the * only free scale parameter: Y_i = X_{i+1} - X_i*ratio_i is exactly sigma*sqrt(dt*ratio_i)*Z_i, * so sigma^2's MLE is the mean of Y_i^2/(dt*ratio_i) over all non-degenerate steps. The final * step (i = N-1) is excluded because _next() pins it to exactly 0 (ratio = 0), carrying no * information about sigma. * * @method fit * @memberof ran.process.BrownianBridge * @param {Array} path Array of observed states (as returned by path()). * @param {number} T Terminal time (must be > 0), matching the constructor's T. * @param {number} [dt=0.1] Time step (must be > 0; T/dt must be a positive integer). * @returns {BrownianBridge} A new instance with estimated sigma. * @throws {Error} If T or dt is not > 0, if T/dt is not at least 2, or if path does not * contain exactly T/dt + 1 states. */ static fit(path: any[], T: number, dt?: number): BrownianBridge; }