/// <summary> /// Creates a new QuantileEstimator. /// </summary> /// <param name="maximumError">The allowed error in the return value of GetProbLessThan. Must be greater than 0 and less than 1. As a rule of thumb, set this to the reciprocal of the number of desired quantiles.</param> public QuantileEstimator(double maximumError) { if (maximumError <= 0) { throw new ArgumentOutOfRangeException(nameof(maximumError), "maximumError <= 0"); } if (maximumError >= 1) { throw new ArgumentOutOfRangeException(nameof(maximumError), "maximumError >= 1"); } this.MaximumError = maximumError; // maxError = 0.05 gives bufferCount = 6, bufferLength = 46 double invError = 1 / maximumError; int bufferCount = 1 + Math.Max(1, (int)Math.Ceiling(Math.Log(invError, 2))); if (bufferCount < 2) { throw new Exception("bufferCount < 2"); } buffers = new double[bufferCount][]; countInBuffer = new int[bufferCount]; rand = SerializableRandom.CreateNew(Rand.Int()); }
/// <summary> /// Sets the seed used for random number generation. /// </summary> /// <param name="seed">Specify the seed to use for random number generation.</param> public void SetRandomSeed(int seed) => rand = SerializableRandom.CreateNew(seed);