GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-d6dec75dd4
geary.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <math.h>
3 
4 double *Cdhc_geary_test(double *x, int n)
5 {
6  int i;
7  static double y[2];
8  double diff, s = 0.0, mean = 0.0;
9 
10  y[0] = 0.0;
11  for (i = 0; i < n; ++i)
12  mean += x[i];
13 
14  mean /= n;
15 
16  for (i = 0; i < n; ++i) {
17  diff = x[i] - mean;
18  y[0] += fabs(diff);
19  s += diff * diff;
20  }
21 
22  s *= n;
23  y[0] /= sqrt(s);
24  y[1] = (y[0] - 0.7979) * sqrt((double)n) / 0.2123;
25 
26 #ifdef NOISY
27  fprintf(stdout, " TEST2 GTN =%10.4f Z(GTN) =%10.4f\n", y[0], y[1]);
28 #endif /* NOISY */
29 
30  return y;
31 }
double * Cdhc_geary_test(double *x, int n)
Definition: geary.c:4
float mean(IClass_statistics *statistics, int band)
Helper function for computing mean.
#define x