public TypedValue CreateTypedValue() { var buckets = _histogram .Percentiles(3) .Select(v => new { v.CountAddedInThisIterationStep, v.ValueIteratedTo }) .GroupBy(v => v.ValueIteratedTo) .Select(v => v.First()) .ToList(); var bucketCounts = buckets.Select(v => v.CountAddedInThisIterationStep).ToList(); bucketCounts.Add(0); var bucketBounds = buckets.Select(v => (double)v.ValueIteratedTo).ToList(); var hasZeroLowerBounds = bucketBounds[0] == 0; if (!hasZeroLowerBounds) { bucketBounds.Insert(0, 0); bucketCounts.Insert(0, 0); } return(new TypedValue { DistributionValue = new Distribution { BucketCounts = { bucketCounts }, BucketOptions = new BucketOptions { ExplicitBuckets = new Explicit { Bounds = { bucketBounds } } }, Count = bucketCounts.Sum(), Mean = _histogram.GetMean(), SumOfSquaredDeviation = Math.Pow(_histogram.GetStdDeviation(), 2) * _histogram.TotalCount } }); }
public void WriteFooter(HistogramBase histogram) { // Calculate and output mean and std. deviation. // Note: mean/std. deviation numbers are very often completely irrelevant when // data is extremely non-normal in distribution (e.g. in cases of strong multi-modal // response time distribution associated with GC pauses). However, reporting these numbers // can be very useful for contrasting with the detailed percentile distribution // reported by outputPercentileDistribution(). It is not at all surprising to find // percentile distributions where results fall many tens or even hundreds of standard // deviations away from the mean - such results simply indicate that the data sampled // exhibits a very non-normal distribution, highlighting situations for which the std. // deviation metric is a useless indicator. var mean = histogram.GetMean() / _outputValueUnitScalingRatio; var stdDeviation = histogram.GetStdDeviation() / _outputValueUnitScalingRatio; _printStream.Write(_footerLine1FormatString, mean, stdDeviation); _printStream.Write(_footerLine2FormatString, histogram.GetMaxValue() / _outputValueUnitScalingRatio, histogram.TotalCount); _printStream.Write(_footerLine3FormatString, histogram.BucketCount, histogram.SubBucketCount); }