/* nag_gamma_pdf (g01kfc) Example Program.
*
* Copyright 2014 Numerical Algorithms Group.
*
* Mark 9, 2009.
*/
/* Pre-processor includes */
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <nag.h>
#include <nag_stdlib.h>
#include <nagg01.h>
int main(void)
{
/*Integer scalar and array declarations */
Integer exit_status = 0;
Integer i, ndata;
/*Double scalar and array declarations */
double a, b, f, x;
/* Nag Types */
NagError fail;
INIT_FAIL(fail);
printf("nag_gamma_pdf (g01kfc) Example Program Results\n\n");
scanf("%*[^\n] ");
scanf("%ld%*[^\n] ", &ndata);
printf("%14s%16s%16s%16s\n\n", "X", "A", "B", "RESULT");
for (i = 0; i < ndata; i++)
{
scanf("%lf%lf%lf%*[^\n] ", &x, &a, &b);
/*
* nag_gamma_pdf (g01kfc)
* Calculates the value for the probability density function of
* the gamma distribution at a chosen point.
*/
f = nag_gamma_pdf(x, a, b, &fail);
if (fail.code != NE_NOERROR)
{
printf("Error from nag_gamma_pdf (g01kfc).\n%s\n",
fail.message);
exit_status = 1;
goto END;
}
printf("%18.4e%16.4e%16.4e%16.4e\n", x, a, b, f);
}
END:
return exit_status;
}