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