10 double *xcopy, mean = 0.0, fx, fn2, sum4 = 0.0;
13 if ((xcopy = (
double *)
malloc(n *
sizeof(
double))) ==
NULL) {
14 fprintf(stderr,
"Memory error in cramer_von_mises_exp\n");
18 for (i = 0; i <
n; ++i) {
24 qsort(xcopy, n,
sizeof(
double),
dcmp);
26 for (i = 0; i <
n; ++i) {
33 fx = 1 - exp(xcopy[i] * (-1.0 / mean));
34 fn2 = (double)(2.0 * i + 1) / (2 *
n);
35 sum4 += (fx - fn2) * (fx - fn2);
42 y[0] = (1.0 / (n * 12) + sum4) * (0.16 / n + 1.0);
45 fprintf(stdout,
" TEST16 CVM(E) =%10.4f\n", y[0]);
int dcmp(const void *i, const void *j)
double * cramer_von_mises_exp(double *x, int n)