/* nag_prob_beta_dist (g01eec) 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, p, pdf, q, tol, x; 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_prob_beta_dist (g01eec) Example Program Results\n"); fprintf(fpout, " x a b p q" " pdf\n\n"); while (fscanf(fpin, "%lf %lf %lf %lf", &x, &a, &b, &tol) != EOF) { /* nag_prob_beta_dist (g01eec). * Upper and lower tail probabilities and probability * density function for the beta distribution */ nag_prob_beta_dist(x, a, b, tol, &p, &q, &pdf, &fail); if (fail.code != NE_NOERROR) { fprintf(fpout, "Error from nag_prob_beta_dist (g01eec).\n%s\n", fail.message); exit_status = 1; goto END; } fprintf(fpout, "%7.4f%13.4e%13.4e%13.4e%13.4e%13.4e\n", x, a, b, p, q, pdf); } END: if (fpin != stdin) fclose(fpin); if (fpout != stdout) fclose(fpout); return exit_status; }