8 double mean = 0.0, sum3 = 0.0, *v;
11 k = rint(4.0 * pow(0.75 * (n - 1.0) * (n - 1.0), 0.2));
13 while ((
double)(n / k) < 5.0)
16 if ((f = (
int *)calloc(k,
sizeof(
int))) ==
NULL) {
17 fprintf(stderr,
"Memory error in Cdhc_chi_square\n");
20 if ((v = (
double *)
malloc((k + 1) *
sizeof(
double))) ==
NULL) {
21 fprintf(stderr,
"Memory error in Cdhc_chi_square\n");
25 for (i = 0; i < n; ++i)
31 for (i = 1; i < k; ++i)
32 v[i] = -log(1.0 - (
double)i / k) /
mean;
36 for (i = 0; i < n; ++i) {
39 if (
x[i] > v[j] &&
x[i] <= v[j + 1]) {
47 for (i = 0; i < k; ++i)
50 y[0] = sum3 * k / n - n;
51 y[1] = (double)k - 2.0;
54 fprintf(stdout,
" TEST21 CS(E) =%10.4f DOF =%10.4f\n", y[0], y[1]);
double * Cdhc_chi_square_exp(double *x, int n)
float mean(IClass_statistics *statistics, int band)
Helper function for computing mean.