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

NAG CL Interface Introduction
Example description
/* nag_stat_mills_ratio (g01mbc) Example Program.
 *
 * Copyright 2022 Numerical Algorithms Group.
 *
 * Mark 28.4, 2022.
 */

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

int main(void) {
  /* Scalars */
  Integer exit_status = 0;
  double rm, x, xmu, xsig, z;
  Integer i;

  printf("nag_stat_mills_ratio (g01mbc) Example Program Results\n");

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

  printf("\n%2sMean%5sSigma%4sX%8sReciprocal", "", "", "", "");
  printf("\n                             Mills Ratio\n\n");
  for (i = 1; i <= 3; ++i) {
    scanf("%lf%lf%lf%*[^\n] ", &x, &xmu, &xsig);
    z = (x - xmu) / xsig;
    /* nag_stat_mills_ratio (g01mbc).
     * Computes reciprocal of Mills' Ratio
     */
    rm = nag_stat_mills_ratio(z) / xsig;
    printf("%7.4f%2s%7.4f%2s%7.4f%2s%7.4f", xmu, "", xsig, "", x, "", rm);
    printf("\n");
  }

  return exit_status;
}