import ShiftedBinomial from '../dist/_shifted-binomial'; import Process from './_process'; /** * Discrete-time random walk on the integers: at each step the state moves by +1 with * probability p and by −1 with probability 1 − p. For p = 0.5 the walk is symmetric * (unbiased); for p ≠ 0.5 it has drift 2p − 1 per step. * * The update rule is * * $X_{n+1} = X_n + \begin{cases} +1 & \text{if } U < p, \\ -1 & \text{if } U \geq p, \end{cases}$ * * where $U \sim \mathrm{Uniform}(0,1)$. * * @class RandomWalk * @memberof ran.process * @constructor */ export default class RandomWalk extends Process { p: { p: number; }; x: number; x0: number; /** * @param {number} p Probability of a +1 step (must satisfy 0 < p < 1). */ constructor(p: number); _next(): 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): ShiftedBinomial; /** * Estimates p from an observed path as the exact MLE: the fraction of +1 steps among all * observed increments. Since every increment is exactly +1 or -1, this coincides with * recovering p from the sample mean of increments (mean = 2p-1, so p = (mean+1)/2) — the two * are algebraically identical, not two competing estimators. * * @method fit * @memberof ran.process.RandomWalk * @param {Array} path Array of observed states (as returned by path()). * @returns {RandomWalk} A new instance with estimated p. * @throws {Error} If path has fewer than 2 states, if any step is not +1 or -1, or if the * estimated p falls outside (0,1) (path contains only up-steps or only down-steps). */ static fit(path: any[]): RandomWalk; }