[q,Asq,info] = anderson_darling_test(x,uniform|normal|exponential)
Test the hypothesis that x is selected from the given distribution
using the Anderson-Darling test. If the returned q is small, reject
the hypothesis at the q*100% level.
The Anderson-Darling A^2 statistic is calculated as follows:
A^2_n = -n - \sum_{i=1}^n (2i-1)/n log(z_i (1-z_{n-i+1}))
where z_i is the ordered position of the x's in the CDF of the
distribution. Unlike the Kolmogorov-Smirnov statistic, the
Anderson-Darling statistic is sensitive to the tails of the
distribution.
For 'normal' and 'exponential' distributions, estimate the
distribution parameters from the data, convert the values
to CDF values, and compare the result to tabluated critical
values. This includes an correction for small n which
works well enough for n >= 8, but less so from smaller n. The
returned info.Asq_corrected contains the adjusted statistic.
For 'uniform', assume the values are uniformly distributed
in (0,1), compute A^2 and return the corresponding p value from
1-anderson_darling_cdf(A^2,n).
If you are selecting from a known distribution, convert your
values into CDF values for the distribution and use 'uniform'.
Do not use 'uniform' if the distribution parameters are estimated
from the data itself, as this sharply biases the A^2 statistic
toward smaller values.
[1] Stephens, MA; (1986), "Tests based on EDF statistics", in
D'Agostino, RB; Stephens, MA; (eds.) Goodness-of-fit Techinques.
New York: Dekker.