/* nag_normal_pdf (g01kac) 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 xmean, xstd, f, x;
/* Nag Types */
NagError fail;
INIT_FAIL(fail);
printf("nag_normal_pdf (g01kac) Example Program Results\n\n");
scanf("%*[^\n] ");
scanf("%ld%*[^\n] ", &ndata);
printf("%14s%17s%17s%17s\n\n", "X", "XMEAN", "XSTD", "RESULT");
for (i = 0; i < ndata; i++)
{
scanf("%lf%lf%lf%*[^\n] ", &x, &xmean, &xstd);
/*
* nag_normal_pdf (g01kac)
* Calculates the value for the probability density function of
* the normal distribution at a chosen point.
*/
f = nag_normal_pdf(x, xmean, xstd, &fail);
if (fail.code != NE_NOERROR)
{
printf("Error from nag_normal_pdf (g01kac).\n%s\n",
fail.message);
exit_status = 1;
goto END;
}
printf("%18.5e%17.5e%17.5e%17.5e\n", x, xmean, xstd, f);
}
END:
return exit_status;
}