NAG Library Manual, Mark 30
Interfaces:  FL   CL   CPP   AD 

NAG CL Interface Introduction
Example description
/* nag_stat_prob_beta_noncentral (g01gec) Example Program.
 *
 * Copyright 2024 Numerical Algorithms Group.
 *
 * Mark 30.0, 2024.
 */

#include <nag.h>
#include <stdio.h>

int main(void) {
  Integer exit_status = 0, max_iter;
  NagError fail;
  double a, b, lambda, prob, tol, x;

  INIT_FAIL(fail);

  printf("nag_stat_prob_beta_noncentral (g01gec) Example Program Results\n");

  /* Skip heading in data file */
  scanf("%*[^\n]");

  printf("\n     x        a       b       lambda   prob\n\n");
  tol = 5e-6;
  max_iter = 50;
  while ((scanf("%lf %lf %lf %lf %*[^\n]", &x, &a, &b, &lambda)) != EOF)
  {
    /* nag_stat_prob_beta_noncentral (g01gec).
     * Computes probabilities for the non-central beta
     * distribution
     */
    prob = nag_stat_prob_beta_noncentral(x, a, b, lambda, tol, max_iter, &fail);
    if (fail.code != NE_NOERROR) {
      printf("Error from nag_stat_prob_beta_noncentral (g01gec).\n%s\n",
             fail.message);
      exit_status = 1;
      goto END;
    }
    printf("%8.3f %8.3f %8.3f %8.3f %8.4f\n", x, a, b, lambda, prob);
  }
END:
  return exit_status;
}