/* nag_outlier_peirce_two_var (g07gbc) Example Program. * * Copyright 2009, Numerical Algorithms Group. * * Mark 23, 2011. */ /* Pre-processor includes */ #include #include #include #include #include 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; /* Initialise the error structure */ INIT_FAIL(fail); exit_status = 0; printf( "nag_outlier_peirce_two_var (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("%ld %lf %lf %lf%*[^\n] ", &n, &e, &var1, &var2) != EOF) { /* Use nag_outlier_peirce_two_var (g07gbc) to check whether e is a potential outlier */ outlier = nag_outlier_peirce_two_var(n, e, var1, var2, &x, &lx, &ux, &fail); if (fail.code != NE_NOERROR) { printf("Error from nag_outlier_peirce_two_var (g07gbc).\n%s\n", fail.message); exit_status = 1; goto END; } /* Display the results */ printf(" Sample size : %10ld\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; }