/* nag_univar_robust_1var_ci (g07eac) Example Program.
*
* Copyright 2024 Numerical Algorithms Group.
*
* Mark 30.1, 2024.
*/
#include <nag.h>
#include <stdio.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_univar_robust_1var_ci (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_univar_robust_1var_ci (g07eac).
* Robust confidence intervals, one-sample
*/
nag_univar_robust_1var_ci(Nag_RCI_Exact, n, x, clevel, &theta, &thetal,
&thetau, &estcl, &wlower, &wupper, &fail);
if (fail.code != NE_NOERROR) {
printf("Error from nag_univar_robust_1var_ci (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;
}