/* nag_prob_1_sample_ks (g01eyc) 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 */ double d__, prob; Integer exit_status, n; 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); exit_status = 0; fprintf(fpout, "nag_prob_1_sample_ks (g01eyc) Example Program Results\n\n"); fprintf(fpout, "%s\n\n", " d n One-sided probability"); /* Skip heading in data file */ fscanf(fpin, "%*[^\n] "); while (fscanf(fpin, "%ld %lf%*[^\n] ", &n, &d__) != EOF) { /* nag_prob_1_sample_ks (g01eyc). * Computes probabilities for the one-sample * Kolmogorov-Smirnov distribution */ prob = nag_prob_1_sample_ks(n, d__, &fail); if (fail.code != NE_NOERROR) { fprintf(fpout, "Error from nag_prob_1_sample_ks (g01eyc).\n%s\n", fail.message); exit_status = 1; goto END; } fprintf(fpout, "%7.4f%2s%4ld%10s%7.4f\n", d__, "", n, "", prob); } END: if (fpin != stdin) fclose(fpin); if (fpout != stdout) fclose(fpout); return exit_status; }