/** * Simple random walk: steps of +stepSize with probability p and -stepSize otherwise. * * @example * randomWalk(100) // 101 positions starting at 0 * randomWalk(10, { p: 0.6, start: 5 }) * * @param {number} steps - Number of steps. * @param {Object} [options] * @param {number} [options.start=0] - Starting position. * @param {number} [options.p=0.5] - Probability of an up step. * @param {number} [options.stepSize=1] - Step size. * @param {number} [options.paths] - Number of independent paths. * @returns {number[]|number[][]} Positions (steps + 1 values per path). */ export function randomWalk(steps: number, { start, p, stepSize, paths }?: { start?: number; p?: number; stepSize?: number; paths?: number; }): number[] | number[][]; /** * Brownian motion (Wiener process) with drift: dX = mu dt + sigma dW. * * @param {Object} [options] * @param {number} [options.T=1] - Time horizon. * @param {number} [options.n=100] - Number of time steps. * @param {number} [options.mu=0] - Drift. * @param {number} [options.sigma=1] - Volatility. * @param {number} [options.x0=0] - Starting value. * @param {number} [options.paths] - Number of independent paths. * @returns {{t: number[], x: number[]|number[][]}} */ export function brownianMotion({ T, n, mu, sigma, x0, paths }?: { T?: number; n?: number; mu?: number; sigma?: number; x0?: number; paths?: number; }): { t: number[]; x: number[] | number[][]; }; /** * Brownian bridge from `a` at time 0 to `b` at time T. * * @param {Object} [options] * @param {number} [options.T=1] * @param {number} [options.n=100] * @param {number} [options.a=0] - Start value. * @param {number} [options.b=0] - End value. * @param {number} [options.sigma=1] - Volatility. * @param {number} [options.paths] - Number of independent paths. * @returns {{t: number[], x: number[]|number[][]}} */ export function brownianBridge({ T, n, a, b, sigma, paths }?: { T?: number; n?: number; a?: number; b?: number; sigma?: number; paths?: number; }): { t: number[]; x: number[] | number[][]; }; /** * Geometric Brownian motion dS = mu S dt + sigma S dW, simulated exactly: * S_t = S_0 exp((mu - sigma²/2) t + sigma W_t). The Black–Scholes stock price model. * * @param {Object} [options] * @param {number} [options.s0=1] - Initial value (> 0). * @param {number} [options.mu=0] - Drift. * @param {number} [options.sigma=0.2] - Volatility. * @param {number} [options.T=1] * @param {number} [options.n=100] * @param {number} [options.paths] - Number of independent paths. * @returns {{t: number[], x: number[]|number[][]}} */ export function geometricBrownianMotion({ s0, mu, sigma, T, n, paths }?: { s0?: number; mu?: number; sigma?: number; T?: number; n?: number; paths?: number; }): { t: number[]; x: number[] | number[][]; }; /** * Ornstein–Uhlenbeck process dX = theta (mu - X) dt + sigma dW, simulated with its exact * Gaussian transition (no discretisation error). Mean reverting (Vasicek model). * * @param {Object} [options] * @param {number} [options.x0=0] - Starting value. * @param {number} [options.theta=1] - Mean reversion speed (> 0). * @param {number} [options.mu=0] - Long term mean. * @param {number} [options.sigma=1] - Volatility. * @param {number} [options.T=1] * @param {number} [options.n=100] * @param {number} [options.paths] - Number of independent paths. * @returns {{t: number[], x: number[]|number[][]}} */ export function ornsteinUhlenbeck({ x0, theta, mu, sigma, T, n, paths }?: { x0?: number; theta?: number; mu?: number; sigma?: number; T?: number; n?: number; paths?: number; }): { t: number[]; x: number[] | number[][]; }; /** * Arrival times of a homogeneous Poisson process with the given rate on [0, T]. * * @param {number} rate - Events per unit time (>= 0). * @param {number} [T=1] - Time horizon. * @returns {number[]} Sorted arrival times. */ export function poissonProcess(rate: number, T?: number): number[]; /** * Arrival times of an inhomogeneous Poisson process with intensity `intensity(t)` bounded by * `maxRate` on [0, T], by Lewis–Shedler thinning. * * @param {function(number): number} intensity - Rate function. * @param {number} maxRate - Upper bound of the intensity on [0, T]. * @param {number} [T=1] - Time horizon. * @returns {number[]} Sorted arrival times. */ export function inhomogeneousPoissonProcess(intensity: (arg0: number) => number, maxRate: number, T?: number): number[]; /** * Number of events of a compound-free Poisson process at the grid times: N(t) on [0, T]. * * @param {number} rate * @param {Object} [options] * @param {number} [options.T=1] * @param {number} [options.n=100] * @returns {{t: number[], x: number[]}} */ export function poissonCountingProcess(rate: number, { T, n }?: { T?: number; n?: number; }): { t: number[]; x: number[]; }; /** * Simulates a discrete-time Markov chain. * * @example * const P = [[0.9, 0.1], [0.5, 0.5]] * markovChain(P, 10, 0) // 11 states starting at 0 * * @param {number[][]} transition - Row-stochastic transition matrix. * @param {number} steps - Number of transitions. * @param {number|number[]} [start=0] - Initial state, or an initial distribution. * @returns {number[]} The visited states (steps + 1 values). */ export function markovChain(transition: number[][], steps: number, start?: number | number[]): number[]; /** * Returns a bootstrap resample (sampling with replacement) of the data. * * @param {Array} data * @param {number} [size=data.length] * @returns {Array} */ export function resample(data: any[], size?: number): any[];