public void TestMT19937Generator() { var rand = new MT19937Generator(); EntCalc calc = new EntCalc(false); for (int i = 0; i < 100000; ++i) { calc.AddSample(rand.Next(), false); } EntCalc.EntCalcResult result = calc.EndCalculation(); Assert.Less(result.ChiProbability, 0.01, "ChiProbability is too high, thus MT19937 Generator is not really random"); }
/// <summary> /// Resets the <see cref="ALFGenerator"/>, so that it produces the same pseudo-random number sequence again. /// </summary> private void ResetGenerator() { var gen = new MT19937Generator(seed); x = new uint[longLag]; for (uint j = 0; j < longLag; ++j) { x[j] = gen.NextUInt(); } i = longLag; // Reset helper variables used for generation of random bools. bitBuffer = 0; bitCount = 0; }
/// <summary> /// Resets the <see cref="ALFGenerator"/>, so that it produces the same pseudo-random number sequence again. /// </summary> private void ResetGenerator() { MT19937Generator gen = new MT19937Generator(this.seed); this.x = new uint[this.longLag]; for (uint j = 0; j < this.longLag; ++j) { this.x[j] = gen.NextUInt(); } this.i = this.longLag; // Reset helper variables used for generation of random bools. this.bitBuffer = 0; this.bitCount = 0; }