/* nag_1_sample_ks_test (g08cbc) Example Program. * * Copyright 2000 Numerical Algorithms Group. * * Mark 6, 2000. */ #include #include #include #include int main (void) { double d, p, *par=0, *x=0, z; Integer i, n, np, ntype; Integer exit_status=0; Nag_TestStatistics ntype_enum; NagError fail; INIT_FAIL(fail); Vprintf("g08cbc Example Program Results\n"); /* Skip heading in data file */ Vscanf("%*[^\n]"); Vscanf("%ld", &n); x = NAG_ALLOC(n, double); Vprintf("\n"); for (i = 1; i <= n; ++i) Vscanf("%lf", &x[i - 1]); Vscanf("%ld", &np); if (!(par = NAG_ALLOC(np, double))) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } for (i = 1; i <= np; ++i) Vscanf("%lf", &par[i - 1]); Vscanf("%ld", &ntype); if (ntype == 1) ntype_enum = Nag_TestStatisticsDAbs; else if (ntype == 2) ntype_enum = Nag_TestStatisticsDPos; else if (ntype == 3) ntype_enum = Nag_TestStatisticsDNeg; else ntype_enum = (Nag_TestStatistics)-999; g08cbc(n, x, Nag_Uniform, par, Nag_ParaSupplied, ntype_enum, &d, &z, &p, &fail); if (fail.code != NE_NOERROR) { Vprintf("Error from g08cbc.\n%s\n", fail.message); exit_status = 1; goto END; } Vprintf("Test against uniform distribution on (0,2)\n"); Vprintf("\n"); Vprintf("Test statistic D = %8.4f\n", d); Vprintf("Z statistic = %8.4f\n", z); Vprintf("Tail probability = %8.4f\n", p); Vprintf("\n"); Vscanf("%ld", &np); for (i = 1; i <= np; ++i) Vscanf("%lf", &par[i - 1]); Vscanf("%ld", &ntype); if (ntype == 1) ntype_enum = Nag_TestStatisticsDAbs; else if (ntype == 2) ntype_enum = Nag_TestStatisticsDPos; else if (ntype == 3) ntype_enum = Nag_TestStatisticsDNeg; g08cbc(n, x, Nag_Normal, par, Nag_ParaEstimated, ntype_enum, &d, &z, &p, &fail); if (fail.code != NE_NOERROR) { Vprintf("Error from g08cbc.\n%s\n", fail.message); exit_status = 1; goto END; } Vprintf("Test against Normal distribution with parameters estimated from the data\n"); Vprintf("\n"); Vprintf("%s%6.4f%s%6.4f\n", "Mean = ", par[0], " and variance = ", par[1]); Vprintf("Test statistic D = %8.4f\n", d); Vprintf("Z statistic = %8.4f\n", z); Vprintf("Tail probability = %8.4f\n", p); END: if (x) NAG_FREE(x); if (par) NAG_FREE(par); return exit_status; }