Exemplo n.º 1
1
        public static StatSummary CalculateSummaries(IList<decimal> vals)
        {
            var res = new StatSummary();

            res.Count = vals.Count;
            res.Average = vals.Average();

            var sorted = new List<decimal>(vals);
            sorted.Sort();

            res.Median = CalculateQuantile(sorted, 0.5M);
            res.LowerQuartile = CalculateQuantile(sorted, 0.25M);
            res.UpperQuartile = CalculateQuantile(sorted, 0.75M);

            res.Min = sorted.First();
            res.Max = sorted.Last();

            res.Percentile2 = CalculateQuantile(sorted, 0.02M);
            res.Percentile98 = CalculateQuantile(sorted, 0.98M);

            Validate(sorted, res);
            return res;
        }
Exemplo n.º 2
0
 static void Validate(ICollection<decimal> vals, StatSummary summary)
 {
     ValidateSplitterValue(vals, summary.Median, 0.5M);
     ValidateSplitterValue(vals, summary.LowerQuartile, 0.25M);
     ValidateSplitterValue(vals, summary.UpperQuartile, 0.75M);
 }