/* nag_random_beta (g05fec) Example Program. * * Copyright 1991 Numerical Algorithms Group. * * Mark 2, 1991. */ #include #include #include #include #include #define N 5 int main(int argc, char *argv[]) { FILE *fpout; Integer exit_status = 0; Integer j; double a = 2.0; double b = 2.0; double x[N]; NagError fail; INIT_FAIL(fail); /* Check for command-line IO options */ fpout = nag_example_file_io(argc, argv, "-results", NULL); fprintf(fpout, "nag_random_beta (g05fec) Example Program Results\n"); /* nag_random_init_repeatable (g05cbc). * Initialize random number generating functions to give * repeatable sequence */ nag_random_init_repeatable((Integer) 0); fprintf(fpout, "Beta Dist --- a=%2.1f, b=%2.1f\n", a, b); /* nag_random_beta (g05fec). * Pseudo-random real numbers from the beta distribution */ nag_random_beta(a, b, (Integer) N, x, &fail); if (fail.code != NE_NOERROR) { fprintf(fpout, "Error from nag_random_beta (g05fec) %s\n", fail.message); exit_status = 1; goto END; } for (j = 0; j < (Integer) N; j++) fprintf(fpout, "%10.4f\n", x[j]); END: if (fpout != stdout) fclose(fpout); return exit_status; }