D'Agostino-Pearson Test (Omnibus Test)
- Combines skewness and kurtosis to produce an omnibus test of normality
- Good general-purpose test for medium to large sample sizes (n > 20)
- Returns both the test statistic and p-value
Interpretation
- p-value > 0.05: Data is normally distributed ✓
- p-value ≤ 0.05: Data is NOT normally distributed ✗
- Based on chi-squared distribution with 2 degrees of freedom
Python Example
# Example: Test for Normality using D'Agostino-Pearson Test (scipy.stats.normaltest)
from scipy.stats import normaltest
import numpy as np
import matplotlib.pyplot as plt
# Generate sample data: normal and non-normal
data_normal = np.random.normal(loc=0, scale=1, size=1000)
data_non_normal = np.random.exponential(scale=2, size=1000)
# Plot histograms for visual inspection
fig, axes = plt.subplots(1, 2, figsize=(12, 4))
axes[0].hist(data_normal, bins=30, color='skyblue', edgecolor='black')
axes[0].set_title('Normal Data Histogram')
axes[1].hist(data_non_normal, bins=30, color='salmon', edgecolor='black')
axes[1].set_title('Non-Normal Data Histogram')
plt.tight_layout()
plt.show()
# D'Agostino-Pearson Omnibus test for normality
stat_norm, p_norm = normaltest(data_normal)
stat_non_norm, p_non_norm = normaltest(data_non_normal)
print(f"Normal Data: Statistic={stat_norm:.4f}, p-value={p_norm:.4f}")
if p_norm > 0.05:
print("Normal Data: Likely Gaussian (fail to reject H0)")
else:
print("Normal Data: Not Gaussian (reject H0)")
print(f"\nNon-Normal Data: Statistic={stat_non_norm:.4f}, p-value={p_non_norm:.4f}")
if p_non_norm > 0.05:
print("Non-Normal Data: Likely Gaussian (fail to reject H0)")
else:
print("Non-Normal Data: Not Gaussian (reject H0)")
Output
Normal Data: Statistic=0.5287, p-value=0.7677
Normal Data: Likely Gaussian (fail to reject H0)Non-Normal Data: Statistic=459.6370, p-value=0.0000
Non-Normal Data: Not Gaussian (reject H0)
