// my_pgamma - evaluate the distribution function of the gamma distribution // a demo of the R standalone math library // // Written in 2020 by Charles J. Geyer // // To the extent possible under law, the author(s) have dedicated all // copyright and related and neighboring rights to this software to // the public domain worldwide. This software is distributed without // any warranty. // // See the CC0 Public Domain Dedication // . #define MATHLIB_STANDALONE #include #include #include #include int main(int argc, char *argv[]) { if (argc != 4) { fputs("Usage: my_pgamma x alpha beta\n" "where x is a real number and alpha and beta" " are postive real numbers\n" "the shape and scale parameters (respectively)\n", stderr); return EXIT_FAILURE; } double x, alpha, beta; if (sscanf(argv[1], "%lg", &x) != 1) { fputs("failed to read x\n", stderr); return EXIT_FAILURE; } if (sscanf(argv[2], "%lg", &alpha) != 1) { fputs("failed to read alpha\n", stderr); return EXIT_FAILURE; } if (sscanf(argv[3], "%lg", &beta) != 1) { fputs("failed to read beta\n", stderr); return EXIT_FAILURE; } double result = pgamma(x, alpha, beta, true, false); printf("pgamma(x, alpha, beta) = %g\n", result); return EXIT_SUCCESS; }