/* nag_poisson_ci (g07abc) Example Program. * * Copyright 2001 Numerical Algorithms Group. * * Mark 7, 2001. */ #include #include #include #include int main(void) { /* Scalars */ double clevel, sum, tl, tu, xmean; Integer exit_status, i, ifreq, n, num; NagError fail; INIT_FAIL(fail); exit_status = 0; Vprintf("nag_poisson_ci (g07abc) Example Program Results\n"); /* Skip heading in data file */ Vscanf("%*[^\n] "); /* Read in the number of Noxious Seeds in a sub sample and * the frequency with which that number occurs. */ /* Compute the sample mean */ sum = 0.0; n = 0; while (scanf("%ld%ld%*[^\n] ", &num, &ifreq) != EOF) { sum += (double) num * (double) ifreq; n += ifreq; } xmean = sum / (double) n; Vprintf("\n"); Vprintf("The point estimate of the Poisson parameter = %6.4f\n", xmean); for (i = 1; i <= 2; ++i) { if (i == 1) { clevel = 0.95; Vprintf("\n"); Vprintf("95 percent Confidence Interval for the estimate\n"); } else { clevel = 0.99; Vprintf("99 percent Confidence Interval for the estimate\n"); } /* nag_poisson_ci (g07abc). * Computes confidence interval for the parameter of a * Poisson distribution */ nag_poisson_ci(n, xmean, clevel, &tl, &tu, &fail); if (fail.code != NE_NOERROR) { Vprintf("Error from nag_poisson_ci (g07abc).\n%s\n", fail.message); exit_status = 1; goto END; } Vprintf("( %6.4f , %6.4f )\n", tl, tu); Vprintf("\n"); } END: return exit_status; }