TheAnderson–Darling test is astatistical test of whether a given sample of data is drawn from a givenprobability distribution. In its basic form, the test assumes that there are no parameters to be estimated in the distribution being tested, in which case the test and its set ofcritical values is distribution-free. However, the test is most often used in contexts wherein a family of distributions is being tested, in which case the parameters of that family need to be estimated and account must be taken of this in adjusting either the test-statistic or its critical values. When applied to testing whether anormal distribution adequately describes a set of data, it is one of the most powerful statistical tools for detecting most departures fromnormality.[1][2]K-sample Anderson–Darling tests are available for testing whether several collections of observations can be modelled as coming from a single population, where thedistribution function does not have to be specified.
In addition to its use as a test of fit for distributions, it can be used in parameter estimation as the basis for a form ofminimum distance estimation procedure.
The test is named afterTheodore Wilbur Anderson (1918–2016) andDonald A. Darling (1915–2014), who invented it in 1952.[3]
The Anderson–Darling andCramér–von Mises statistics belong to the class ofquadraticEDF statistics (tests based on theempirical distribution function).[2] If the hypothesized distribution is, and empirical (sample) cumulative distribution function is, then the quadratic EDF statistics measure the distance between and bywhere is the number of elements in the sample, and is a weighting function. When the weighting function is, the statisticis theCramér–von Mises statistic. The Anderson–Darling (1954) test[4] is based on the distancewhich is obtained when theweight function is. Thus, compared with theCramér–von Mises distance, the Anderson–Darling distance places more weight on observations in the tails of the distribution.
The Anderson–Darling test assesses whether asample comes from a specified distribution. It makes use of the fact that, when given a hypothesized underlying distribution and assuming the data does arise from this distribution, thecumulative distribution function (CDF) of the data can be transformed to what should follow auniform distribution. The data can be then tested for uniformity with a distance test (Shapiro, 1980). The formula for thetest statistic to assess if data (note that the data must be put in order) comes from a CDF is
where
The test statistic can then be compared against the critical values of the theoretical distribution. In this case, no parameters are estimated in relation to the cumulative distribution function.
Essentially the same test statistic can be used in the test of fit of a family of distributions, but then it must be compared against the critical values appropriate to that family of theoretical distributions and dependent also on the method used for parameter estimation.
Empirical testing has found[5] that the Anderson–Darling test is not quite as good as theShapiro–Wilk test, but is better than other tests. Stephens[1] found to be one of the bestempirical distribution function statistics for detecting most departures from normality.
The computation differs based on what is known about the distribution:[6]
Then observations,, for, of the variable must be sorted such that and the notation in the following assumes thatXi represent the ordered observations. Let
The values are standardized to create new values, given byWith the standard normal CDF, is calculated usingAn alternative expression in which only a single observation is dealt with at each step of the summation is:A modified statistic can be calculated using
[2]. If or exceeds a given critical value, then the hypothesis of normality is rejected withsome significance level. The critical values are given in the table below for values of.[1][2][7]
| Case | n | 15% | 10% | 5% | 2.5% | 1% |
|---|---|---|---|---|---|---|
| 0 | ≥ 5 | 1.621 | 1.933 | 2.492 | 3.070 | 3.857 |
| 1 | ≥ 20 | 0.782 | 0.894 | 1.087 | 1.285 | 1.551 |
| 2 | ≥ 20 | 1.430 | 1.743 | 2.308 | 2.898 | 3.702 |
| 3 | 0.561 | 0.631 | 0.752 | 0.873 | 1.035 |
Note 1: If = 0 or any(0 or 1) then cannot be calculated and is undefined.
Note 2: The above formula for the modified statistic is taken from D'Agostino (1986, p. 123). Care is required in comparisons across different sources as often the specific adjustment formula is not stated.
Note 3: Stephens[1] notes that the test becomes better when the parameters are computed from the data, even if they are known.
Note 4: Marsaglia & Marsaglia[7] provide a more accurate result for Case 0 at 85% and 99%.
Above, it was assumed that the variable was being tested for normal distribution. Any other family of distributions can be tested, but the test for each family is implemented by using a different modification of the basic test statistic, with reference to critical values specific to that family of distributions. The modifications of the statistic and tables of critical values are given by Stephens (1986)[2] for the exponential, extreme-value, Weibull, gamma, logistic, Cauchy, and von Mises distributions. Tests for the (two-parameter)log-normal distribution can be implemented by transforming the data using alogarithm and using the above test for normality. Details for the required modifications to the test statistic and for the critical values for thenormal distribution and theexponential distribution have been published by Pearson & Hartley (1972, Table 54). Details for these distributions, with the addition of theGumbel distribution, are also given by Shorack & Wellner (1986, p239). Details for thelogistic distribution are given by Stephens (1979). A test for the (two parameter)Weibull distribution can be obtained by making use of the fact that the logarithm of a Weibull variate has aGumbel distribution.
Fritz Scholz and Michael A. Stephens (1987) discuss a test, based on the Anderson–Darling measure of agreement between distributions, for whether a number of random samples with possibly different sample sizes may have arisen from the same distribution, where this distribution is unspecified.[8] TheR package kSamples and thePython packageScipy implements thisrank test for comparing k samples among several other such rank tests.[9][10]
For samples the statistic can be computed as follows under the assumption that the distribution function of-th sample is continuous
where