示例#1
0
        public static bool shapiro(double[] items, int p)
        {
            if (!(items.Length >= 2 || items.Length <= 50))
            {
                throw new Exception("Shapiro function: it is required that count of samples be within [2, 50].");
            }

            if (!(p == 95 || p == 99))
            {
                throw new Exception("Shapiro 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 s = 0;

            for (int k = 1; k <= n; k++)
            {
                s += Shapiro.GetAlpha(k, items.Length) * (items[items.Length - k] - items[k - 1]);
            }

            double avarage = items.Average();
            double w       = Math.Pow(s, 2) / items.Sum(i => Math.Pow(i - avarage, 2));

            return(w > Shapiro.GetW(items.Length, p));
        }
示例#2
0
 public static double tshapirow(int n, int p)
 {
     return(Shapiro.GetW(n, p));
 }
示例#3
0
 public static double tshapiroa(int n1, int n2)
 {
     return(Shapiro.GetAlpha(n1, n2));
 }