GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d2c704037
omnibus.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <math.h>
3 
4 
5 double *Cdhc_omnibus_moments(double *x, int n)
6 {
7  double diff, mean = 0., fssm, tssm, sum_cube = 0., sum_four = 0.,
8  sum_sq = 0.;
9  static double y[2];
10  int i;
11 
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  sum_sq += diff * diff;
20  sum_cube += diff * diff * diff;
21  sum_four += diff * diff * diff * diff;
22  }
23 
24  /*
25  fprintf (stdout,"n %d x-bar %g sum^2 %g sum^3 %g sum^4 %g \n",n,mean,sum_sq,sum_cube,sum_four);
26  */
27  tssm = sqrt((double)n) * sum_cube / pow(sum_sq, 1.5);
28  fssm = n * sum_four / (sum_sq * sum_sq);
29 
30 #ifdef NOISY
31  fprintf(stdout,
32  " TESTS OF COMPOSITE DISTRIBUTIONAL HYPOTHESES\n");
33  fprintf(stdout, " TEST1 TSM =%10.4f FSM =%10.4f\n", tssm, fssm);
34 #endif /* NOISY */
35 
36  y[0] = tssm;
37  y[1] = fssm;
38 
39  return y;
40 }
double * Cdhc_omnibus_moments(double *x, int n)
Definition: omnibus.c:5
#define x
float mean(IClass_statistics *statistics, int band)
Helper function for computing mean.