16 double *a, eps,
w, pw, mean = 0, ssq = 0, *xcopy;
19 n2 = (
int)floor((
double)n / 2);
22 if ((a = (
double *)
malloc(n2 *
sizeof(
double))) ==
NULL) {
23 fprintf(stderr,
"Memory error in royston\n");
26 if ((xcopy = (
double *)
malloc(n *
sizeof(
double))) ==
NULL) {
27 fprintf(stderr,
"Memory error in royston\n");
32 for (i = 0; i <
n; ++i) {
38 qsort(xcopy, n,
sizeof(
double),
dcmp);
40 for (i = 0; i <
n; ++i)
41 ssq += (mean - x[i]) * (mean - x[i]);
43 wcoef(a, n, n2, &eps, &ifault);
46 wext(xcopy, n, ssq, a, n2, eps, &w, &pw, &ifault);
48 fprintf(stderr,
"Error in wcoef()\n");
49 return (
double *)
NULL;
57 fprintf(stderr,
"Error in wcoef()\n");
58 return (
double *)
NULL;
int dcmp(const void *i, const void *j)
void wext(double x[], int n, double ssq, double a[], int n2, double eps, double *w, double *pw, int *ifault)
double * royston(double *x, int n)
void wcoef(double a[], int n, int n2, double *eps, int *ifault)