时间:2021-05-22
我就废话不多说了,直接上代码吧!
# -*- coding: utf-8 -*-"""Created on Thu Jun 22 17:03:16 2017@author: yunjinqi E-mail:yunjinqi@qq.com Differentiate yourself in the world from anyone else."""import pandas as pdimport numpy as npimport matplotlib.pyplot as pltimport statsmodels.tsa.stattools as tsimport statsmodels.api as smfrom statsmodels.graphics.api import qqplotfrom statsmodels.sandbox.stats.runs import runstest_1sampimport scipy.stats as sts namelist=['cu','al','zn','pb','sn','au','ag','rb','hc','bu','ru','m9','y9','a9', 'p9','c9','cs','jd','l9','v9','pp','j9','jm','i9','sr','cf', 'zc','fg','ta','ma','oi','rm','sm']j=0for i in namelist: filename='C:/Users/HXWD/Desktop/数据/'+i+'.csv' data=pd.read_csv(filename,encoding='gbk') data.columns=['date','open','high','low','close','amt','opi'] data.head() data=np.log(data['close']) r=data-data.shift(1) r=r.dropna() #print(r) rate = np.array(list(r)) print('品种{}数据长度{}均值{}标准差{}方差{}偏度{}峰度{}'.format(i,len(rate), rate.mean(),rate.std(),rate.var(),sts.skew(rate), sts.kurtosis(rate)))#结果品种cu数据长度4976均值0.00012152573153376814标准差0.014276535327917023方差0.0002038194609692628偏度-0.16028824462338614峰度2.642455989417427品种al数据长度5406均值-2.3195089066551237e-05标准差0.009053990835143359方差8.197475004285994e-05偏度-0.34748915595295604峰度5.083890815632417品种zn数据长度2455均值-0.00011823058103745542标准差0.016294570963077237方差0.00026551304287075983偏度-0.316153612624431峰度1.7208737518119293品种pb数据长度1482均值-9.866770650275384e-05标准差0.011417348325010642方差0.0001303558427746233偏度-0.21599833469407717峰度5.878332673854807品种sn数据长度510均值0.00034131697514080907标准差0.013690993291257949方差0.00018744329730127014偏度0.024808842588775293峰1.072347367872859品种au数据长度2231均值0.0001074021979121701标准差0.012100456199756058方差0.00014642104024221482偏度-0.361814930575112峰度4.110915875328322品种ag数据长度1209均值-0.0003262089978362889标准差0.014853094655086982方差0.00022061442083297348偏度-0.2248883178719188峰度4.296247290616826品种rb数据长度1966均值-6.984154093694264e-05标准差0.013462363746262961方差0.00018123523763669528偏度0.07827546016742666峰度5.198115698123077品种hc数据长度758均值-7.256339078572361e-05标准差0.01710980071993581方差0.000292745280675916偏度-0.08403481899486816峰度3.6250669416786323品种bu数据长度864均值-0.0006258998207218544标准差0.01716581014361468方差0.0002946650378866246偏度-0.41242405508236435峰度2.437556911829674品种ru数据长度4827均值5.17426767764321e-05标准差0.016747187916000945方差0.00028046830309384806偏度-0.1986573449586119峰度1.736876616149547品种m9数据长度4058均值8.873778774208505e-05标准差0.012812626470272115方差0.0001641633970667177偏度-0.12119836197638824峰度2.159984922606264品种y9数据长度2748均值4.985975458693667e-05标准差0.012855191360434762方差0.00016525594491339655偏度-0.33456507243405786峰度2.566586342814616品种a9数据长度5392均值9.732600802295795e-05标准差0.010601259945310599方差0.00011238671242804687偏度-0.08768586026629852峰度3.898562231789457品种p9数据长度2311均值-0.00021108840931287863标准差0.014588073181583774方差0.00021281187915124373偏度-0.2881364812318466峰度1.693401619226936品种c9数据长度3075均值0.00010060972262212708标准差0.007206853641314312方差5.1938739407325355e-05偏度-5.204419912904765e-05峰6.074899127691497品种cs数据长度573均值-0.0006465907683602394标准差0.011237570390237955方差0.00012628298827555283偏度0.10170996173895988峰度1.176384982024672品种jd数据长度847均值-9.035290965408637e-05标准差0.01167344224455134方差0.00013626925383687581偏度-0.0682866825422671峰度2.0899893901516133品种l9数据长度2370均值-0.00014710186232216803标准差0.014902467199956509方差0.00022208352864577958偏度-0.2105262196327885峰度1.8796065573836品种v9数据长度1927均值-5.190379527562386e-05标准差0.010437020362123387方差0.00010893139403937818偏度-0.050531345744352064峰度3.47595007264211品种pp数据长度773均值-0.0003789841804842144标准差0.01439578332841083方差0.00020723857763855122偏度0.05479337073436029峰度1.3397870170464232品种j9数据长度1468均值-0.00021854062264841954标准差0.01639429047795793方差0.000268772760275662偏度-0.10048542944058193峰度5.156597958913997品种jm数据长度997均值-0.00011645794468155402标准差0.01792430947223131方差0.000321280870056321偏度0.0010592028961588294峰度3.743159578760195品种i9数据长度862均值-0.0007372124442033161标准差0.021187573227350754方差0.0004489132592643504偏度0.00014411506989559858峰度1.585951370650品种sr数据长度2749均值0.00012213466321006727标准差0.012183745931527473方差0.00014844366492401223偏度-0.038613285961243735峰度2.520231613626品种cf数据长度3142均值2.2008517526768612e-05标准差0.010657271857464626方差0.00011357744344390753偏度-0.034412876065561426峰度5.6421501855702品种zc数据长度475均值0.00041282070613302206标准差0.015170141171075784方差0.00023013318315036853偏度-0.1393361750238265峰度1.2533894316392926品种fg数据长度1068均值-1.57490340832121e-05标准差0.013148411070446203方差0.00017288071367743227偏度0.008980132282547534峰度1.9028507879273144品种ta数据长度2518均值-0.00023122774877981512标准差0.013637519813532077方差0.00018598194666447998偏度-0.9126347458178135峰度10.954670464918品种ma数据长度700均值-0.00024988691257348835标准差0.015328611435734359方差0.00023496632854772616偏度0.0164362832185746峰度1.1736088397060品种oi数据长度1098均值-0.0004539513793265549标准差0.009589990427720812方差9.196791640377678e-05偏度-0.28987574371279706峰度3.871322266527967品种rm数据长度1049均值1.458523923966432e-05标准差0.013432556545527753方差0.00018043357534880047偏度-0.053300026893851014峰度1.3938292783638品种sm数据长度548均值-3.179600698107184e-05标准差0.020018458278106444方差0.00040073867183228846偏度-2.6734390275887647峰度31.533801188366837#正态分布的偏度应该是0,峰度是3,所以,不满者这些的都是非标准正态分布以上这篇python 实现检验33品种数据是否是正态分布就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
importnumpyasnpimportmatplotlib.pyplotaspltimportmath#Python实现正态分布#绘制正态分布概率密度函数u
在做数据分析或者统计的时候,经常需要进行数据正态性的检验,因为很多假设都是基于正态分布的基础之上的,例如:T检验。在Python中,主要有以下检验正态性的方法:
利用观测数据判断总体是否服从正态分布的检验称为正态性检验,它是统计判决中重要的一种特殊的拟合优度假设检验。直方图初判:直方图+密度线QQ图判断:(s_r.ind
说明wilcoxon秩和及wilcoxon符号秩检验是对原假设的非参数检验,在不需要假设两个样本空间都为正态分布的情况下,测试它们的分布是否完全相同。操作#利用
使用Python绘制正态分布曲线,借助matplotlib绘图工具;#-*-coding:utf-8-*-"""python绘制标准正态分布曲线"""#====