UNPKG

clustering-tfjs

Version:

High-performance TypeScript clustering algorithms (K-Means, Spectral, Agglomerative) with TensorFlow.js acceleration and scikit-learn compatibility

38 lines 1.41 kB
/** * Minimal TypeScript implementation of the original MT19937 32-bit variant * used by NumPy's legacy `RandomState` (and therefore by scikit-learn). * * This port only exposes the functionality required by the k-means++ seeding * routine: * • Generation of 32-bit unsigned integers (\[0, 2**32)) * • High-precision uniform floats in the half-open interval \[0, 1) * * The algorithm closely follows the reference implementation described in * Matsumoto & Nishimura (1998) and the public domain C code. */ export declare class MT19937 { private static readonly N; private static readonly M; private static readonly MATRIX_A; private static readonly UPPER_MASK; private static readonly LOWER_MASK; /** State vector – 624 32-bit unsigned ints. */ private mt; /** Current index within the state vector. */ private index; constructor(seed: number); /** Returns next 32-bit unsigned int in \[0, 2**32). */ nextUint32(): number; /** * Returns a 53-bit precision float in the interval \[0, 1) identical to * NumPy's `random_sample` implementation. */ nextFloat(): number; /** Uniform integer in \[0, max). Mirrors NumPy's rejection sampling to * eliminate modulo bias so that sequences match exactly. */ nextInt(max: number): number; private init; private twist; } //# sourceMappingURL=mt19937.d.ts.map