4 #include "local_proto.h"
10 double *xcopy, sumx = 0.0, sumx2 = 0.0, s2, *
b, *c, *
g, *z, sqrt2;
13 if ((
b = (
double *)
malloc(n *
sizeof(
double))) ==
NULL) {
14 fprintf(stderr,
"Memory error in Cdhc_durbins_exact\n");
17 if ((c = (
double *)
malloc((n + 1) *
sizeof(
double))) ==
NULL) {
18 fprintf(stderr,
"Memory error in Cdhc_durbins_exact\n");
21 if ((
g = (
double *)
malloc((n + 1) *
sizeof(
double))) ==
NULL) {
22 fprintf(stderr,
"Memory error in Cdhc_durbins_exact\n");
25 if ((z = (
double *)
malloc(n *
sizeof(
double))) ==
NULL) {
26 fprintf(stderr,
"Memory error in Cdhc_durbins_exact\n");
29 if ((xcopy = (
double *)
malloc(n *
sizeof(
double))) ==
NULL) {
30 fprintf(stderr,
"Memory error in Cdhc_durbins_exact\n");
34 sqrt2 = sqrt((
double)2.0);
35 for (i = 0; i < n; ++i) {
41 s2 = sqrt((sumx2 - sumx * sumx / n) / (n - 1));
42 for (i = 0; i < n; ++i) {
43 xcopy[i] = (xcopy[i] - sumx / n) / s2;
49 for (i = 1; i < n; ++i)
50 c[i] =
b[i] -
b[i - 1];
55 qsort(c, n + 1,
sizeof(
double),
Cdhc_dcmp);
57 for (j = 1; j <= n; ++j)
58 g[j] = (n + 1 - j) * (c[j] - c[j - 1]);
60 g[0] = (n + 1) * c[0];
61 g[n] = c[n] - c[n - 1];
63 for (i = 0; i < n; ++i) {
65 for (j = 0; j <= i; ++j)
68 z[i] = (i + 1.0) / n - z[i];
74 y[1] = sqrt((
double)n) * z[n - 1];
77 fprintf(stdout,
" TEST7 DRB(N) =%10.4f\n", y[0]);
int Cdhc_dcmp(const void *i, const void *j)
double Cdhc_normp(double)
double * Cdhc_durbins_exact(double *x, int n)