9 double *xcopy, mean = 0.0, sdx = 0.0, sqrt2, zbar = 0.0;
10 double fn2, fx, sum4 = 0.0;
14 sqrt2 = sqrt((
double)2.0);
16 if ((xcopy = (
double *)
malloc(n *
sizeof(
double))) ==
NULL) {
17 fprintf(stderr,
"Memory error in anderson_darling\n");
21 for (i = 0; i <
n; ++i) {
26 sdx = sqrt((n * sdx - mean * mean) / (n * (n - 1)));
29 qsort(xcopy, n,
sizeof(
double),
dcmp);
31 for (i = 0; i <
n; ++i) {
32 xcopy[i] = (xcopy[i] - mean) / sdx;
33 fn2 = (2.0 * (i + 1) - 1.0) / (2.0 *
n);
34 fx = 0.5 +
normp(xcopy[i] / sqrt2) / 2.0;
43 sum4 += (fx - fn2) * (fx - fn2);
47 y[0] = (1.0 / (n * 12) + sum4) - n * (zbar - .5) * (zbar - .5);
48 y[0] *= 0.5 / n + 1.0;
51 fprintf(stdout,
" TEST6 WU2(N) =%10.4f\n", y[0]);
int dcmp(const void *i, const void *j)
double * watson_u2(double *x, int n)