/* nag_stat_prob_chisq_noncentral (g01gcc) Example Program.
*
* Copyright 2021 Numerical Algorithms Group.
*
* Mark 27.2, 2021.
*/
#include <nag.h>
#include <stdio.h>
int main(void) {
Integer exit_status = 0, max_iter;
NagError fail;
double df, lambda, prob, tol, x;
INIT_FAIL(fail);
printf("nag_stat_prob_chisq_noncentral (g01gcc) Example Program Results\n\n");
/* Skip heading in data file */
scanf("%*[^\n]");
printf("\n x df lambda prob\n\n\n");
tol = 5e-6;
max_iter = 50;
while ((scanf(" %lf %lf %lf %*[^\n] ", &x, &df, &lambda)) != EOF)
{
/* nag_stat_prob_chisq_noncentral (g01gcc).
* Computes probabilities for the non-central chi^2
* distribution
*/
prob = nag_stat_prob_chisq_noncentral(x, df, lambda, tol, max_iter, &fail);
if (fail.code != NE_NOERROR) {
printf("Error from nag_stat_prob_chisq_noncentral (g01gcc).\n%s\n",
fail.message);
exit_status = 1;
goto END;
}
printf("%8.3f %8.3f %8.3f %8.4f\n", x, df, lambda, prob);
}
END:
return exit_status;
}