public void MeanTest([Values(0.0f, 5.0f, -5.0f, 32.0f)] float targetMean, [Values(6, 10, 20, 40)] int bufferSize) { var ma = new MovingAverage(bufferSize); var count = 100 * bufferSize; // The expected error is more or less this, a bit on the generous side // with a lot of hand waving, but its good enough. var expError = 2f / (float)Math.Sqrt(ma.MovingAverageDepth); for (int i = 0; i < count; i++) { var val = (float)(_rng.NextDouble() - 0.5) + targetMean; ma.Enqueue(val); if (i > bufferSize) { Assert.That(ma.Mean, Is.EqualTo(targetMean).Within(expError)); } } Console.WriteLine(expError); }