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

NAG CL Interface Introduction
Example description
/* nag_univar_robust_2var_ci (g07ebc) Example Program.
 *
 * Copyright 2024 Numerical Algorithms Group.
 *
 * Mark 30.1, 2024.
 */

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

int main(void) {
  /* Scalars */
  double clevel, estcl, theta, thetal, thetau, ulower, uupper;
  Integer exit_status, i, m, n;
  NagError fail;

  /* Arrays */
  double *wrk = 0, *x = 0, *y = 0;
  Integer *iwrk = 0;

  INIT_FAIL(fail);

  exit_status = 0;
  printf("nag_univar_robust_2var_ci (g07ebc) Example Program Results\n");

  /* Skip Heading in data file */
  scanf("%*[^\n] %" NAG_IFMT "%" NAG_IFMT "%*[^\n] ", &n, &m);

  /* Allocate memory */
  if (!(wrk = NAG_ALLOC(600, double)) || !(x = NAG_ALLOC(n, double)) ||
      !(y = NAG_ALLOC(m, double)) || !(iwrk = NAG_ALLOC(300, Integer))) {
    printf("Allocation failure\n");
    exit_status = -1;
    goto END;
  }
  scanf(" %*[^\n] ");

  for (i = 1; i <= n; ++i)
    scanf("%lf", &x[i - 1]);
  scanf(" %*[^\n] ");

  for (i = 1; i <= m; ++i)
    scanf("%lf", &y[i - 1]);
  scanf(" %*[^\n] ");
  scanf(" %lf%*[^\n] ", &clevel);

  /* nag_univar_robust_2var_ci (g07ebc).
   * Robust confidence intervals, two-sample
   */
  nag_univar_robust_2var_ci(Nag_RCI_Approx, n, x, m, y, clevel, &theta, &thetal,
                            &thetau, &estcl, &ulower, &uupper, &fail);
  if (fail.code != NE_NOERROR) {
    printf("Error from nag_univar_robust_2var_ci (g07ebc).\n%s\n",
           fail.message);
    exit_status = 1;
    goto END;
  }

  printf("\n");
  printf(" Location estimator     Confidence Interval\n");
  printf("\n");
  printf("   %10.4f           ( %6.4f , %6.4f )\n", theta, thetal, thetau);
  printf("\n");
  printf(" Corresponding Mann-Whitney U statistics\n");
  printf("\n");
  printf(" Lower : %8.2f\n Upper : %8.2f\n", ulower, uupper);
END:
  NAG_FREE(wrk);
  NAG_FREE(x);
  NAG_FREE(y);
  NAG_FREE(iwrk);
  return exit_status;
}