GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d2c704037
geary.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <math.h>
3 
4 
5 double *Cdhc_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 }
#define x
double * Cdhc_geary_test(double *x, int n)
Definition: geary.c:5
float mean(IClass_statistics *statistics, int band)
Helper function for computing mean.