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