/* nag_rank_ci_1var (g07eac) Example Program.
*
* NAGPRODCODE Version.
*
* Copyright 2016 Numerical Algorithms Group.
*
* Mark 26, 2016.
*/
#include <stdio.h>
#include <nag.h>
#include <nag_stdlib.h>
#include <nagg07.h>
int main(void)
{
/* Scalars */
double clevel, estcl, theta, thetal, thetau, wlower, wupper;
Integer exit_status, i, n;
NagError fail;
/* Arrays */
double *x = 0;
INIT_FAIL(fail);
exit_status = 0;
printf("nag_rank_ci_1var (g07eac) Example Program Results\n");
/* Skip heading in data file */
scanf("%*[^\n] ");
scanf("%" NAG_IFMT "%*[^\n] ", &n);
/* Allocate memory */
if (!(x = NAG_ALLOC(n, double)))
{
printf("Allocation failure\n");
exit_status = -1;
goto END;
}
for (i = 1; i <= n; ++i)
scanf("%lf", &x[i - 1]);
scanf("%*[^\n] ");
scanf("%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) {
printf("Error from nag_rank_ci_1var (g07eac).\n%s\n", fail.message);
exit_status = 1;
goto END;
}
printf("\n");
printf(" Location estimator Confidence Interval\n");
printf("\n");
printf("%10.4f ( %6.4f , %6.4f )\n", theta, thetal, thetau);
printf("\n");
printf(" Corresponding Wilcoxon statistics\n");
printf("\n");
printf(" Lower : %8.2f\n", wlower);
printf(" Upper : %8.2f\n", wupper);
END:
NAG_FREE(x);
return exit_status;
}