1、);xjunzhi=xjunzhiS=(n-1)(-1)*A输出结果xjunzhi = 82.0000 60.2000 14.5000S = 31.6000 8.0400 0.5000 8.0400 3.1720 1.3100 0.5000 1.3100 1.900然后u=90;58;16;t2=n*(xjunzhi-u)*(S(-1)*(xjunzhi-u)f=(n-p)/(p*(n-1)*t2输出结果t2 = 420.4447f = 84.0889所以=420.4447=84.0889查表得F3,3(0.05)=9.2884.0889 F3,3(0.01)=29.51.4982 F0.01
2、(3,11)=6.221.4982因此在a=0.05或 a=0.01时接受第四章习题4.1 下表列举某年级任取12名学生的5门主课的期末考试成绩,试绘制学生序号为1、2、11、12的轮廓图、雷达图。表4.1 学生学习成绩序号政治语文外语数学物理99949310088969798917290827389836887601095623943671285503437解 我们只需要数据如下1 利用matlab画轮廓图程序x=1:5;y1=99 94 93 100 100;y2=99 88 96 99 97;y3=76 72 43 67 78;y4=85 75 50 34 37;plot(x,y1,k-
3、o,linewidth,1);hold on;plot(x,y2,r-*,2);plot(x,y3,b-.phold onplot(x,y4,k-oxlabel(学科ylabel(分数legend(121112set(gca,xtick,1 2 3 4 5)xticklabel,政治语文外语数学物理)输出结果2 利用matlab画雷达图此图用matlab画起来比较复杂首先我们修改polar函数在命令窗口输入edit polar 结果会出现polar函数的程序其中我们把% plot spokes th = (1:6)*2*pi/12; cst = cos(th); snt = sin(th);
4、cs = -cst; cst; sn = -snt; snt; line(rmax*cs,rmax*sn,linestyle,ls,color,tc,1,. handlevisibilityoffparent,cax)修改为3)*2*pi/6;再将后面的所有程序中的30改为72然后另存为work中并命名为mypolar.m然后输入程序x=0:pi/2.5:2*pi;y1=99 94 93 100 100 99;y2=99 88 96 99 97 99;y3=76 72 43 67 78 76;y4=85 75 50 34 37 85;mypolar(x,y1,bmypolar(x,y2,mmy
5、polar(x,y3,gmypolar(x,y4,y)第五章聚类分析习题5.3.下表给出我国历年职工人数(单位:万人),请用有序样品的fisher法聚类。年份全民所有制集体所有制195215802319541881121195624235541958453266219605044925196233031012196434651136196639391264196841701334197047921424197256101524197460071644197668601813197874512048198080192425解 第一步数据标准化后计算直径D程序:X=1580 23;1881 121
6、;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: for j=1: if ij t=i:j; xgjunzhi=(1/(j-i+1)*sum(X(t,: y=zeros(1,j-i+1); for s=i: y(s)=(X(s,:
7、)-xgjunzhi)*(X(s,:)-xgjunzhi) end s=i: D(i,j)=sum(y); else D(i,j)=0;D=D输出结果矩阵太大,所以用excel处理了一下D=0.0225670.448980.245782.06321.39810.600243.92562.6511.18020.110984.50223.00911.42380.569530.408625.1793.43531.66480.825760.538310.020446.08234.0211.9761.0230.633430.127810.0477577.03114.65022.32551.23130.7
8、550.263410.112750.0124568.33225.57622.90941.60451.05310.606190.338810.131220.06003210.3127.10344.01172.41261.77721.37930.923140.526640.315410.09940112.6968.99725.44223.51142.75482.35531.6691.04570.654960.256320.0367116.29111.9987.86885.50384.56864.11933.10322.14681.47070.771220.308580.1276221.11716.
9、12811.3218.42987.23166.64875.21163.83122.77931.68770.88810.460160.107092822.16716.52812.97811.38610.5468.55966.6275.07163.45392.17481.34430.598320.19951我们只看下三角所有元素,其它元素理解为空第二步我们计算损失函数矩阵L%设计一个把样品分为两类的程序,以及对应最后一类分割点L=zeros(n-1,n-1);alp=zeros(n-1,n-1);for m=2: s=zeros(1,m-1); for j=2: s(1,j-1)=D(1,j-1)
10、+D(j,m); L(m-1,1)=min(s(1,1:m-1);m-1 if L(m-1,1)=s(1,j); alp(m-1,1)=j+1;%分为k类for k=3: for m=k: s=zeros(1,m-k+1); for j=k: s(1,j-k+1)=L(j-2,k-2)+D(j,m); L(m-1,k-1)=min(s(1,1:m-k+1);m-k+1 if L(m-1,k-1)=s(1,j); alp(m-1,k-1)=j+k-1;输出结果 这里由于表太大,用excel处理一下L=0.559960.133551.01851.27470.58040.153990.0430071
11、.4720.687770.261360.150381.68030.823370.396960.166440.0554640.0328972.05351.16620.711620.285212.86161.77970.922770.496360.265840.154863.96041.93661.07970.653280.321920.203150.0921740.012465.95282.36211.47471.02020.593790.03298.71882.94162.04371.18680.760370.429010.310240.199270.05546alp=在这里解释一下这两个矩阵
12、行表示分为k类,k从2到15;列表示样本数m,m从2到15我们只看下三角所有元素,其它元素理解为空,接下来我们根据结果分析如果我们要把样品分为三类,则第一个分割点为11,然后第二个分割点为6得到 第一类:1952,1954,1956,1958,1960第二类:1962,1964,1966,1968,1970第三类:1972,1974,1976,1978,1980第六章判别分析例6.6 对全国30个省市自治区1994年影响各地区经济增长差异的制度变量x1经济增长率,x2非国有化水平,x3开放度,x4市场化程度作贝叶斯判别分析。类别地区x1x2x3x4第一组辽宁11.257.2513.4773.4
13、1河北14.967.197.8973.09天津14.364.7419.4172.33北京13.555.6320.5977.33山东16.275.5111.0672.08上海57.6322.5177.35浙江2083.415.9989.5福建21.868.0339.4271.9广东1978.3183.0380.75广西1657.1112.5760.91海南11.949.9730.769.2第二组黑龙江8.730.7215.4160.25吉林37.6512.9566.42内蒙古10.134.637.6862.96山西9.156.3310.366.01河南13.865.234.6964.2417湖北15.355.626.0654.7418湖南55.558.0267.47江西62.856.458.83甘肃10.430.014.6160.2621宁夏8.229.286.1150.7122四川11.462.885.3161.49云南11.628.579.0868.4724贵州30.236.0325青海15.968.0440.2626新疆10.924.758.3446.0127西藏15.621.4428.62待判样品江苏80.058.8173.0429
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1