/* nag_univar_outlier_peirce_2var (g07gbc) Example Program.
*
* Copyright 2021 Numerical Algorithms Group.
*
* Mark 27.2, 2021.
*/
/* Pre-processor includes */
#include <math.h>
#include <nag.h>
#include <stdio.h>
int main(void) {
/* Integer scalar and array declarations */
Integer n, exit_status;
/* NAG structures and types */
Nag_Boolean outlier;
NagError fail;
/* Double scalar and array declarations */
double e, var1, var2, x, lx, ux;
/* Initialize the error structure */
INIT_FAIL(fail);
exit_status = 0;
printf("nag_univar_outlier_peirce_2var (g07gbc) Example Program Results\n");
/* Skip headings in data file */
scanf("%*[^\n] ");
/* Loop through all the lines in the input file, reading in the sample size,
variances and value to test */
while (scanf("%" NAG_IFMT " %lf %lf %lf%*[^\n] ", &n, &e, &var1, &var2) !=
EOF) {
/* Use nag_univar_outlier_peirce_2var (g07gbc) to check whether e is a
potential outlier */
outlier =
nag_univar_outlier_peirce_2var(n, e, var1, var2, &x, &lx, &ux, &fail);
if (fail.code != NE_NOERROR) {
printf("Error from nag_univar_outlier_peirce_2var (g07gbc).\n%s\n",
fail.message);
exit_status = 1;
goto END;
}
/* Display the results */
printf(" Sample size : %10" NAG_IFMT "\n", n);
printf(" Largest absolute residual (E) : %10.3f\n", e);
printf(" Variance for whole sample : %10.3f\n", var1);
printf(" Variance excluding E : %10.3f\n", var2);
printf(" Estimate for cutoff (X) : %10.3f\n", x);
printf(" Lower limit for cutoff (LX) : %10.3f\n", lx);
printf(" Upper limit for cutoff (UX) : %10.3f\n", ux);
if (outlier)
printf(" E is a potential outlier\n");
else
printf(" E does not appear to be an outlier\n");
printf("\n");
}
END:
return exit_status;
}