示例#1
0
        /// <summary>
        /// Add all samples stored in another QuantileEstimator, compacting them as necessary.
        /// </summary>
        /// <param name="that"></param>
        public void Add(QuantileEstimator that)
        {
            if (that == this)
            {
                throw new ArgumentException("Argument is the same object as this", nameof(that));
            }
            // Add the samples stored in all buffers, in increasing height.
            int height = that.lowestBufferHeight;

            for (int bufferIndex = that.lowestBufferIndex; ; height++)
            {
                double[] buffer = that.buffers[bufferIndex];
                int      count  = that.countInBuffer[bufferIndex];
                for (int i = 0; i < count; i++)
                {
                    AddAtHeight(buffer[i], height);
                }
                bufferIndex = (bufferIndex + 1) % that.buffers.Length;
                if (bufferIndex == that.lowestBufferIndex)
                {
                    break;
                }
            }
            Add(that.nextSample, that.reservoirCount);
        }
示例#2
0
 /// <summary>
 /// Returns true if that contains the same information as this.
 /// </summary>
 /// <param name="that"></param>
 /// <returns></returns>
 public bool ValueEquals(QuantileEstimator that)
 {
     return((this.MaximumError == that.MaximumError) &&
            this.buffers.JaggedValueEquals(that.buffers) &&
            this.countInBuffer.ValueEquals(that.countInBuffer) &&
            (this.lowestBufferIndex == that.lowestBufferIndex) &&
            (this.lowestBufferHeight == that.lowestBufferHeight) &&
            (this.nextSample == that.nextSample) &&
            (this.reservoirCount == that.reservoirCount));
 }