4 #include "local_proto.h" 11 double mean = 0.0, sdx = 0.0, fx, sqrt2, *xcopy;
13 sqrt2 = sqrt((
double)2.0);
16 if ((xcopy = (
double *)
malloc(n *
sizeof(
double))) ==
NULL) {
17 fprintf(stderr,
"Memory error in Cdhc_cramer_von_mises\n");
21 for (i = 0; i < n; ++i) {
26 sdx = sqrt((n * sdx - mean * mean) / (n * (n - 1.0)));
29 qsort(xcopy, n,
sizeof(
double),
Cdhc_dcmp);
31 for (i = 0; i < n; ++i) {
32 fx = 0.5 +
Cdhc_normp((xcopy[i] - mean) / sdx / sqrt2) / 2.0;
39 fx -= (2.0 * i + 1.0) / (2.0 * n);
42 y[1] += 1.0 / (double)(n * 12);
43 y[0] = y[1] * (0.5 / n + 1.0);
46 fprintf(stdout,
" TEST9 CVM(N) =%10.4f\n", y[0]);
double * Cdhc_cramer_von_mises(double *x, int n)
double Cdhc_normp(double)
int Cdhc_dcmp(const void *i, const void *j)
float mean(IClass_statistics *statistics, int band)
Helper function for computing mean.