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