Tests whether a one-dimensional signal is normally distributed by comparing
its empirical cumulative distribution function (ECDF) to that of a normal
distribution fitted to the sample (mean and SD). The statistic is the
Kolmogorov-Smirnov distance \(D = \sup_x |F_n(x) - \Phi((x-\mu)/\sigma)|\),
the largest vertical gap between the two CDFs; the two-sided asymptotic
(Kolmogorov) p-value follows. The \(D\) statistic reproduces
stats::ks.test and scipy.stats.kstest bit-for-bit.
Value
A list with statistic (the KS distance \(D\)),
p_value (two-sided asymptotic), and n (sample size).
Details
A distribution-shape (empirical-CDF) normality test, complementary to the
moment-based jarqueBeraTest: KS responds to the overall shape of
the distribution, Jarque-Bera to its skewness and kurtosis (the tails). The two
can disagree – on a long, mildly non-Gaussian signal Jarque-Bera's power often
rejects while KS does not.
Caveat
Because the normal parameters are estimated from the same sample, the naive p-value is anti-conservative (a Lilliefors correction gives an exact test); the \(D\) statistic itself is exact and is what this function certifies.
See also
jarqueBeraTest for the moment-based normality test,
signalMoments for the skewness and kurtosis.