GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
geary.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <math.h>
3 
4 
5 double *geary_test(double *x, int n)
6 {
7  int i;
8  static double y[2];
9  double diff, s = 0.0, mean = 0.0;
10 
11  y[0] = 0.0;
12  for (i = 0; i < n; ++i)
13  mean += x[i];
14 
15  mean /= n;
16 
17  for (i = 0; i < n; ++i) {
18  diff = x[i] - mean;
19  y[0] += fabs(diff);
20  s += diff * diff;
21  }
22 
23  s *= n;
24  y[0] /= sqrt(s);
25  y[1] = (y[0] - 0.7979) * sqrt((double)n) / 0.2123;
26 
27 #ifdef NOISY
28  fprintf(stdout, " TEST2 GTN =%10.4f Z(GTN) =%10.4f\n", y[0], y[1]);
29 #endif /* NOISY */
30 
31  return y;
32 }
int y
Definition: plot.c:34
double * geary_test(double *x, int n)
Definition: geary.c:5
int n
Definition: dataquad.c:291