Exemple #1
0
        public Statistics(IEnumerable <double> values)
        {
            var sortedValues = new SegmentedList <double>(values.Where(d => !double.IsNaN(d)));

            sortedValues.Sort();
            if (sortedValues.Count < 1)
            {
                return;
            }

            var quartiles = Quartiles.FromSorted(sortedValues);

            Min    = quartiles.Min;
            Q1     = quartiles.Q1;
            Median = quartiles.Median;
            Q3     = quartiles.Q3;
            Max    = quartiles.Max;

            Mean = sortedValues.Average();

            var tukey = TukeyOutlierDetector.FromQuartiles(quartiles);

            LowerFence = tukey.LowerFence;
            UpperFence = tukey.UpperFence;

            P0   = SimpleQuantileEstimator.Instance.GetQuantileFromSorted(sortedValues, 0.0);
            P25  = SimpleQuantileEstimator.Instance.GetQuantileFromSorted(sortedValues, 0.25);
            P50  = SimpleQuantileEstimator.Instance.GetQuantileFromSorted(sortedValues, 0.50);
            P67  = SimpleQuantileEstimator.Instance.GetQuantileFromSorted(sortedValues, 0.67);
            P80  = SimpleQuantileEstimator.Instance.GetQuantileFromSorted(sortedValues, 0.80);
            P85  = SimpleQuantileEstimator.Instance.GetQuantileFromSorted(sortedValues, 0.85);
            P90  = SimpleQuantileEstimator.Instance.GetQuantileFromSorted(sortedValues, 0.90);
            P95  = SimpleQuantileEstimator.Instance.GetQuantileFromSorted(sortedValues, 0.95);
            P99  = SimpleQuantileEstimator.Instance.GetQuantileFromSorted(sortedValues, 0.99);
            P100 = SimpleQuantileEstimator.Instance.GetQuantileFromSorted(sortedValues, 1.00);
        }