Normality screening
Validate distributional assumptions before applying a statistical method that expects approximately normal data.
SciPy · Function
Tests whether a sample differs from a normal distribution using D’Agostino and Pearson’s omnibus test, which combines skewness and kurtosis. It returns the test statistic and a two-sided p-value.
normaltest combines skewness and kurtosis into D’Agostino and Pearson’s omnibus statistic. It tests each slice along the selected axis, handles NaNs according to nan_policy, and returns the statistic with its two-sided chi-squared p-value.
scipy.stats.normaltest(a, axis=0, nan_policy='propagate', *, keepdims=False)| Name | Type | Description |
|---|---|---|
a | array_like | Array containing the data to test. |
axis | int or None | Axis along which to compute the statistic; use None to flatten the input. Default: 0. |
nan_policy | {'propagate', 'omit', 'raise'} | NaN handling policy: 'propagate', 'omit', or 'raise'. Default: 'propagate'. |
keepdims | bool | Whether reduced axes remain as dimensions of size one. Default: False. |
A result containing statistic (s² + k², where s and k are the skewness and kurtosis z-scores) and pvalue (a two-sided chi-squared probability).
import numpy as np
from scipy.stats import normaltest
rng = np.random.default_rng(42)
sample = rng.normal(size=100)
result = normaltest(sample)
print(result.statistic, result.pvalue)Generates 100 normal observations, applies the omnibus normality test, and prints its statistic and two-sided p-value.
Validate distributional assumptions before applying a statistical method that expects approximately normal data.
Evaluate each column or row of a NumPy array independently by selecting the appropriate axis.
Preserve array shape compatibility while reducing a dimension by setting keepdims=True.
normaltest tests the null hypothesis that the sample comes from a normal distribution. It combines skewness and kurtosis into an omnibus statistic and returns a two-sided chi-squared p-value.
Follow-up: What does a small p-value suggest? It provides evidence against the normality null hypothesis, though it does not identify which aspect of the distribution caused the departure.
By default, axis=0 computes the test along the first axis. Setting axis=None raveles the input and tests all values as one sample; each axis slice otherwise produces a corresponding output element.
Follow-up: How can output dimensions be retained for broadcasting? Set keepdims=True so reduced axes remain with size one.
nan_policy controls NaNs: 'propagate' returns NaN for an affected slice, 'omit' excludes NaNs, and 'raise' throws ValueError. The default is 'propagate'.
Follow-up: What happens when omission leaves too few observations? The affected output entry becomes NaN.
scipy.stats.skewtestscipy.stats.kurtosistestscipy.stats.normaltest