/* nag_univar_ttest_2normal (g07cac) Example Program.
*
* Copyright 2021 Numerical Algorithms Group.
*
* Mark 27.3, 2021.
*
*/
#include <nag.h>
#include <stdio.h>
int main(void) {
/* Local variables */
double prob, xstd, ystd;
double t;
double xmean, ymean, df, dl, du;
double clevel;
Integer exit_status = 0, nx, ny;
NagError fail;
INIT_FAIL(fail);
printf("nag_univar_ttest_2normal (g07cac) Example Program Results\n");
/* Skip heading in data file */
scanf("%*[^\n]");
scanf("%" NAG_IFMT " %" NAG_IFMT "", &nx, &ny);
scanf("%lf %lf %lf %lf", &xmean, &ymean, &xstd, &ystd);
scanf("%lf", &clevel);
/* nag_univar_ttest_2normal (g07cac).
* Computes t-test statistic for a difference in means
* between two Normal populations, confidence interval
*/
nag_univar_ttest_2normal(Nag_TwoTail, Nag_PopVarEqual, nx, ny, xmean, ymean,
xstd, ystd, clevel, &t, &df, &prob, &dl, &du, &fail);
if (fail.code != NE_NOERROR) {
printf("Error from nag_univar_ttest_2normal (g07cac).\n%s\n", fail.message);
exit_status = 1;
goto END;
}
printf("\nAssuming population variances are equal.\n\n");
printf("t test statistic = %10.4f\n", t);
printf("Degrees of freedom = %8.1f\n", df);
printf("Significance level = %8.4f\n", prob);
printf("Lower confidence limit for difference in means = %10.4f\n", dl);
printf("Upper confidence limit for difference in means = %10.4f\n\n", du);
/* nag_univar_ttest_2normal (g07cac), see above. */
nag_univar_ttest_2normal(Nag_TwoTail, Nag_PopVarNotEqual, nx, ny, xmean,
ymean, xstd, ystd, clevel, &t, &df, &prob, &dl, &du,
&fail);
if (fail.code != NE_NOERROR) {
printf("Error from nag_univar_ttest_2normal (g07cac).\n%s\n", fail.message);
exit_status = 1;
goto END;
}
printf("\nNo assumptions about population variances.\n\n");
printf("t test statistic = %10.4f\n", t);
printf("Degrees of freedom = %8.4f\n", df);
printf("Significance level = %8.4f\n", prob);
printf("Lower confidence limit for difference in means = %10.4f\n", dl);
printf("Upper confidence limit for difference in means = %10.4f\n", du);
END:
return exit_status;
}