/* nag_median_test (g08acc) Example Program. * * Copyright 2000 Numerical Algorithms Group. * * Mark 6, 2000. */ #include #include #include #include int main (void) { Integer above, below, exit_status=0, i, n1, n2; NagError fail; double p, *x=0, *y=0; INIT_FAIL(fail); Vprintf("nag_median_test (g08acc) Example Program Results\n"); /* Skip heading in data file */ Vscanf("%*[^\n]"); n1 = 16; n2 = 23; if (!(x = NAG_ALLOC(n1, double)) || !(y = NAG_ALLOC(n2, double))) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } for (i = 1; i <= n1; ++i) Vscanf("%lf", &x[i - 1]); for (i = 1; i <= n2; ++i) Vscanf("%lf", &y[i - 1]); Vprintf("\nMedian test\n\n"); Vprintf("Data values\n\n"); Vprintf(" Group 1 "); for (i = 1; i <= n1; ++i) Vprintf("%4.0f%s", x[i - 1], i%8?"":"\n "); Vprintf("\n"); Vprintf(" Group 2 "); for (i = 1; i <= n2; ++i) Vprintf("%4.0f%s", y[i - 1], i%8?"":"\n "); Vprintf("\n"); /* nag_median_test (g08acc). * Median test on two samples of unequal size */ nag_median_test(n1, x, n2, y, &above, &below, &p, &fail); if (fail.code != NE_NOERROR) { Vprintf("Error from nag_median_test (g08acc).\n%s\n", fail.message); exit_status = 1; goto END; } Vprintf("\n"); Vprintf("%6ld%s\n", above, " scores below median in group 1"); Vprintf("%6ld%s\n", below, " scores below median in group 2"); Vprintf("\n%s%8.5f\n", " Significance ", p); END: if (x) NAG_FREE(x); if (y) NAG_FREE(y); return exit_status; }