熵权法代码以及模板
The Entropy Method is derived from thermodynamics and is later introduced to telecommunication, energy, finance and other disciplines. Previous studies have successfully used this method to determine the weight of a group of indicators which are used for evaluation.
熵权法适合我们的研究,原因是我们的指标的非常繁杂,很难确定相应的权重,。通过熵权法处理已经标准化后的数据,得到相应的权重。
To start with, the entropy value of indicator is obtained by the equation:
Where:
Accordingly, we determine the weight of indicator by equation:
Hence, the comprehensive performance of this a country
function weights = EntropyWeight(R)
%% 熵权法求指标权重,R为输入矩阵,返回权重向量weights
clc,clear
R=[0.120965662 0.060739431
0.143930393 0.003180801
0.334914034 0
0.21005113 0.010565369
0.289401773 0.024218562
0.353263351 0.022606904
0.38374068 0.03347756
0.5283851 0.040057247
0.622980189 0.030080483
0.53220209 0.040741393
1 1
0.038037703 0.013172233
0.031439014 0.013278932
0.025778546 0.013273949
0.020549523 0.013642691
0.016416445 0.013912351
0.013149036 0.014098809
0.010357782 0.014305312
0.008026561 0.014565034
0.006137755 0.014797325
0.004579358 0.015020222
0.003280466 0.015252275
0.002210328 0.015490769
0.001330235 0.015723923
0.000602044 0.015957285
0 0.016193287];
[rows,cols]=size(R); % 输入矩阵的大小,rows为对象个数,cols为指标个数
%-----------------------输入标准化后的矩阵R
% 指标 指标 指标 指标
% 对象
% 对象
% 对象
% 对象
%-----------------------
k=1/log(rows); % 求k
f=zeros(rows,cols); % 初始化fij
sumBycols=sum(R,1); % 输入矩阵的每一列之和(结果为一个1*cols的行向量)
% 计算fij
for i=1:rows
for j=1:cols
f(i,j)=R(i,j)./sumBycols(1,j);
end
end
lnfij=zeros(rows,cols); % 初始化lnfij
% 计算lnfij
for i=1:rows
for j=1:cols
if f(i,j)==0
lnfij(i,j)=0;
else
lnfij(i,j)=log(f(i,j));
end
end
end
Hj=-k*(sum(f.*lnfij,1)); % 计算熵值Hj
weights=(1-Hj)/(cols-sum(Hj));
end