4 #include "local_proto.h"
8 double *xcopy,
mean = 0.0, sdx = 0.0, sqrt2, zbar = 0.0;
9 double fn2, fx, sum4 = 0.0;
13 sqrt2 = sqrt((
double)2.0);
15 if ((xcopy = (
double *)
malloc(n *
sizeof(
double))) ==
NULL) {
16 fprintf(stderr,
"Memory error in Cdhc_anderson_darling\n");
20 for (i = 0; i < n; ++i) {
25 sdx = sqrt((n * sdx -
mean *
mean) / (n * (n - 1)));
28 qsort(xcopy, n,
sizeof(
double),
Cdhc_dcmp);
30 for (i = 0; i < n; ++i) {
31 xcopy[i] = (xcopy[i] -
mean) / sdx;
32 fn2 = (2.0 * (i + 1) - 1.0) / (2.0 * n);
42 sum4 += (fx - fn2) * (fx - fn2);
46 y[0] = (1.0 / (n * 12) + sum4) - n * (zbar - .5) * (zbar - .5);
47 y[0] *= 0.5 / n + 1.0;
50 fprintf(stdout,
" TEST6 WU2(N) =%10.4f\n", y[0]);
int Cdhc_dcmp(const void *i, const void *j)
double Cdhc_normp(double)
float mean(IClass_statistics *statistics, int band)
Helper function for computing mean.
double * Cdhc_watson_u2(double *x, int n)