You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Kolmogorov–Smirnov检验(stats.kstest)中P值与检验统计量不匹配问题

Why Your KS Test P-Values Are Uniformly Distributed

Your observation is correct and expected—here's the key reason:

You're generating data from the exact distribution you're testing against (standard normal) in every iteration. When the null hypothesis (H₀: data comes from the specified distribution) is true, p-values from valid hypothesis tests like the Kolmogorov–Smirnov test will always follow a uniform distribution over [0, 1].

Breakdown of Your Results:

  • Your critical statistic check shows ~5% of test statistics exceed the α=0.05 threshold. This directly maps to ~5% of p-values being below 0.05 (the rejection region), which aligns perfectly with the uniform distribution (5% of values fall in the bottom 5th percentile).
  • The rest of the p-values are evenly spread between 0 and 1 because, when H₀ holds, there's no systematic tendency for the test statistic to be large or small—each p-value between 0 and 1 is equally likely.

What If H₀ Was False?

If you generated data from a different distribution (e.g., stats.uniform.rvs), the p-values would cluster near 0, since the test statistic would frequently be large enough to reject H₀.

Confirm With Your Output

Look at the fraction below pvalue 0.05 printout—it should be ~0.05, which matches both your critical statistic result and the uniform distribution expectation. This confirms scipy.stats.kstest is working correctly.

内容的提问来源于stack exchange,提问作者BigGulpshuh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 08:35:03