4 #include "local_proto.h" 10 double sqrt2,
mean = 0.0, *xcopy, fx, sum3 = 0.0;
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);
20 for (i = 0; i < n; ++i) {
25 qsort(xcopy, n,
sizeof(
double),
Cdhc_dcmp);
27 for (i = 0; i < n; ++i) {
28 fx = 1 - exp(-xcopy[i] / mean);
29 sum3 += (2.0 * i + 1) * (log(fx) - xcopy[n - i - 1] /
mean);
32 y[0] = (1.0 + 0.3 / n) * (-n - sum3 / n);
34 fprintf(stdout,
" TEST20 AD(E) =%10.4f\n", y[0]);
int Cdhc_dcmp(const void *i, const void *j)
float mean(IClass_statistics *statistics, int band)
Helper function for computing mean.
double * Cdhc_anderson_darling_exp(double *x, int n)