public void Random() { for (int i = 0; i < Iterations; i++) { _ = _rng.NextDouble(); } }
public void Xoroshiro128Plus_Distribution_Similar_To_Std_Random(bool useRandomSeed) { var rnd = new Random(); var xoroshiro128plus = new Xoroshiro128Plus(useRandomSeed ? new Random() : null); var iterations = 10_000_000; var stdRand = new double[iterations]; var testRand = new double[iterations]; for (int i = 0; i < iterations; i++) { stdRand[i] = rnd.NextDouble(); testRand[i] = xoroshiro128plus.NextDouble(); } var stdAvg = stdRand.Average(); var testAvg = testRand.Average(); var avgDiff = Math.Abs(stdAvg - testAvg); Assert.True(avgDiff < 0.001d, "RNG should have simular distributions as BCL version. Diff: " + avgDiff); Test_Uniform_Distribution(stdRand); Test_Uniform_Distribution(testRand);