/* nag_bivariate_students_t (g01hcc) Example Program. * * Mark 23 Release. NAG Copyright 2011. */ #include #include #include #include #include #include int main(void) { /* Scalars */ Integer df, exit_status = 0, ierr; double prob, rho; /* Arrays */ char nag_enum_arg[14]; double a[2], b[2]; /* NAG types */ Nag_TailProbability tail; NagError fail; printf("%s\n\n", "nag_bivariate_students_t (g01hcc) Example Program Results"); /* Skip heading in data file */ scanf("%*[^\n]"); /* Display headers */ printf("%-8s%2s%-8s%2s%-8s%2s%-8s%2s%-4s%2s%-8s%2s%-14s%2s%-8s\n\n", "a1", " ", "b1", " ", "a2", " ", "b2", " ", "df", " ", "rho", " ", "Tail", " ", "p"); while (1) { ierr = scanf("%14s", nag_enum_arg); if (ierr == EOF || ierr < 1) { break; } /* Initialize limits */ a[0] = a[1] = b[0] = b[1] = 0.0; /* nag_enum_name_to_value(x04nac). * Converts NAG enum member name to value */ tail = (Nag_TailProbability)nag_enum_name_to_value(nag_enum_arg); /* Read parameter values*/ switch (tail) { case Nag_LowerTail: scanf("%ld%lf%lf%lf", &df, &rho, b, b+1); break; case Nag_Central: scanf("%ld%lf%lf%lf%lf%lf", &df, &rho, a, b, a+1, b+1); break; case Nag_UpperTail: scanf("%ld%lf%lf%lf", &df, &rho, a, a+1); break; default: printf(" %s\n", "Invalid tail specification in data file"); exit_status = -1; goto END; } scanf("%*[^\n]"); /* Calculate probablity for the bivariate Student's t-distribution */ INIT_FAIL(fail); /* nag_bivariate_students_t (g01hcc) */ prob = nag_bivariate_students_t(tail, a, b, df, rho, &fail); /* Display results */ switch (tail) { case Nag_LowerTail: printf("%-8s%2s%-8g%2s%-8s%2s%-8g", "-Inf", " ", b[0], " ", "-Inf", " ", b[1]); break; case Nag_Central: printf("%-8g%2s%-8g%2s%-8g%2s%-8g", a[0], " ", b[0], " ", a[1], " ", b[1]); break; case Nag_UpperTail: printf("%-8g%2s%-8s%2s%-8g%2s%-8s", a[0], " ", "Inf", " ", a[1], " ", "Inf"); } printf("%2s%-4ld%2s%-8g%2s%-14s%2s%-8.4f\n", " ", df, " ", rho, " ", nag_enum_arg, " ", prob); } END: return exit_status; }