示例#1
0
        public static bool dagostino(double[] items, int alpha)
        {
            if (!(items.Length >= 1 && items.Length <= 1000))
            {
                throw new Exception("Dagostino function: it is required that count of samples be within [1, 1000].");
            }

            if (!(alpha == 95 || alpha == 99))
            {
                throw new Exception("Dagostino function: it is required that p be 95 or 99.");
            }


            items = items.OrderBy(i => i).ToArray();

            int n = (items.Length % 2) == 0 ? items.Length / 2 : (items.Length - 1) / 2;


            double sum = 0;

            for (int k = 1; k <= n; k++)
            {
                sum += ((items.Length + 1) / 2 - k) * (items[items.Length - k] - items[k - 1]);
            }

            double average = items.Average();
            double m       = items.Sum(i => Math.Pow(i - average, 2)) / items.Length;
            double y       = Math.Sqrt(items.Length) * (sum / (Math.Pow(items.Length, 2) * Math.Sqrt(m)) - 0.28209479) / 0.02998598;

            Tuple <float, float> range = Dagostino.GetValue(alpha, items.Length);

            return(y >= range.Item1 && y <= range.Item2);
        }
示例#2
0
        public static Tuple <double, double> tdagostino(int n, int alpha)
        {
            Tuple <float, float> result = Dagostino.GetValue(alpha, n);

            return(new Tuple <double, double>(result.Item1, result.Item2));
        }