4 #include "local_proto.h" 11 double sqrt2,
mean = 0.0, sdx = 0.0, *xcopy, fx;
13 if ((xcopy = (
double *)
malloc(n *
sizeof(
double))) ==
NULL) {
14 fprintf(stderr,
"Memory error in Cdhc_anderson_darling\n");
18 sqrt2 = sqrt((
double)2.0);
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 xcopy[i] = (xcopy[i] - mean) / sdx;
34 for (i = 0; i < n; ++i) {
43 (2.0 * i + 1.0) * log(fx) + (2.0 * (n - i) - 1.0) * log(1 - fx);
46 y[0] = y[1] * (0.75 / n + 1.0 + 2.25 / (n * n));
49 fprintf(stdout,
" TEST8 AD(N) =%10.4f\n", y[0]);
double * Cdhc_anderson_darling(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.