The Anderson-Darling test is commonly used
to test whether a data sample comes from a normal distribution. However,
it can be used to test for another hypothesized distribution, even
if you do not fully specify the distribution parameters. Instead,
the test estimates any unknown parameters from the data sample.

The test statistic belongs to the family of quadratic empirical
distribution function statistics, which measure the distance between
the hypothesized distribution, *F*(*x*)
and the empirical cdf, *F*_{n}(*x*)
as

$$n{\displaystyle {\int}_{-\infty}^{\infty}\left({F}_{n}\left(x\right)-F\left(x\right)\right){}^{2}w\left(x\right)dF\left(x\right)},$$

over the ordered sample values $${x}_{1}<{x}_{2}<\mathrm{...}<{x}_{n}$$, where *w*(*x*)
is a weight function and *n* is the number of data
points in the sample.

The weight function for the Anderson-Darling test is

$$w\left(x\right)={\left[F\left(x\right)\left(1-F\left(x\right)\right)\right]}^{-1},$$

which places greater weight on the observations
in the tails of the distribution, thus making the test more sensitive
to outliers and better at detecting departure from normality in the
tails of the distribution.

The Anderson-Darling test statistic is

$${A}_{n}^{2}=-n-{\displaystyle \sum _{i=1}^{n}\frac{2i-1}{n}}\left[\mathrm{ln}\left(F\left({X}_{i}\right)\right)+\mathrm{ln}\left(1-F\left({X}_{n+1-i}\right)\right)\right],$$

where$$\left\{{X}_{1}<\mathrm{...}<{X}_{n}\right\}$$ are the ordered
sample data points and *n* is the number of data
points in the sample.

In `adtest`, the decision to reject or not
reject the null hypothesis is based on comparing the *p*-value
for the hypothesis test with the specified significance level, not
on comparing the test statistic with the critical value.