主成分分析報(bào)告法MATLAB地實(shí)現(xiàn)_第1頁(yè)
主成分分析報(bào)告法MATLAB地實(shí)現(xiàn)_第2頁(yè)
主成分分析報(bào)告法MATLAB地實(shí)現(xiàn)_第3頁(yè)
主成分分析報(bào)告法MATLAB地實(shí)現(xiàn)_第4頁(yè)
主成分分析報(bào)告法MATLAB地實(shí)現(xiàn)_第5頁(yè)
已閱讀5頁(yè),還剩7頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

實(shí)用標(biāo)準(zhǔn)MATLAB結(jié)課作業(yè)指導(dǎo)老師:張肅班級(jí):信管121姓名:桂亞?wèn)|學(xué)號(hào):201200654118文案大全實(shí)用標(biāo)準(zhǔn)利用Matlab編程實(shí)現(xiàn)主成分分析概述Matlab語(yǔ)言是當(dāng)今國(guó)際上科學(xué)界 (尤其是自動(dòng)控制領(lǐng)域) 最具影響力、也是最有活力的軟件。它起源于矩陣運(yùn)算,并已經(jīng)發(fā)展成一種高度集成的計(jì)算機(jī)語(yǔ)言。它提供了強(qiáng)大的科學(xué)運(yùn)算、靈活的程序設(shè)計(jì)流程、高質(zhì)量的圖形可視化與界面設(shè)計(jì)、與其他程序和語(yǔ)言的便捷接口的功能。 Matlab 語(yǔ)言在各國(guó)高校與研究單位起著重大的作用。主成分分析是把原來(lái)多個(gè)變量劃為少數(shù)幾個(gè)綜合指標(biāo)的一種統(tǒng)計(jì)分析方法,從數(shù)學(xué)角度來(lái)看,這是一種降維處理技術(shù)。1.1主成分分析計(jì)算步驟①計(jì)算相關(guān)系數(shù)矩陣r11r12r1pr21r22r2pRrp1rp2rpp(1)在()式中,rij(i,j=1,2,?,p)為原變量的xi與xj之間的相關(guān)系數(shù),其計(jì)算公式為n(xkixi)(xkjxj)rijk1nnxi)2xj)2(xki(xkjk1k1(2)因?yàn)镽是實(shí)對(duì)稱矩陣(即 rij=rji),所以只需計(jì)算上三角元素或下三角元素即可。②計(jì)算特征值與特征向量文案大全實(shí)用標(biāo)準(zhǔn)首先解特征方程IR0,通常用雅可比法(Jacobi)求出特征值i(i1,2,,p),并使其按大小順序排列,即12,p0;然后分別求p出對(duì)應(yīng)于特征值i的特征向量ei(i1,2,,p)。這里要求ei=1,即eij21,其j1中eij表示向量ei的第j個(gè)分量。計(jì)算主成分貢獻(xiàn)率及累計(jì)貢獻(xiàn)率主成分zi的貢獻(xiàn)率為i(i1,2,,p)pk1k累計(jì)貢獻(xiàn)率為ikk1(i1,2,,p)pkk1一般取累計(jì)貢獻(xiàn)率達(dá) 85—95%的特征值 1,2, , m所對(duì)應(yīng)的第一、第二,?,第m(m≤p)個(gè)主成分。計(jì)算主成分載荷其計(jì)算公式為lijp(zi,xj)ieij(i,j1,2,,p)(3)得到各主成分的載荷以后,還可以按照( )式進(jìn)一步計(jì)算,得到各主成分的得分文案大全實(shí)用標(biāo)準(zhǔn)z11z12z1mz21z22z2mZzn1zn2znm(4)函數(shù)作用Cwstd.m——用總和標(biāo)準(zhǔn)化法標(biāo)準(zhǔn)化矩陣Cwfac.m——計(jì)算相關(guān)系數(shù)矩陣;計(jì)算特征值和特征向量;對(duì)主成分進(jìn)行排序;計(jì)算各特征值貢獻(xiàn)率;挑選主成分(累計(jì)貢獻(xiàn)率大于 85%),輸出主成分個(gè)數(shù);計(jì)算主成分載荷Cwscore.m——計(jì)算各主成分得分、綜合得分并排序Cwprint.m——讀入數(shù)據(jù)文件;調(diào)用以上三個(gè)函數(shù)并輸出結(jié)果源程序3.1cwstd.m 總和標(biāo)準(zhǔn)化法標(biāo)準(zhǔn)化矩陣%cwstd.m,用總和標(biāo)準(zhǔn)化法標(biāo)準(zhǔn)化矩陣functionstd=cwstd(vector)cwsum=sum(vector,1); % 對(duì)列求和[a,b]=size(vector); % 矩陣大小,a為行數(shù),b為列數(shù)fori=1:aforj=1:bstd(i,j)=vector(i,j)/cwsum(j);endend3.2cwfac.m 計(jì)算相關(guān)系數(shù)矩陣文案大全實(shí)用標(biāo)準(zhǔn)%cwfac.mfunctionresult=cwfac(vector);fprintf(' 相關(guān)系數(shù)矩陣 :\n')std=CORRCOEF(vector) % 計(jì)算相關(guān)系數(shù)矩陣fprintf(' 特征向量(vec)及特征值(val) :\n')[vec,val]=eig(std) % 求特征值(val) 及特征向量(vec)newval=diag(val);[y,i]=sort(newval); % 對(duì)特征根進(jìn)行排序, y為排序結(jié)果,i為索引fprintf(' 特征根排序: \n')forz=1:length(y)newy(z)=y(length(y)+1-z);endfprintf('%g\n',newy)rate=y/sum(y);fprintf('\n 貢獻(xiàn)率:\n')newrate=newy/sum(newy)sumrate=0;newi=[];fork=length(y):-1:1sumrate=sumrate+rate(k);newi(length(y)+1-k)=i(k);ifsumrate>0.85break;endend % 記下累積貢獻(xiàn)率大 85%的特征值的序號(hào)放入 newi中fprintf(' 主成分?jǐn)?shù):%g\n\n',length(newi));fprintf(' 主成分載荷: \n')forp=1:length(newi)forq=1:length(y)result(q,p)=sqrt(newval(newi(p)))*vec(q,newi(p));endend % 計(jì)算載荷disp(result)3.3cwscore.m%cwscore.m,計(jì)算得分functionscore=cwscore(vector1,vector2);sco=vector1*vector2;csum=sum(sco,2);[newcsum,i]=sort(-1*csum);[newi,j]=sort(i);文案大全實(shí)用標(biāo)準(zhǔn)fprintf(' 計(jì)算得分:\n')score=[sco,csum,j]%得分矩陣:sco為各主成分得分; csum為綜合得分; j為排序結(jié)果3.4cwprint.m%cwprint.mfunctionprint=cwprint(filename,a,b);%filename為文本文件文件名, a為矩陣行數(shù)(樣本數(shù)),b為矩陣列數(shù)(變量指標(biāo)數(shù))fid=fopen(filename,'r')vector=fscanf(fid,'%g',[ab]);fprintf(' 標(biāo)準(zhǔn)化結(jié)果如下: \n')v1=cwstd(vector)result=cwfac(v1);cwscore(v1,result);程序測(cè)試4.1原始數(shù)據(jù)中國(guó)大陸35個(gè)大城市某年的 10項(xiàng)社會(huì)經(jīng)濟(jì)統(tǒng)計(jì)指標(biāo)數(shù)據(jù)見(jiàn)下表。非農(nóng)客運(yùn)貨運(yùn)城鄉(xiāng)居民城市年底農(nóng)業(yè)工業(yè)總量總量地方財(cái)政年底儲(chǔ)蓄在崗職業(yè)名稱總?cè)丝诳偖a(chǎn)值總產(chǎn)值(萬(wàn)(萬(wàn)預(yù)算內(nèi)收余額工人數(shù)人口比入(萬(wàn)元)(萬(wàn)人)(萬(wàn)人)(萬(wàn)元)(萬(wàn)元)人)噸)(萬(wàn)元)(%)北0.5971843427199997062032345562279086326806646410.80京1249.9080.580150113622645502325926317112807311301931202.68天津910.1790.2332918680688576829291911352348709587595.60石家莊875.402太原0.6562360382737750193711895203277394310088.65299.9230.44136534381645223512623105783139658842.11呼和浩特207.782

在崗職工工資總額(萬(wàn)元)57733012254343877023337文案大全實(shí)用標(biāo)準(zhǔn)沈陽(yáng)677.080.629129541858267337782154125679199016998135.4511528119大連545.310.494187973984263851078019187709227755679694.159659226長(zhǎng)春691.230.40618532105966343481095323570964803744102.638844478哈爾濱927.090.46226638554186123672075204814436450020172.7913091517上海1313.120.738206901954529098640644485431850025971200336.8456054454南京537.440.5349891991307273714269111936642995680472113.8113578611杭州616.050.3551414737120007961788311684449593742596796.9011809476寧波538.410.2541428235106228662221510298501723524635062.158240347合肥429.950.318628764251412548931517233628162293147.273695774福州583.130.2732152288655535188517190467524503022069.596806073廈門128.990.486333374575112437282570418758210833146.936574845南昌424.200.398688289230588136743189167714264046062.08479,5558濟(jì)南557.630.40814863026285882591511775460690412697083.317566965青島702.970.36923823201149203613408170386584354978045103.529617043鄭州615.360.3426774255287601104336768387252513533884.666968484武漢740.200.586121129175060859793154426046585748055149.2013147669長(zhǎng)沙582.470.3101146367309817987065718323660346124469.575969867廣州685.000.6211600738233481392200723854176149920401811182.8130475944深圳119.850.79329966220368295875442741847908951990091.2618903381南寧285.870.406720486114969151303293149700219091845.09371809文案大全實(shí)用標(biāo)準(zhǔn)4???4.380.8354481571746153452356115174162680019.011981384重慶3072.340.206416878085855255244125124898,9129090969223.7316068047成都1003.560.3351935590589428940140196325611897479684132.891200671貴陽(yáng)321.500.4553620612247934157034143197908178774855.284196817昆明473.390.3867933563605729560412042524216412790088.118423215西安674.500.40973990536659421031197664088965863980114.018851694蘭州287.590.544259444294088418324749169540264156865.835508905西寧133.950.52265848711310174614694913485505127.212192517銀川95.380.570171603661226210611937475881410323.721786219烏魯木齊158.920.82478513184724126689041254870236550855.2751762244.2運(yùn)行結(jié)果cwprint('cwbook.txt',35,10)fid=6數(shù)據(jù)標(biāo)準(zhǔn)化結(jié)果如下:v1=0.0581 0.03560.04350.06800.05570.11120.11940.11840.10830.13920.0423 0.03460.03540.07700.00890.06420.04830.04990.05340.05440.0407 0.01390.06880.02340.00800.00470.01510.03140.02520.01830.0139 0.03910.00560.00930.00530.02900.00870.01740.02340.01580.0097 0.02630.00860.00280.00640.00640.00450.00620.01110.0075文案大全實(shí)用標(biāo)準(zhǔn)0.0315 0.03750.03050.01980.02130.03760.02430.03980.03570.02780.0253 0.02950.04430.02860.02950.04680.03040.03340.02480.02330.0321 0.02420.04370.02030.01320.02330.01530.02120.02700.02130.0431 0.02760.06280.01420.01840.01840.02060.02850.04550.03160.0610 0.04400.04880.18530.01760.10860.18480.11480.08880.13520.0250 0.03180.02330.04440.03910.02730.02840.02510.03000.03270.0286 0.02120.03340.04080.04900.02850.01920.03280.02550.02850.0250 0.01520.03370.03610.06090.02510.02150.02320.01640.01990.0200 0.01900.01480.00850.01340.00370.01000.00720.01250.00890.0271 0.01630.05080.02230.02430.01750.02000.02220.01830.01640.0060 0.02900.00790.01950.01020.00630.01790.00930.01240.01590.0197 0.02370.01620.00780.01010.00780.00720.01170.01640.01160.0259 0.02430.03500.02140.01620.02870.01970.01820.02200.01820.0327 0.02200.05620.03910.03670.04160.02820.02200.02730.02320.0286 0.02040.01600.01800.02860.01650.01660.02270.02230.01680.0344 0.03490.02860.02550.02680.03770.02590.02540.03930.03170.0271 0.01850.02700.01050.02390.01400.01390.01530.01830.01440.0318 0.03700.03770.07930.06030.05820.07540.09010.04820.07350.0056 0.04720.00710.06920.02400.01040.07910.04210.02400.04560.0133 0.02420.01700.00390.01410.00800.00640.00970.01190.00900.0025 0.04970.00110.00240.01460.00570.00490.00720.00500.00480.1428 0.01230.09830.02920.14370.06130.03850.04020.05900.03870.0466 0.01990.04560.02000.11000.04790.02400.03310.03500.02900.0149 0.02710.00850.00760.04300.01010.00850.00790.01460.01010.0220 0.02300.01870.01230.01540.02940.02240.01820.02320.02030.0313 0.02440.01740.01250.02830.02380.01750.02590.03000.02130.0134 0.03240.00610.01000.00500.01160.00730.01170.01730.01330.0062 0.03110.00160.00240.00480.00360.00210.00380.00720.00530.0044 0.03400.00400.00220.00580.00290.00320.00360.00630.00430.0074 0.04910.00190.00630.00730.02210.01090.01050.01460.0125相關(guān)系數(shù)矩陣:std=1.0000-0.34440.84250.36030.73900.62150.40390.49670.67610.4689-0.34441.0000-0.47500.3096-0.35390.19710.35710.26000.15700.30900.8425-0.47501.00000.33580.58910.50560.32360.44560.55750.37420.36030.30960.33581.00000.15070.76640.94120.84800.73200.8614文案大全實(shí)用標(biāo)準(zhǔn)0.7390-0.35390.58910.15071.00000.42940.19710.31820.38930.25950.62150.19710.50560.76640.42941.00000.83160.89660.93020.90270.40390.35710.32360.94120.19710.83161.00000.92330.83760.95270.49670.26000.44560.84800.31820.89660.92331.00000.92010.97310.67610.15700.55750.73200.38930.93020.83760.92011.00000.93960.46890.30900.37420.86140.25950.90270.95270.97310.93961.0000特征向量(vec):vec=-0.13670.2282-0.26280.19390.6371-0.21630.3176-0.1312-0.41910.2758-0.0329-0.02170.00090.0446-0.1447-0.44370.4058-0.55620.54870.0593-0.0522-0.02800.2040-0.0492-0.5472-0.42250.34400.3188-0.44380.24010.0067-0.4176-0.2856-0.23890.1926-0.4915-0.41890.27260.20650.34030.04040.14080.08960.0380-0.1969-0.0437-0.4888-0.6789-0.44050.1861-0.03430.23600.0640-0.82940.03770.26620.1356-0.12900.02780.37820.29810.47390.56850.23580.1465-0.1502-0.26310.12450.21520.36440.15670.3464-0.64850.2489-0.40430.2058-0.07040.04620.12140.38120.4879-0.57070.12170.17610.09870.35500.3280-0.01390.00710.3832-0.7894-0.16280.19250.2510-0.04220.26940.03960.04560.16680.3799特征值(val)val=0.003900000000000.024000000000000.030700000000000.099100000000000.123200000文案大全實(shí)用標(biāo)準(zhǔn)000000.256600000000000.320700000000000.530000000000002.351400000000006.2602特征根排序:6.260222.351380.5300470.3206990.2566390.1232410.09909150.03070880.02403550.00393387各主成分貢獻(xiàn)率:newrate=0.6260 0.2351 0.0530 0.0321 0.0257 0.0123 0.0099 0.0031 0.00240.0004第一、二主成分的載荷:0.6901 -0.64270.1483 0.

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論