matlab與聚類分析.doc
《matlab與聚類分析.doc》由會員分享,可在線閱讀,更多相關(guān)《matlab與聚類分析.doc(4頁珍藏版)》請在裝配圖網(wǎng)上搜索。
第五章聚類分析安慶師范學(xué)院 胡云峰習(xí)題5.3.下表給出我國歷年職工人數(shù)(單位:萬人),請用有序樣品的fisher法聚類。年份全民所有制集體所有制195215802319541881121195624235541958453266219605044925196233031012196434651136196639391264196841701334197047921424197256101524197460071644197668601813197874512048198080192425解 第一步數(shù)據(jù)標(biāo)準(zhǔn)化后計算直徑D程序:X=1580 23;1881 121;2423 554;4532 662;5044 925;3303 1012;3465 1136;. 3939 1264;4170 1334;4792 1424;5610 1524;6007 1644;6860 1813;. 7451 2048;8019 2425;stdr=std(X);n,m=size(X);X=X./stdr(ones(n,1),:); n p=size(X);D=zeros(n,n);for i=1:1:n; for j=1:1:n; if ij t=i:1:j; xgjunzhi=(1/(j-i+1)*sum(X(t,:); y=zeros(1,j-i+1); for s=i:1:j y(s)=(X(s,:)-xgjunzhi)*(X(s,:)-xgjunzhi); end s=i:1:j; D(i,j)=sum(y); else D(i,j)=0; end endendD=D輸出結(jié)果 矩陣太大,所以用excel處理了一下D=0000000000000000.022567000000000000000.448980.2457800000000000002.06321.39810.600240000000000003.92562.6511.18020.11098000000000004.50223.00911.42380.569530.4086200000000005.1793.43531.66480.825760.538310.020440000000006.08234.0211.9761.0230.633430.127810.047757000000007.03114.65022.32551.23130.7550.263410.112750.01245600000008.33225.57622.90941.60451.05310.606190.338810.131220.06003200000010.3127.10344.01172.41261.77721.37930.923140.526640.315410.0994010000012.6968.99725.44223.51142.75482.35531.6691.04570.654960.256320.03671000016.29111.9987.86885.50384.56864.11933.10322.14681.47070.771220.308580.1276200021.11716.12811.3218.42987.23166.64875.21163.83122.77931.68770.88810.460160.10709002822.16716.52812.97811.38610.5468.55966.6275.07163.45392.17481.34430.598320.199510我們只看下三角所有元素,其它元素理解為空第二步我們計算損失函數(shù)矩陣L程序:%設(shè)計一個把樣品分為兩類的程序,以及對應(yīng)最后一類分割點D=D;L=zeros(n-1,n-1);alp=zeros(n-1,n-1);for m=2:n; s=zeros(1,m-1); for j=2:m s(1,j-1)=D(1,j-1)+D(j,m); end L(m-1,1)=min(s(1,1:m-1); for j=1:m-1 if L(m-1,1)=s(1,j); alp(m-1,1)=j+1; end endend%分為k類for k=3:n; for m=k:n s=zeros(1,m-k+1); for j=k:m; s(1,j-k+1)=L(j-2,k-2)+D(j,m); end L(m-1,k-1)=min(s(1,1:m-k+1); for j=1:m-k+1 if L(m-1,k-1)=s(1,j); alp(m-1,k-1)=j+k-1; end end endend輸出結(jié)果 這里由于表太大,用excel處理一下L=000000000000000.02256700000000000000.448980.0225670000000000000.559960.133550.022567000000000001.01850.559960.133550.02256700000000001.27470.58040.153990.0430070.020440000000001.4720.687770.261360.150380.0430070.02044000000001.68030.823370.396960.166440.0554640.0328970.01245600000002.05351.16620.711620.285210.166440.0554640.0328970.0124560000002.86161.77970.922770.496360.265840.154860.0554640.0328970.012456000003.96041.93661.07970.653280.321920.203150.0921740.0554640.0328970.0124600005.95282.36211.47471.02020.593790.321920.203150.0921740.0554640.03290.0124560008.71882.94162.04371.18680.760370.429010.310240.199270.0921740.055460.0328970.01245600alp=200000000000003300000000000044400000000000445500000000004666600000000046666700000000466688800000004668888900000046881010101010000004101010101011111111000041010101111111212121200041111111113131313131313001011131313131313141414141401012131415151515151515151515在這里解釋一下這兩個矩陣表示分為k類,k從2到15;列表示樣本數(shù)m,m從2到15接下來我們根據(jù)結(jié)果分析如果我們要把樣品分為三類,則第一個分割點為11,然后第二個分割點為6得到 第一類:1952,1954,1956,1958,1960第二類:1962,1964,1966,1968,1970第三類:1972,1974,1976,1978,1980- 1.請仔細(xì)閱讀文檔,確保文檔完整性,對于不預(yù)覽、不比對內(nèi)容而直接下載帶來的問題本站不予受理。
- 2.下載的文檔,不會出現(xiàn)我們的網(wǎng)址水印。
- 3、該文檔所得收入(下載+內(nèi)容+預(yù)覽)歸上傳者、原創(chuàng)作者;如果您是本文檔原作者,請點此認(rèn)領(lǐng)!既往收益都?xì)w您。
下載文檔到電腦,查找使用更方便
9.9 積分
下載 |
- 配套講稿:
如PPT文件的首頁顯示word圖標(biāo),表示該PPT已包含配套word講稿。雙擊word圖標(biāo)可打開word文檔。
- 特殊限制:
部分文檔作品中含有的國旗、國徽等圖片,僅作為作品整體效果示例展示,禁止商用。設(shè)計者僅對作品中獨創(chuàng)性部分享有著作權(quán)。
- 關(guān) 鍵 詞:
- matlab 聚類分析
鏈接地址:http://italysoccerbets.com/p-6596311.html