What is D’Agostino’s K-squared 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. D’Agostino’s K-squared test for normality is named after Ralph D’Agostino. This test calculates kurtosis and skewness of data to determine whether the sample data looks normal.
Please note that kurtosis measures the tailedness of the data. In other words, it determines how much data of the distribution is in the tail. And skewness determines whether the data of the distribution is pushed to the left or right.
How to perform D’Agostino’s K-squared test for normality using Python?
We can use the following Python code to perform D’Agostino’s K-squared test for normality.
from numpy.random import randn
from scipy.stats import normaltest
data = 5*randn(100) + 10
print(data)
test_statistic, p_value = normaltest(data)
print("Test Statistic: ", test_statistic)
print("p-value: ", p_value)
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 normaltest() function from the scipy.stats module to test whether …








































0 Comments