Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

SciPy · Function

stats.normaltest

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.

How it works

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.

Syntax

scipy.stats.normaltest(a, axis=0, nan_policy='propagate', *, keepdims=False)

Parameters

NameTypeDescription
aarray_likeArray containing the data to test.
axisint or NoneAxis 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'.
keepdimsboolWhether reduced axes remain as dimensions of size one. Default: False.

Returns

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).

Key points

  • Use it as an omnibus test of whether sample data are compatible with a normal distribution.
  • Its statistic incorporates both asymmetry and tail/peakedness information rather than testing only one moment.
  • For multidimensional input, the test is applied independently to slices along axis.
  • axis=None treats the entire input, regardless of shape, as one flattened sample.
  • keepdims=True preserves reduced dimensions, which is useful when aligning results with the original array.
  • The returned p-value is two-sided and uses a chi-squared reference distribution.

Common mistakes

  • The input sample needs at least eight observations; smaller samples are not supported by the documented test.
  • With nan_policy='omit', removing NaNs can leave a slice with too little data, producing NaN.
  • Choose nan_policy='raise' only when NaNs should be treated as an error.

Example: Test a one-dimensional sample

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.

When to use it

Normality screening

Validate distributional assumptions before applying a statistical method that expects approximately normal data.

Batch testing

Evaluate each column or row of a NumPy array independently by selecting the appropriate axis.

Broadcastable results

Preserve array shape compatibility while reducing a dimension by setting keepdims=True.

Interview questions

QWhat hypothesis does scipy.stats.normaltest test?

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.

QHow do axis and keepdims affect normaltest?

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.

QHow does normaltest handle NaN values?

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.skewtest
  • scipy.stats.kurtosistest
  • scipy.stats.normaltest

Source: Normaltest. Checked 2026-10-15.