4 #include "local_proto.h"
10 double sqrt2,
mean = 0.0, sdx = 0.0, *xcopy, fx;
12 if ((xcopy = (
double *)
malloc(n *
sizeof(
double))) ==
NULL) {
13 fprintf(stderr,
"Memory error in Cdhc_anderson_darling\n");
17 sqrt2 = sqrt((
double)2.0);
20 for (i = 0; i < n; ++i) {
25 sdx = sqrt((n * sdx -
mean *
mean) / (n * (n - 1.0)));
28 qsort(xcopy, n,
sizeof(
double),
Cdhc_dcmp);
30 for (i = 0; i < n; ++i)
31 xcopy[i] = (xcopy[i] -
mean) / sdx;
33 for (i = 0; i < n; ++i) {
41 y[1] += (2.0 * i + 1.0) * log(fx) + (2.0 * (n - i) - 1.0) * log(1 - fx);
44 y[0] = y[1] * (0.75 / n + 1.0 + 2.25 / (n * n));
47 fprintf(stdout,
" TEST8 AD(N) =%10.4f\n", y[0]);
double * Cdhc_anderson_darling(double *x, int n)
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.