Line data Source code
1 1 : import { MersenneTwister19937 } from "../randomjs/engine/MersenneTwister19937.ts"; 2 1 : import { Random } from "../randomjs/Random.ts"; 3 : import { Engine } from "../randomjs/types.ts"; 4 1 : import { nativeMath } from "../randomjs/engine/nativeMath.ts"; 5 : 6 1 : abstract class RandomTest { 7 : distribution: Random; 8 0 : constructor(engine: Engine) { 9 0 : this.distribution = new Random(engine); 10 0 : } 11 0 : sample(n: number, min: number, max: number): number[] { 12 0 : return Array.from({ length: n }, () => this.distribution.real(min, max)); 13 0 : } 14 1 : } 15 : 16 1 : class MersenneTwister19937Test extends RandomTest { 17 0 : constructor() { 18 0 : super(MersenneTwister19937.autoSeed()); 19 0 : } 20 1 : } 21 : 22 1 : class NativeMathTest extends RandomTest { 23 0 : constructor() { 24 0 : super(nativeMath); 25 0 : } 26 1 : } 27 : 28 1 : (window as any).MersenneTwister19937Test = MersenneTwister19937Test; 29 1 : (window as any).NativeMathTest = NativeMathTest;