您好,登錄后才能下訂單哦!
我就廢話不多說了,直接上代碼吧!
# -*- 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 pd import numpy as np import matplotlib.pyplot as plt import statsmodels.tsa.stattools as ts import statsmodels.api as sm from statsmodels.graphics.api import qqplot from statsmodels.sandbox.stats.runs import runstest_1samp import 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=0 for 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品種數據是否是正態分布就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持億速云。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。