Class AndersonDarlingTest
- java.lang.Object
-
- elki.math.statistics.tests.AndersonDarlingTest
-
@Reference(authors="T. W. Anderson, D. A. Darling", title="Asymptotic theory of certain \'goodness of fit\' criteria based on stochastic processes", booktitle="Annals of mathematical statistics 23(2)", url="https://doi.org/10.1214/aoms/1177729437", bibkey="doi:10.1214/aoms/1177729437") public class AndersonDarlingTest extends java.lang.Object
Perform Anderson-Darling test for a Gaussian distribution.This is a test against normality / goodness of fit. I.e. you can use it to reject the hypothesis that the data is normal distributed. Such tests are sensitive to data set size: on small samples, even large deviations could be by-chance and thus not allow rejection. On the other hand, on large data sets even a slight deviation can be unlikely to happen if the data were indeed normal distributed. Thus, this test is more likely to fail to reject small data sets even when they intuitively do not appear to be normal distributed, while it will reject large data sets that originate from a distribution only slightly different from the normal distribution.
Before using, make sure you have understood statistical tests, and the difference between failure-to-reject and acceptance!
The data size should be at least 8 before the results start getting somewhat reliable. For large data sets, the chance of rejecting the normal distribution hypothesis increases a lot: no real data looks exactly like a normal distribution.
References:
T. W. Anderson, D. A. Darling
Asymptotic theory of certain 'goodness of fit' criteria based on stochastic processes
Annals of mathematical statistics 23(2)M. A. Stephens
EDF Statistics for Goodness of Fit and Some Comparisons
Journal of the American Statistical Association 69(347)Ralph B. D'Agostino
Tests for the Normal Distribution
Goodness-of-Fit TechniquesL. Jäntschi and S. D. Bolboacă
Computation of Probability Associated with Anderson–Darling Statistic
Mathematics (MDPI, 2018)- Since:
- 0.7.0
- Author:
- Erich Schubert, Robert Gehde
-
-
Field Summary
Fields Modifier and Type Field Description private static double
SMALL
Cut-off for extreme values.
-
Constructor Summary
Constructors Modifier Constructor Description private
AndersonDarlingTest()
Private constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static double
A2Noncentral(double[] sorted)
Test a sorted but not standardized data set.static double
A2StandardNormal(double[] sorted)
Test a sorted data set against the standard normal distribution.static double
calculateQuantileCase0(double A2, int n)
Calculates the p-value for an Anderson Darling statistic in the case where both center and variance are known.static double
calculateQuantileCase3(double A2)
Calculates the quantile for an Anderson Darling statistic in the case where both center and variance are unknown.static double
pValueCase0(double A2, int n)
Calculates the p-value for an Anderson Darling statistic in the case where both center and variance are known.static double
pValueCase3(double A2)
Calculates the p-value for an Anderson Darling statistic in the case where both center and variance are unknown.static double
removeBiasNormalDistribution(double A2, int n)
Remove bias from the Anderson-Darling statistic if the mean and standard deviation were estimated from the data, and a normal distribution was assumed.static double
removeBiasNormalDistributionDAgostino(double A2, int n)
Remove bias from the Anderson-Darling statistic if the mean and standard deviation were estimated from the data, and a normal distribution was assumed.
-
-
-
Method Detail
-
A2StandardNormal
public static double A2StandardNormal(double[] sorted)
Test a sorted data set against the standard normal distribution.Note: the data will be compared to the standard normal distribution, i.e. with mean 0 and variance 1.
The data size should be at least 8 before the results start getting somewhat reliable. For large data sets, the chance of rejecting increases a lot: no real data looks exactly like a normal distribution.
- Parameters:
sorted
- Sorted input data.- Returns:
- Test statistic A².
-
A2Noncentral
public static double A2Noncentral(double[] sorted)
Test a sorted but not standardized data set.The data size should be at least 8!
- Parameters:
sorted
- Sorted input data.- Returns:
- Test statistic A², after bias removal.
-
removeBiasNormalDistribution
@Reference(authors="M. A. Stephens", title="EDF Statistics for Goodness of Fit and Some Comparisons", booktitle="Journal of the American Statistical Association, Volume 69, Issue 347", url="https://doi.org/10.1080/01621459.1974.10480196", bibkey="doi:10.1080/01621459.1974.10480196") public static double removeBiasNormalDistribution(double A2, int n)
Remove bias from the Anderson-Darling statistic if the mean and standard deviation were estimated from the data, and a normal distribution was assumed.- Parameters:
A2
- A2 statisticn
- Sample size- Returns:
- Unbiased test statistic
-
removeBiasNormalDistributionDAgostino
@Reference(authors="R. B. D\'Agostino", title="Tests for the Normal Distribution", booktitle="Goodness-of-Fit Techniques", url="https://doi.org/10.1201/9780203753064-9", bibkey="doi:10.1201/9780203753064-9") public static double removeBiasNormalDistributionDAgostino(double A2, int n)
Remove bias from the Anderson-Darling statistic if the mean and standard deviation were estimated from the data, and a normal distribution was assumed.- Parameters:
A2
- A2 statisticn
- Sample size- Returns:
- Unbiased test statistic
-
calculateQuantileCase3
public static double calculateQuantileCase3(double A2)
Calculates the quantile for an Anderson Darling statistic in the case where both center and variance are unknown.Note: the equations assume a correction with
removeBiasNormalDistributionDAgostino(double, int)
.- Parameters:
A2
- Anderson Darling statistic- Returns:
- quantile
-
pValueCase3
@Reference(authors="R. B. D\'Agostino", title="Tests for the Normal Distribution", booktitle="Goodness-of-Fit Techniques", url="https://doi.org/10.1201/9780203753064-9", bibkey="doi:10.1201/9780203753064-9") public static double pValueCase3(double A2)
Calculates the p-value for an Anderson Darling statistic in the case where both center and variance are unknown.Note: the equations assume a correction with
removeBiasNormalDistributionDAgostino(double, int)
.- Parameters:
A2
- Anderson Darling statistic- Returns:
- quantile
-
calculateQuantileCase0
public static double calculateQuantileCase0(double A2, int n)
Calculates the p-value for an Anderson Darling statistic in the case where both center and variance are known.Note: the equations assume a correction with
removeBiasNormalDistributionDAgostino(double, int)
.- Parameters:
A2
- Anderson Darling statisticn
- sample size- Returns:
- quantile
-
pValueCase0
@Reference(authors="L. J\u00e4ntschi and S. D. Bolboac\u0103", booktitle="Mathematics 6(6)", title="Computation of Probability Associated with Anderson-Darling Statistic", url="https://doi.org/10.3390/math6060088", bibkey="doi:10.3390/math6060088") public static double pValueCase0(double A2, int n)
Calculates the p-value for an Anderson Darling statistic in the case where both center and variance are known.Note: the equations assume a correction with
removeBiasNormalDistributionDAgostino(double, int)
.Reference:
L. Jäntschi and S. D. Bolboacă
Computation of Probability Associated with Anderson-Darling Statistic
Mathematics 6(6)- Parameters:
A2
- Anderson Darling statisticn
- sample size- Returns:
- quantile
-
-