/** * Seedable PRNG for reproducible training. * * The package previously used `Math.random()` everywhere — fast but * non-deterministic, which breaks reproducible training, A/B mode comparison, * and unit tests that assert on stochastic behavior. * * This module exposes a Mulberry32-based PRNG (small, fast, statistically * sound for non-cryptographic use) plus a global injection point. RL * algorithms, weight initialization, and exploration policies should call * `random()` / `randomInt()` / `randomNormal()` from here instead of * `Math.random()` directly. * * For deterministic runs: * * import { setGlobalRng, Mulberry32 } from '@claude-flow/neural'; * setGlobalRng(new Mulberry32(42)); * * After that, all `random()` consumers produce the same sequence on * every run. Pass a different seed to vary the trajectory. */ export interface RNG { /** Uniform sample in [0, 1) */ next(): number; /** Integer sample in [min, max) */ nextInt(min: number, max: number): number; /** Standard normal sample (Box-Muller) */ nextNormal(): number; /** Reseed in place (mutates this instance) */ seed(s: number): void; } /** * Mulberry32 — 32-bit chaotic-state PRNG. Period 2^32, passes BigCrush * subtests, ~5x faster than seedrandom. Not cryptographically secure. */ export declare class Mulberry32 implements RNG { private state; constructor(seedValue?: number); next(): number; nextInt(min: number, max: number): number; nextNormal(): number; seed(s: number): void; } /** * Math.random()-backed RNG for backward compatibility / production default. * Fast, non-deterministic, what the package shipped with before. */ export declare class MathRandomRng implements RNG { next(): number; nextInt(min: number, max: number): number; nextNormal(): number; seed(_s: number): void; } /** * Replace the global RNG. Pass a `Mulberry32(seed)` for reproducible runs, * or any custom RNG impl for testing. Idempotent. */ export declare function setGlobalRng(rng: RNG): void; /** Get the current global RNG (mainly for tests/diagnostics). */ export declare function getGlobalRng(): RNG; /** Reset to the default `Math.random()`-backed RNG. Mainly for tests. */ export declare function resetGlobalRng(): void; /** Convenience: uniform sample in [0, 1) using the global RNG. */ export declare function random(): number; /** Convenience: integer sample in [min, max) using the global RNG. */ export declare function randomInt(min: number, max: number): number; /** Convenience: standard normal sample using the global RNG. */ export declare function randomNormal(): number; //# sourceMappingURL=rng.d.ts.map