/* nag_prob_chi_sq (g01ecc) Example Program. * * Copyright 1990 Numerical Algorithms Group. * * Mark 1, 1990. */ #include #include #include #include int main(void) { double df, prob, x; static NagError fail; /* Skip heading in data file */ Vscanf("%*[^\n]"); Vprintf("nag_prob_chi_sq (g01ecc) Example Program Results\n"); Vprintf(" x df prob\n\n"); while (scanf("%lf %lf", &x, &df) != EOF) { /* nag_prob_chi_sq (g01ecc). * Probabilities for chi^2 distribution */ prob = nag_prob_chi_sq(Nag_LowerTail, x, df, &fail); if (fail.code==NE_NOERROR) Vprintf("%6.3f%8.3f%8.4f\n", x, df, prob); else { Vprintf("%6.3f%8.3f%8.4f\n Note: %s\n", x, df, prob, fail.message); return EXIT_FAILURE; } } return EXIT_SUCCESS; }