GRASS Programmer's Manual  6.4.2(2012)
shapiroe.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <math.h>
00003 
00004 
00005 double *shapiro_wilk_exp(double *x, int n)
00006 {
00007     static double y[2];
00008     double mean, b, s1, xs, sum1 = 0.0, sum2 = 0.0;
00009     int i;
00010 
00011     for (i = 0; i < n; ++i)
00012         if (i == 0 || xs > x[i])
00013             xs = x[i];
00014 
00015     for (i = 0; i < n; ++i) {
00016         sum1 += x[i];
00017         sum2 += x[i] * x[i];
00018     }
00019 
00020     s1 = sum2 - sum1 * sum1 / n;
00021     mean = sum1 / n;
00022     b = (mean - xs) * sqrt((double)n / (n - 1.0));
00023     y[0] = b * b / s1;
00024 
00025 #ifdef NOISY
00026     fprintf(stdout, "  TEST15 SW(E)  =%10.4f\n", y[0]);
00027 #endif /* NOISY */
00028 
00029     return y;
00030 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines