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

NAG CL Interface Introduction
Example description
/* nag_stat_prob_poisson (g01bkc) Example Program.
 *
 * Copyright 2022 Numerical Algorithms Group.
 *
 * Mark 28.3, 2022.
 *
 */

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

int main(void) {
  Integer exit_status = 0;
  Integer k;
  double plek, peqk, pgtk;
  double rlamda;
  NagError fail;

  INIT_FAIL(fail);

  printf("nag_stat_prob_poisson (g01bkc) Example Program Results\n");

  /* Skip heading in data file */
  scanf("%*[^\n] ");
  printf("\n    rlamda     k     plek      pgtk      peqk\n\n");
  while ((scanf("%lf %" NAG_IFMT "%*[^\n] ", &rlamda, &k)) != EOF)
  {
    /* nag_stat_prob_poisson (g01bkc).
     * Poisson distribution function
     */
    nag_stat_prob_poisson(rlamda, k, &plek, &pgtk, &peqk, &fail);
    if (fail.code != NE_NOERROR) {
      printf("Error from nag_stat_prob_poisson (g01bkc).\n%s\n", fail.message);
      exit_status = 1;
      goto END;
    }
    printf(" %10.3f%6" NAG_IFMT "%10.5f%10.5f%10.5f\n", rlamda, k, plek, pgtk,
           peqk);
  }

END:
  return exit_status;
}