Scipy Normaltest 是怎么用的? [英] Scipy Normaltest how is it used?

查看:36
本文介绍了Scipy Normaltest 是怎么用的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 scipy 中使用 normaltest 来测试数据集是否为正态分布.但我似乎找不到任何好的例子如何使用 scipy.stats.normaltest.

I need to use normaltest in scipy for testing if the dataset is normal distributet. But I cant seem to find any good examples how to use scipy.stats.normaltest.

我的数据集有 100 多个值.

My dataset has more than 100 values.

推荐答案

In [12]: import scipy.stats as stats

In [13]: x = stats.norm.rvs(size = 100)

In [14]: stats.normaltest(x)
Out[14]: (1.627533590094232, 0.44318552909231262)

normaltest 返回卡方统计量的 2 元组和相关的 p 值.给定 x 来自正态分布的原假设,p 值表示看到大(或更大)的卡方统计量的概率.

normaltest returns a 2-tuple of the chi-squared statistic, and the associated p-value. Given the null hypothesis that x came from a normal distribution, the p-value represents the probability that a chi-squared statistic that large (or larger) would be seen.

如果 p-val 非常小,则意味着数据不太可能来自正态分布.例如:

If the p-val is very small, it means it is unlikely that the data came from a normal distribution. For example:

In [15]: y = stats.uniform.rvs(size = 100)

In [16]: stats.normaltest(y)
Out[16]: (31.487039026711866, 1.4543748291516241e-07)

这篇关于Scipy Normaltest 是怎么用的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆