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

NAG CL Interface Introduction
Example description
/* nag_stat_prob_bivariate_normal (g01hac) Example Program.
 *
 * Copyright 2024 Numerical Algorithms Group.
 *
 * Mark 30.3, 2024.
 */

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

int main(void) {
  Integer exit_status = 0;
  double prob, rho, x, y;
  NagError fail;

  INIT_FAIL(fail);

  /* Skip heading in data file */
  scanf("%*[^\n]");
  printf("nag_stat_prob_bivariate_normal (g01hac) Example Program Results\n");
  printf("    x       y      rho    prob\n\n");
  while (scanf("%lf %lf %lf", &x, &y, &rho) != EOF)
  {
    /* nag_stat_prob_bivariate_normal (g01hac).
     * Probability for the bivariate Normal distribution
     */
    prob = nag_stat_prob_bivariate_normal(x, y, rho, &fail);
    if (fail.code != NE_NOERROR) {
      printf("Error from nag_stat_prob_bivariate_normal (g01hac).\n%s\n",
             fail.message);
      exit_status = 1;
      goto END;
    }
    printf("%8.3f%8.3f%8.3f%8.4f\n", x, y, rho, prob);
  }

END:
  return exit_status;
}