0

我正在为python 中具有未知参数的正态分布寻找一个样本 Cramer-Von Mises 测试。

我在这里找到了一些讨论 https://github.com/chrisb83/scipy/commit/9274d22fc1ca7ce40596b01322be84c81352899d 但这似乎没有发布?

还有这个: https ://pypi.org/project/scikit-gof/ 但这些测试仅适用于完全指定的分布(即已知参数)。

有谁知道 python 中的 CVM 测试实现,用于具有未知参数的普通 dist?

谢谢

4

1 回答 1

0

测试是在样品上完成的。这是一个在 Python 中使用OpenTURNS的示例。

import openturns as ot

首先让我们从居中的标准正态分布构建一个大小为 200 的随机样本您可能有自己的数据:

sample = ot.Sample([0, 0.3, -0.1, 0.23, -0.5], 1)

但 OpenTurns 提供了一种构建样本的简单方法

sample = ot.Normal().getSample(200)

现在要执行 Cramer-Von Mises 正态性检验,您只需调用此方法

test_result = ot.NormalityTest.CramerVonMisesNormal(sample)

然后打印结果

print('Component is normal?', test_result.getBinaryQualityMeasure(),
      'p-value=%.6g' % test_result.getPValue(),
      'threshold=%.6g' % test_result.getThreshold())

>>> Component is normal? True 
 p-value=0.624469 
 threshold=0.01

但请始终记住,阈值是任意的,即使样本确实来自正态分布,测试也可能给出假阴性。

如果要测试来自均匀分布的样本,请将“样本”行替换为:sample = ot.Uniform().getSample(200)

于 2020-10-27T10:12:30.693 回答