/* nag_triplets_test (g08ecc) Example Program. * * Copyright 2000 Numerical Algorithms Group. * * Mark 6, 2000. * * Mark 8 revised, 2004 * */ #include #include #include #include #include int main (void) { Integer exit_status=0, igen = 0, iseed[] = {0, 0, 0, 0}, max_count, n; NagError fail; double chi, df, enda, endb, p, *x=0; INIT_FAIL(fail); Vprintf("nag_triplets_test (g08ecc) Example Program Results\n"); /* nag_rngs_init_repeatable (g05kbc). * Initialize seeds of a given generator for random number * generating functions (that pass seeds explicitly) to give * a repeatable sequence */ nag_rngs_init_repeatable(&igen, iseed); n = 10000; if (!(x = NAG_ALLOC(n, double))) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } enda = 0.0; endb = 1.0; /* nag_rngs_uniform (g05lgc). * Generates a vector of random numbers from a uniform * distribution, seeds and generator number passed * explicitly */ nag_rngs_uniform(enda, endb, n, x, igen, iseed, NAGERR_DEFAULT); max_count = 5; /* nag_triplets_test (g08ecc). * Performs the triplets test for randomness */ nag_triplets_test(n, x, max_count, &chi, &df, &p, &fail); if (fail.code != NE_NOERROR && fail.code != NE_G08EC_CELL) { Vprintf("Error from nag_triplets_test (g08ecc).\n%s\n", fail.message); exit_status = 1; goto END; } Vprintf("\n"); Vprintf("%s%10.4f\n", "chisq = ", chi); Vprintf("%s%8.2f\n", "df = ", df); Vprintf("%s%10.4f\n", "prob = ", p); if (fail.code == NE_G08EC_CELL) Vprintf("Error from nag_triplets_test (g08ecc).\n%s\n", fail.message); END: if (x) NAG_FREE(x); return exit_status; }