HdrHistogram.HistogramBase.MedianEquivalentValue C# (CSharp) Method

MedianEquivalentValue() public method

Get a value that lies in the middle (rounded up) of the range of values equivalent the given value. Where "equivalent" means that value samples recorded for any two equivalent values are counted in a common total count.
public MedianEquivalentValue ( long value ) : long
value long The given value
return long
        public long MedianEquivalentValue(long value)
        {
            return LowestEquivalentValue(value)
                + (SizeOfEquivalentValueRange(value) >> 1);
        }

Usage Example

示例#1
0
        /// <summary>
        /// Get the computed standard deviation of all recorded values in the histogram
        /// </summary>
        /// <returns>the standard deviation (in value units) of the histogram data</returns>
        public static double GetStdDeviation(this HistogramBase histogram)
        {
            var mean = histogram.GetMean();
            var geometricDeviationTotal = 0.0;

            foreach (var iterationValue in histogram.RecordedValues())
            {
                double deviation = (histogram.MedianEquivalentValue(iterationValue.ValueIteratedTo) * 1.0) - mean;
                geometricDeviationTotal += (deviation * deviation) * iterationValue.CountAddedInThisIterationStep;
            }
            var stdDeviation = Math.Sqrt(geometricDeviationTotal / histogram.TotalCount);

            return(stdDeviation);
        }