用python对数据进行正态性检验(Q-Q检验,KS检验,W检验,偏峰检验)

本文介绍了使用Python进行数据正态性检验的方法,包括Kolmogorov-Smirnov(KS)检验,Shapiro-Wilk(W)检验,以及通过Q-Q图进行的正态性检查。KS检验基于累积分布函数,用于测试样本是否符合特定理论分布或比较两个实际分布之间的显著差异。W检验是一种基于相关性的算法,计算得出的关联系数越接近1,表明数据越符合正态分布。正常性检验的结果包括Kstest的统计量和p值,ShapiroResult的统计量和p值,以及normaltest的统计量和p值。
摘要由CSDN通过智能技术生成

Kolmogorov Smirnov test is based on the cumulative distribution function. It is used to test whether a distribution conforms to a certain theoretical distribution or compare whether there are significant differences between two empirical distributions. The original hypothesis is that the sample comes from a population subject to normal distribution
在这里插入图片描述
The full name of W test is Shapiro Wilk test, which is a correlation based algorithm. A correlation coefficient can be obtained by calculation. The closer it is to 1, the better it shows that the data fit the normal distribution. It is recommended by the national standard gb4882-85 to make the smallest type II error.

W test is a method to check whether the sample conforms to the normal distribution when the sample size is 8 ≤ n ≤ 50. (now the research

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Kolmogorov-Smirnov检验是一种非参数检验方法,用于检验一组数据是否服从某个已知的概率分布,例如正态分布。下面是使用Kolmogorov-Smirnov检验进行正态性检验的步骤: 1. 设置假设:假设数据符合正态分布。 2. 计算样本的累计分布函数(CDF):将样本数据从小到大排序,对于每个数据点,计算出它在整个样本中的累计占比。 3. 计算理论的累计分布函数:根据假设分布,计算出每个数据点在该分布中的累计占比。 4. 计算两个累计分布函数之间的最大差值(D值):D值表示样本数据与理论分布之间的最大偏差。 5. 计算临界值:通过查找Kolmogorov-Smirnov分布表,可以找到相应样本量和显著性水平下的临界值。 6. 进行假设检验:如果D值小于临界值,则无法拒绝假设,即数据可以认为是服从正态分布的;反之,如果D值大于临界值,则可以拒绝假设,即数据不符合正态分布。 Python中可以使用scipy库中的kstest函数进行Kolmogorov-Smirnov检验,具体用法如下: ```python from scipy.stats import kstest, norm import numpy as np # 生成一组正态分布的数据 data = np.random.normal(0, 1, 100) # 进行Kolmogorov-Smirnov检验 statistic, pvalue = kstest(data, norm.cdf) # 打印检验结果 print("D值为:", statistic) print("p值为:", pvalue) ``` 其中,norm.cdf表示标准正态分布的累计分布函数。如果p值小于显著性水平(通常为0.05),则可以拒绝假设,认为数据不符合正态分布。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值