/* nag_rank_ci_2var (g07ebc) Example Program. * * Copyright 2001 Numerical Algorithms Group. * * Mark 7, 2001. */ #include #include #include #include #include int main(int argc, char *argv[]) { FILE *fpin, *fpout; /* Scalars */ double clevel, estcl, theta, thetal, thetau, ulower, uupper; Integer exit_status, i, m, n; NagError fail; /* Arrays */ double *wrk = 0, *x = 0, *y = 0; Integer *iwrk = 0; INIT_FAIL(fail); /* Check for command-line IO options */ fpin = nag_example_file_io(argc, argv, "-data", NULL); fpout = nag_example_file_io(argc, argv, "-results", NULL); exit_status = 0; fprintf(fpout, "nag_rank_ci_2var (g07ebc) Example Program Results\n"); /* Skip Heading in data file */ fscanf(fpin, "%*[^\n] %ld%ld%*[^\n] ", &n, &m); /* Allocate memory */ if (!(wrk = NAG_ALLOC(600, double)) || !(x = NAG_ALLOC(n, double)) || !(y = NAG_ALLOC(m, double)) || !(iwrk = NAG_ALLOC(300, Integer))) { fprintf(fpout, "Allocation failure\n"); exit_status = -1; goto END; } fscanf(fpin, " %*[^\n] "); for (i = 1; i <= n; ++i) fscanf(fpin, "%lf", &x[i - 1]); fscanf(fpin, " %*[^\n] "); for (i = 1; i <= m; ++i) fscanf(fpin, "%lf", &y[i - 1]); fscanf(fpin, " %*[^\n] "); fscanf(fpin, " %lf%*[^\n] ", &clevel); /* nag_rank_ci_2var (g07ebc). * Robust confidence intervals, two-sample */ nag_rank_ci_2var(Nag_RCI_Approx, n, x, m, y, clevel, &theta, &thetal, &thetau, &estcl, &ulower, &uupper, &fail); if (fail.code != NE_NOERROR) { fprintf(fpout, "Error from nag_rank_ci_2var (g07ebc).\n%s\n", fail.message); exit_status = 1; goto END; } fprintf(fpout, "\n"); fprintf(fpout, " Location estimator Confidence Interval\n"); fprintf(fpout, "\n"); fprintf(fpout, " %10.4f ( %6.4f , %6.4f )\n", theta, thetal, thetau); fprintf(fpout, "\n"); fprintf(fpout, " Corresponding Mann-Whitney U statistics\n"); fprintf(fpout, "\n"); fprintf(fpout, " Lower : %8.2f\n Upper : %8.2f\n", ulower, uupper); END: if (fpin != stdin) fclose(fpin); if (fpout != stdout) fclose(fpout); if (wrk) NAG_FREE(wrk); if (x) NAG_FREE(x); if (y) NAG_FREE(y); if (iwrk) NAG_FREE(iwrk); return exit_status; }