GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-8828094037
kotz.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <math.h>
3 
4 double *Cdhc_kotz_families(double *x, int n)
5 {
6  static double y[2];
7  int i;
8  double a1, a2, b3, c1, c2, c3, c4, c5, c6, lx;
9  double sum2 = 0.0, sum4 = 0.0;
10 
11  for (i = 0; i < n; ++i) {
12  sum2 += log(x[i]);
13  }
14 
15  a1 = sum2 / n;
16 
17  for (i = 0; i < n; ++i) {
18  lx = log(x[i]);
19  sum4 += (lx - a1) * (lx - a1);
20  }
21 
22  a2 = sum4 / n;
23  b3 = exp(a1 * 2 + a2) * (exp(a2) - 1);
24  c1 = log(a2 / b3);
25  c2 = (exp(a2 * 4) + exp(a2 * 3) * 2 - 4) / 4 - a2 + exp(a2) * 0.75;
26  c3 = a2 * (exp(a2) * 2 - 1) * (exp(a2) * 2 - 1);
27  c4 = (exp(a2) - 1) * 2 * (exp(a2) - 1);
28  c5 = c3 / c4;
29 
30  if (c2 < c5) {
31 #ifdef NOISY
32  fprintf(stdout, " WARNING!!! STATISTICS FOR THE NEXT TEST WILL\n");
33  fprintf(stdout, " NOT BE CALCULATED DUE TO SMALL LOGVARIANCE\n");
34 #endif /* NOISY */
35  y[0] = 999999999.;
36  }
37  else {
38  c6 = sqrt(c2 - c5) * 2.0 * sqrt((double)n);
39  y[0] = c1 / c6;
40  }
41 
42 #ifdef NOISY
43  fprintf(stdout, " TEST24 KT(LN) =%10.4f\n", y[0]);
44 #endif /* NOISY */
45 
46  return y;
47 }
double * Cdhc_kotz_families(double *x, int n)
Definition: kotz.c:4
#define x