日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区

您的位置:首頁技術文章
文章詳情頁

Python數據正態性檢驗實現過程

瀏覽:105日期:2022-07-29 15:25:40

在做數據分析或者統計的時候,經常需要進行數據正態性的檢驗,因為很多假設都是基于正態分布的基礎之上的,例如:T檢驗。

在Python中,主要有以下檢驗正態性的方法:

1.scipy.stats.shapiro ——Shapiro-Wilk test,屬于專門用來做正態性檢驗的模塊,其原假設:樣本數據符合正態分布。

注:適用于小樣本。

其函數定位為:

def shapiro(x): ''' Perform the Shapiro-Wilk test for normality. The Shapiro-Wilk test tests the null hypothesis that the data was drawn from a normal distribution. Parameters ---------- x : array_like Array of sample data. Returns ------- W : float The test statistic. p-value : float The p-value for the hypothesis test.

x參數為樣本值序列,返回值中第一個為檢驗統計量,第二個為P值,當P值大于指定的顯著性水平,則接受原假設。

2.scipy.stats.kstest(K-S檢驗):可以檢驗多種分布,不止正態分布,其原假設:數據符合正態分布。

其函數定義為:

def kstest(rvs, cdf, args=(), N=20, alternative=’two-sided’, mode=’approx’): ''' Perform the Kolmogorov-Smirnov test for goodness of fit. This performs a test of the distribution G(x) of an observed random variable against a given distribution F(x). Under the null hypothesis the two distributions are identical, G(x)=F(x). The alternative hypothesis can be either ’two-sided’ (default), ’less’ or ’greater’. The KS test is only valid for continuous distributions. Parameters ---------- rvs : str, array or callable If a string, it should be the name of a distribution in `scipy.stats`. If an array, it should be a 1-D array of observations of random variables. If a callable, it should be a function to generate random variables; it is required to have a keyword argument `size`. cdf : str or callable If a string, it should be the name of a distribution in `scipy.stats`. If `rvs` is a string then `cdf` can be False or the same as `rvs`. If a callable, that callable is used to calculate the cdf. args : tuple, sequence, optional Distribution parameters, used if `rvs` or `cdf` are strings. N : int, optional Sample size if `rvs` is string or callable. Default is 20. alternative : {’two-sided’, ’less’,’greater’}, optional Defines the alternative hypothesis (see explanation above). Default is ’two-sided’. mode : ’approx’ (default) or ’asymp’, optional Defines the distribution used for calculating the p-value. - ’approx’ : use approximation to exact distribution of test statistic - ’asymp’ : use asymptotic distribution of test statistic Returns ------- statistic : float KS test statistic, either D, D+ or D-. pvalue : float One-tailed or two-tailed p-value.

參數是:

rvs:待檢驗數據。

cdf:檢驗分布,例如’norm’,’expon’,’rayleigh’,’gamma’等分布,設置為’norm’時表示正態分布。

alternative:默認為雙側檢驗,可以設置為’less’或’greater’作單側檢驗。

model:’approx’(默認值),表示使用檢驗統計量的精確分布的近視值;’asymp’:使用檢驗統計量的漸進分布。

其返回值中第一個為統計量,第二個為P值。

3.scipy.stats.normaltest:正態性檢驗,其原假設:樣本來自正態分布。

其函數定義為:

def normaltest(a, axis=0, nan_policy=’propagate’): ''' Test whether a sample differs from a normal distribution. This function tests the null hypothesis that a sample comes from a normal distribution. It is based on D’Agostino and Pearson’s [1]_, [2]_ test that combines skew and kurtosis to produce an omnibus test of normality. Parameters ---------- a : array_like The array containing the sample to be tested. axis : int or None, optional Axis along which to compute test. Default is 0. If None, compute over the whole array `a`. nan_policy : {’propagate’, ’raise’, ’omit’}, optional Defines how to handle when input contains nan. ’propagate’ returns nan, ’raise’ throws an error, ’omit’ performs the calculations ignoring nan values. Default is ’propagate’. Returns ------- statistic : float or array ``s^2 + k^2``, where ``s`` is the z-score returned by `skewtest` and ``k`` is the z-score returned by `kurtosistest`. pvalue : float or array A 2-sided chi squared probability for the hypothesis test.

其參數:

axis=None 可以表示對整個數據做檢驗,默認值是0。

nan_policy:當輸入的數據中有nan時,’propagate’,返回空值;’raise’ 時,拋出錯誤;’omit’ 時,忽略空值。

其返回值中,第一個是統計量,第二個是P值。

4.scipy.stats.anderson:由 scipy.stats.kstest 改進而來,用于檢驗樣本是否屬于某一分布(正態分布、指數分布、logistic 或者 Gumbel等分布)

其函數定義為:

def anderson(x, dist=’norm’): ''' Anderson-Darling test for data coming from a particular distribution The Anderson-Darling tests the null hypothesis that a sample is drawn from a population that follows a particular distribution. For the Anderson-Darling test, the critical values depend on which distribution is being tested against. This function works for normal, exponential, logistic, or Gumbel (Extreme Value Type I) distributions. Parameters ---------- x : array_like array of sample data dist : {’norm’,’expon’,’logistic’,’gumbel’,’gumbel_l’, gumbel_r’, ’extreme1’}, optional the type of distribution to test against. The default is ’norm’ and ’extreme1’, ’gumbel_l’ and ’gumbel’ are synonyms. Returns ------- statistic : float The Anderson-Darling test statistic critical_values : list The critical values for this distribution significance_level : list The significance levels for the corresponding critical values in percents. The function returns critical values for a differing set of significance levels depending on the distribution that is being tested against.

其參數:

x和dist分別表示樣本數據和分布。

返回值有三個,第一個表示統計值,第二個表示評價值,第三個是顯著性水平;評價值和顯著性水平對應。

對于不同的分布,顯著性水平不一樣。

Critical values provided are for the following significance levels: normal/exponenential 15%, 10%, 5%, 2.5%, 1% logistic 25%, 10%, 5%, 2.5%, 1%, 0.5% Gumbel 25%, 10%, 5%, 2.5%, 1%

關于統計值與評價值的對比:當統計值大于這些評價值時,表示在對應的顯著性水平下,原假設被拒絕,即不屬于某分布。

If the returned statistic is larger than these critical values then for the corresponding significance level, the null hypothesis that the data come from the chosen distribution can be rejected.

5.skewtest 和kurtosistest 檢驗:用于檢驗樣本的skew(偏度)和kurtosis(峰度)是否與正態分布一致,因為正態分布的偏度=0,峰度=3。

偏度:偏度是樣本的標準三階中心矩。

Python數據正態性檢驗實現過程

峰度:峰度是樣本的標準四階中心矩。

Python數據正態性檢驗實現過程

6. 代碼如下:

import numpy as npfrom scipy import statsa = np.random.normal(0,2,50)b = np.linspace(0, 10, 100)# Shapiro-Wilk testS,p = stats.shapiro(a)print(’the shapiro test result is:’,S,’,’,p)# kstest(K-S檢驗)K,p = stats.kstest(a, ’norm’)print(K,p)# normaltestN,p = stats.normaltest(b)print(N,p)# Anderson-Darling testA,C,p = stats.anderson(b,dist=’norm’)print(A,C,p)

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網。

標簽: Python 編程
相關文章:
日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区
欧美黑人做爰爽爽爽| 老鸭窝毛片一区二区三区| 日韩精品一二三区| 狠狠色狠狠色综合日日tαg| 日本不卡免费高清视频在线| 麻豆视频一区二区| 精品国产18久久久久久二百| 美女视频黄 久久| 精品视频一区二区三区在线观看 | 国产精品亚洲二区| 亚洲一区网站| 蜜臀av性久久久久蜜臀aⅴ四虎| 丝袜亚洲另类欧美| 日韩综合一区二区| 欧美日韩夜夜| 国产一区二区三区四区大秀 | 麻豆国产91在线播放| 国内自拍视频一区二区三区| 福利一区二区| 久久精品1区| 亚洲成人日韩| 亚洲一区二区成人| 日韩一区二区三区精品 | 免费日韩av片| 91成人精品在线| 黄色精品视频| 蜜桃国内精品久久久久软件9| 免费看的黄色欧美网站| 日韩美女精品| 精品资源在线| 在线日韩欧美| 人人爽香蕉精品| 久久国产精品免费一区二区三区 | 麻豆精品99| 999精品一区| 蜜臀av一区二区三区| 国产精品久久久久久久久免费高清| 国产成人久久| 一区二区亚洲精品| **爰片久久毛片| аⅴ资源天堂资源库在线| 免费欧美一区| 欧美久久一区二区三区| 中文字幕在线免费观看视频| 婷婷综合亚洲| 国产探花一区在线观看| 日韩1区2区| 久久福利一区| 狠狠久久伊人| 中文字幕一区二区三区日韩精品 | 色婷婷精品视频| 自拍自偷一区二区三区| 国产+成+人+亚洲欧洲在线| 国产午夜精品一区二区三区欧美| 国产日韩一区二区三免费高清 | 狠狠色狠狠色综合日日tαg| 国产调教一区二区三区| 亚洲国产福利| 在线精品视频一区| jizzjizz中国精品麻豆| 日韩中文字幕一区二区三区| 精品久久久久久久| 亚洲精品亚洲人成在线观看| 久久久久久亚洲精品美女| 亚洲美洲欧洲综合国产一区| 久久av国产紧身裤| 国产亚洲一级| 在线看片福利| 国产亚洲精品精品国产亚洲综合| 国精品一区二区| 久久亚洲精精品中文字幕| 日韩中文字幕av电影| 91综合网人人| 亚洲精品自拍| 欧美一级精品| 九九九精品视频| 日本国产一区| 狠狠干成人综合网| 欧美国产偷国产精品三区| 日本不卡一二三区黄网| 香蕉久久精品| 国产一区精品福利| 欧美日韩午夜| 丝瓜av网站精品一区二区| 精品日韩视频| 国产精品v日韩精品v欧美精品网站 | 亚洲黄色影院| 狠狠久久伊人中文字幕| 热久久久久久| 蜜桃视频在线观看一区| 亚洲国产综合在线看不卡| 国产一区二区三区亚洲| 日本aⅴ精品一区二区三区 | 麻豆视频在线看| 国产精品一区二区精品视频观看| 国产精品日韩久久久| 日韩成人高清| 福利一区二区| 麻豆高清免费国产一区| 91麻豆精品| 五月亚洲婷婷 | 日韩国产在线一| 在线视频免费在线观看一区二区| 成人在线免费观看网站| 国产三级一区| 国产三级精品三级在线观看国产| 亚洲欧美网站在线观看| 日韩中文字幕区一区有砖一区 | 国产极品模特精品一二| 日韩一区精品| 综合激情五月婷婷| 丝袜美腿一区二区三区| 亚洲激情偷拍| 欧美精品一区二区三区精品| 日韩欧美一区二区三区在线视频 | 亚洲综合福利| 亚洲一区二区三区中文字幕在线观看| 国产视频一区三区| 午夜久久99| 亚洲成人日韩| 美女网站久久| 日韩影院免费视频| 亚洲一区二区日韩| 日本不卡在线视频| 日本午夜精品一区二区三区电影| 亚洲精品日韩久久| 一区二区高清| 日韩专区在线视频| 蜜臀精品一区二区三区在线观看 | 一本综合精品| 中文字幕一区二区三区在线视频| 美国三级日本三级久久99 | а√天堂中文在线资源8| 捆绑调教日本一区二区三区| 成人国产精品久久| 精品捆绑调教一区二区三区 | 日韩一区二区免费看| 国产视频一区三区| 美美哒免费高清在线观看视频一区二区| 中文字幕一区二区三区四区久久| 天堂av一区| 国产欧美日本| 成人国产精品一区二区免费麻豆| 成人日韩在线观看| 91久久中文| 偷拍亚洲精品| 久久一区欧美| 久久精品1区| 久久av一区二区三区| 热久久久久久| 成午夜精品一区二区三区软件| 成人看片网站| 在线日韩欧美| 亚洲人亚洲人色久| 久久av综合| 久久久777| 亚洲一区欧美二区| 国产精品日本一区二区不卡视频| 精品国产一区二区三区性色av| 久久久噜噜噜| 一区二区精彩视频| 精品欧美日韩精品| 蜜臀久久99精品久久一区二区| 国产一区亚洲| 涩涩涩久久久成人精品| 国产aⅴ精品一区二区三区久久 | 亚洲精品系列| 国产在线不卡一区二区三区| 亚洲一级二级| 日韩高清欧美激情| 中文在线免费视频| 一本综合精品| 四虎国产精品免费观看| jiujiure精品视频播放| 日韩国产欧美在线播放| a天堂资源在线| 亚洲精品在线二区| 91欧美在线| 爽爽淫人综合网网站| 日韩高清三区| 日韩在线不卡| 亚洲精品成a人ⅴ香蕉片| 国产精品精品国产一区二区| 国产日韩专区| 成人台湾亚洲精品一区二区| 国产一区视频在线观看免费| 日韩高清在线不卡| 激情综合网站| 久久免费视频66| 伊人久久成人| 精品国产a一区二区三区v免费| 日韩精品一二区| xxxxx性欧美特大| 日韩高清欧美激情| 亚洲成人一区在线观看| 欧美日韩1区2区3区| 亚洲天堂黄色| 国产乱论精品| 亚洲综合日本| 日韩在线综合|