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

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

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

int main(void) {
  Integer exit_status = 0;
  double a, b, p, pdf, q, tol, x;
  NagError fail;

  INIT_FAIL(fail);

  /* Skip heading in data file */
  scanf("%*[^\n]");
  printf("nag_stat_prob_beta (g01eec) Example Program Results\n");
  printf("   x         a            b            p            q"
         "          pdf\n\n");
  while (scanf("%lf %lf %lf %lf", &x, &a, &b, &tol) != EOF)
  {
    /* nag_stat_prob_beta (g01eec).
     * Upper and lower tail probabilities and probability
     * density function for the beta distribution
     */
    nag_stat_prob_beta(x, a, b, tol, &p, &q, &pdf, &fail);
    if (fail.code != NE_NOERROR) {
      printf("Error from nag_stat_prob_beta (g01eec).\n%s\n", fail.message);
      exit_status = 1;
      goto END;
    }
    printf("%7.4f%13.4e%13.4e%13.4e%13.4e%13.4e\n", x, a, b, p, q, pdf);
  }

END:
  return exit_status;
}