andersonDarlingTest
Performs the Anderson-Darling test for normality.
The null hypothesis is that sample was drawn from a normal distribution. The test measures the discrepancy between the empirical distribution and a fitted normal distribution, giving more weight to the tails than the Kolmogorov-Smirnov test. Standardizes the data using the sample mean and standard deviation before computing the A² statistic. Uses D'Agostino & Stephens' (1986) piecewise approximation for the p-value with a finite-sample correction factor.
If all values are identical (zero variance), returns A² = 0.0 and p-value = 1.0.
Example:
val data = doubleArrayOf(-1.2, -0.5, 0.1, 0.3, 0.7, 1.0, 1.5)
val result = andersonDarlingTest(data)
result.statistic // A² statistic
result.pValue // p-value
result.additionalInfo["modifiedStatistic"] // A²* (finite-sample corrected)
result.isSignificant() // true if data deviates from normalityReturn
a TestResult containing the A² statistic, p-value, and additional info with "modifiedStatistic" (the finite-sample corrected A²*).
Parameters
the observed values. Must have at least 3 elements.