/* nag_bivariate_normal_dist (g01hac) 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 prob, rho, x, y; 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_bivariate_normal_dist (g01hac) Example Program Results\n"); fprintf(fpout, " x y rho prob\n\n"); while (fscanf(fpin, "%lf %lf %lf", &x, &y, &rho) != EOF) { /* nag_bivariate_normal_dist (g01hac). * Probability for the bivariate Normal distribution */ prob = nag_bivariate_normal_dist(x, y, rho, &fail); if (fail.code != NE_NOERROR) { fprintf(fpout, "Error from nag_bivariate_normal_dist (g01hac).\n%s\n", fail.message); exit_status = 1; goto END; } fprintf(fpout, "%8.3f%8.3f%8.3f%8.4f\n", x, y, rho, prob); } END: if (fpin != stdin) fclose(fpin); if (fpout != stdout) fclose(fpout); return exit_status; }