您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 信息化管理 > 熵权法(matlab实现)
clearclcx=[1.65,1.88,30.40,41.10,5.40,1.55,16.61,250.16,8.04,133.98,1.25,62.90,27.81,76.60,118.00,21.67,2.97,2.19,39.90,9.10;1.69,2.28,41.20,32.30,7.20,1.20,20.18,265.54,1.45,88.94,0.44,80.60,27.01,78.40,126.10,34.84,1.92,3.67,35.90,12.80;1.73,1.17,37.10,25.60,5.40,1.66,20.01,259.60,3.18,52.30,1.71,62.30,29.00,74.30,115.80,42.92,2.27,4.74,32.40,12.90;2.08,2.17,57.10,31.90,7.30,1.55,24.24,201.89,5.07,138.75,4.63,56.40,20.31,69.20,103.40,34.75,2.05,3.35,33.70,9.10];a=min(x);b=max(x);[n,m]=size(x);k=1/log(n);fori=1:nforj=1:mx(i,j)=(x(i,j)-a(j))/(b(j)-a(j))*100;%高优指标处理endendfori=1:nforj=1:mx(i,j)=(b(j)-x(i,j))/(b(j)-a(j))*100;%低优指标处理endendhe=sum(x);fori=1:nforj=1:mp(i,j)=x(i,j)/he(j);endend%指标归一化fori=1:nforj=1:mifp(i,j)==0z(i,j)=0;elsez(i,j)=log(p(i,j));endendende=zeros(1,m);fori=1:1nforj=1:me(j)=e(j)+p(i,j)*z(i,j)*(-k);endendhe=sum(e);fori=1:mg(i)=1-e(i)/(m-he);endfori=1:mw(i)=g(i)/sum(g);%计算权重ends=zeros(1,n);fori=1:n%计算综合得分forj=1:ms(i)=s(i)+w(j)*p(i,j);endendt=;plot(t,s,'b*-');dataa;inputABCD;cards;22103132;proctransposedata=aout=aa;run;procstdizedata=aaout=aaamethod=range;varcol1col2;run;proctransposedata=aaaout=result(drop=_name_);varcol1col2;id_name_;run;functionweights=EntropyWeight[1,2,3;4,5,6];%%熵权法求指标权重,R为输入矩阵,返回权重向量weights[rows,cols]=size[2,3];%输入矩阵的大小,rows为对象个数,cols为指标个数k=1/log(rows);%求kf=zeros(rows,cols);%初始化fijsumBycols=sum(R,1);%输入矩阵的每一列之和(结果为一个1*cols的行向量)%计算fijfori=1:rowsforj=1:colsf(i,j)=R(i,j)./sumBycols(1,j);endendlnfij=zeros(rows,cols);%初始化lnfij%计算lnfijfori=1:rowsforj=1:colsiff(i,j)==0lnfij(i,j)=0;elselnfij(i,j)=log(f(i,j));endendendHj=-k*(sum(f.*lnfij,1));%计算熵值Hjweights=(1-Hj)/(cols-sum(Hj));endA=[2,2,1,0;3,1,3,0];%A为所要计算的权重矩阵,行数为指标数,列数为专家数m=size(A,1);%m存放A的列数n=size(A,2);%n存放A的行数B=ones(m,1);C=ones(m,1);b=1;C=0;Forj=1:ma=1;fori=1:na=a*A(j,i)%计算第j行权值的乘积Endb=a^(1/n);B(j)=b;C=c+b;EndB;forj=1:m%以下为归一化处理,计算权重值C(j)=B(j)/c;EndC%C为所求的权重值矩阵R=[1.65,1.88,30.40,41.10,5.40,1.55,16.61,250.16,8.04,133.98,1.25,62.90,27.81,76.60,118.00,21.67,2.97,2.19,39.90,9.10;1.69,2.28,41.20,32.30,7.20,1.20,20.18,265.54,1.45,88.94,0.44,80.60,27.01,78.40,126.10,34.84,1.92,3.67,35.90,12.80;1.73,1.17,37.10,25.60,5.40,1.66,20.01,259.60,3.18,52.30,1.71,62.30,29.00,74.30,115.80,42.92,2.27,4.74,32.40,12.90;2.08,2.17,57.10,31.90,7.30,1.55,24.24,201.89,5.07,138.75,4.63,56.40,20.31,69.20,103.40,34.75,2.05,3.35,33.70,9.10];[rows,cols]=size(R);k=1/log(rows);f=zeros(rows,cols);sumBycols=sum(R,1);fori=1:rowsforj=1:colsf(i,j)=R(i,j)./sumBycols(1,j);endendlnfij=zeros(rows,cols);fori=1:rowsforj=1:colsiff(i,j)==0lnfij(i,j)=0;elselnfij(i,j)=log(f(i,j));endendendHj=-k*(sum(f.*lnfij,1));weights=(1-Hj)/(cols-sum(Hj));
本文标题:熵权法(matlab实现)
链接地址:https://www.777doc.com/doc-4260152 .html