/* nag_anderson_darling_exp_prob (g08clc) Example Program.
*
* NAGPRODCODE Version.
*
* Copyright 2016 Numerical Algorithms Group.
*
* Mark 26, 2016.
*/
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <nag.h>
#include <nag_stdlib.h>
#include <nagg08.h>
int main(void)
{
/* Scalars */
Integer exit_status = 0, i, n;
double a2, aa2, p, ybar;
/* Array */
double *y = 0;
/* NAG types */
Nag_Boolean issort;
NagError fail;
printf("%s\n\n",
"nag_anderson_darling_exp_prob (g08clc) Example Program Results");
/* Skip heading in data file */
scanf("%*[^\n]");
/* Read number of observations */
scanf("%" NAG_IFMT "", &n);
scanf("%*[^\n] ");
/* Memory allocation */
if (!(y = NAG_ALLOC(n, double)))
{
printf("Allocation failure\n");
exit_status = -1;
goto END;
}
/* Read observations */
for (i = 0; i < n; i++) {
scanf("%lf", y + i);
}
scanf("%*[^\n]");
/* Let nag_anderson_darling_exp_prob (g08clc) sort the data */
issort = Nag_FALSE;
/* Calculate the Anderson-Darling goodness-of-fit test statistic and its
probability for the case of an unspecified exponential distribution */
INIT_FAIL(fail);
/* nag_anderson_darling_exp_prob (g08clc) */
nag_anderson_darling_exp_prob(n, issort, (const double *) y, &ybar, &a2,
&aa2, &p, &fail);
/* Results */
printf("%s ", "H0: data from exponential distribution with mean");
printf("%6g\n", ybar);
printf("%s", " Test statistic, A-squared: ");
printf("%6g\n", a2);
printf("%s", " Adjusted A-squared: ");
printf("%6g\n", aa2);
printf("%s", " Upper tail probability: ");
printf("%6g\n", p);
END:
NAG_FREE(y);
return exit_status;
}