What is the Anderson-Darling test for normality?
Sometimes we want to know whether our sample data looks as though it is drawn from the normal distribution. To determine that, we perform a normality test. There are many normality tests. This test is named after Theodore Anderson and Donald Darling.
Please note that the Anderson-Darling test for normality takes the data as input and returns the test statistic as well as a list of critical values and a list of the significance level. If the test statistic is less than the critical value for a significance level, we fail to reject the null hypothesis. And that means the data looks normal.
How to perform the Anderson-Darling test for normality using Python?
We can use the following Python code to perform the Anderson-Darling test for normality.
from numpy.random import randn
from scipy.stats import anderson
data = 5*randn(100) + 10
print(data)
result = anderson(data)
print("Test Statistic: ", result.statistic)
print("Critical Values: ", result.critical_values)
print("Significance Level: ", result.significance_level)
Here, we are using the randn() function from the numpy.random() module to generate 100 random numbers that have a standard deviation of 5 and a mean of 10. After that, we are using the anderson() function from the scipy.stats module to test whether the data is normal.
The output of the above program will be like the following: …








































0 Comments