9 double mean = 0.0, sum3 = 0.0, *v;
12 k = rint(4.0 * pow(0.75 * (n - 1.0) * (n - 1.0), 0.2));
14 while ((
double)(n / k) < 5.0)
17 if ((f = (
int *)calloc(k,
sizeof(
int))) ==
NULL) {
18 fprintf(stderr,
"Memory error in chi_square\n");
21 if ((v = (
double *)
malloc((k + 1) *
sizeof(
double))) ==
NULL) {
22 fprintf(stderr,
"Memory error in chi_square\n");
26 for (i = 0; i <
n; ++i)
32 for (i = 1; i < k; ++i)
33 v[i] = -
log(1.0 - (
double)i / k) / mean;
37 for (i = 0; i <
n; ++i) {
40 if (x[i] > v[j] && x[i] <= v[j + 1]) {
48 for (i = 0; i < k; ++i)
51 y[0] = sum3 * k / n -
n;
52 y[1] = (double)k - 2.0;
55 fprintf(stdout,
" TEST21 CS(E) =%10.4f DOF =%10.4f\n", y[0], y[1]);
double * chi_square_exp(double *x, int n)