/* nag_rank_ci_1var (g07eac) 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, wlower, wupper; Integer exit_status, i, n; NagError fail; /* Arrays */ double *x = 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_1var (g07eac) Example Program Results\n"); /* Skip heading in data file */ fscanf(fpin, "%*[^\n] "); fscanf(fpin, "%ld%*[^\n] ", &n); /* Allocate memory */ if (!(x = NAG_ALLOC(n, double))) { fprintf(fpout, "Allocation failure\n"); exit_status = -1; goto END; } for (i = 1; i <= n; ++i) fscanf(fpin, "%lf", &x[i - 1]); fscanf(fpin, "%*[^\n] "); fscanf(fpin, "%lf%*[^\n] ", &clevel); /* nag_rank_ci_1var (g07eac). * Robust confidence intervals, one-sample */ nag_rank_ci_1var(Nag_RCI_Exact, n, x, clevel, &theta, &thetal, &thetau, &estcl, &wlower, &wupper, &fail); if (fail.code != NE_NOERROR) { fprintf(fpout, "Error from nag_rank_ci_1var (g07eac).\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 Wilcoxon statistics\n"); fprintf(fpout, "\n"); fprintf(fpout, " Lower : %8.2f\n", wlower); fprintf(fpout, " Upper : %8.2f\n", wupper); END: if (fpin != stdin) fclose(fpin); if (fpout != stdout) fclose(fpout); if (x) NAG_FREE(x); return exit_status; }