/* nag_mills_ratio (g01mbc) Example Program. * * Copyright 2001 Numerical Algorithms Group. * * Mark 7, 2001. */ #include #include #include #include #include int main(int argc, char *argv[]) { FILE *fpin, *fpout; /* Scalars */ Integer exit_status = 0; double rm, x, xmu, xsig, z; Integer i; /* Check for command-line IO options */ fpin = nag_example_file_io(argc, argv, "-data", NULL); fpout = nag_example_file_io(argc, argv, "-results", NULL); fprintf(fpout, "nag_mills_ratio (g01mbc) Example Program Results\n"); /* Skip heading in data file */ fscanf(fpin, "%*[^\n] "); fprintf(fpout, "\n%2sMean%5sSigma%4sX%8sReciprocal", "", "", "", ""); fprintf(fpout, "\n Mills Ratio\n\n"); for (i = 1; i <= 3; ++i) { fscanf(fpin, "%lf%lf%lf%*[^\n] ", &x, &xmu, &xsig); z = (x - xmu) / xsig; /* nag_mills_ratio (g01mbc). * Computes reciprocal of Mills' Ratio */ rm = nag_mills_ratio(z) / xsig; fprintf(fpout, "%7.4f%2s%7.4f%2s%7.4f%2s%7.4f", xmu, "", xsig, "", x, "", rm); fprintf(fpout, "\n"); } if (fpin != stdin) fclose(fpin); if (fpout != stdout) fclose(fpout); return exit_status; }