/* nag_gamma_dist (g01efc) Example Program. * * Copyright 1990 Numerical Algorithms Group. * * Mark 1, 1990. */ #include #include #include #include #include int main(int argc, char *argv[]) { FILE *fpin, *fpout; Integer exit_status = 0; double a, b, g, p; NagError fail; INIT_FAIL(fail); /* Check for command-line IO options */ fpin = nag_example_file_io(argc, argv, "-data", NULL); fpout = nag_example_file_io(argc, argv, "-results", NULL); /* Skip heading in data file */ fscanf(fpin, "%*[^\n]"); fprintf(fpout, "nag_gamma_dist (g01efc) Example Program Results\n"); fprintf(fpout, " Gamma deviate Alpha Beta Lower tail prob.\n\n"); while (fscanf(fpin, "%lf %lf %lf", &g, &a, &b) != EOF) { /* nag_gamma_dist (g01efc). * Probabilities for the gamma distribution */ p = nag_gamma_dist(Nag_LowerTail, g, a, b, &fail); if (fail.code != NE_NOERROR) { fprintf(fpout, "Error from nag_gamma_dist (g01efc).\n%s\n", fail.message); exit_status = 1; goto END; } fprintf(fpout, " %9.2f%13.2f%9.2f%14.4f\n", g, a, b, p); } END: if (fpin != stdin) fclose(fpin); if (fpout != stdout) fclose(fpout); return exit_status; }