Technology Sharing

Mathematical Modeling Entropy Weight Method

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

Entropy Weight Method

一种计算评价指标之间权重的方法。熵权法是一种客观的方法,没有主观性,比较可靠。
  • 1

Specific definition

熵权法的核心在于计算信息熵,信息熵反映了一个信息的紊乱程度,体现了信息的可靠性
  • 1

insert image description here

Specific steps

Step 1: Positive processing

将所以评价指标转换为极大型,目的是为了求出概率矩阵
  • 1
  • Converting Tiny to Extra Large
    Extremely small means the smaller the evaluation index, the better
    insert image description here
  • The code is as follows: Note that the matrix X can be a column vector
function[res]=Min2Max(X)
    res=max(X)-X;
end
  • 1
  • 2
  • 3

  • Converting Intermediate to Extra Large

    The intermediate type means that the closer the evaluation index is to the optimal value, the better, where the optimal value is given
    insert image description here

  • code show as below

function[res]=Mid2Max(X,best)
     M=max(abs(X-best));
     res=1-abs(X-best)/M;
end
  • 1
  • 2
  • 3
  • 4

  • Convert interval to very large
    Interval type means that the evaluation index is best within the interval and poor outside the interval
    insert image description here
  • code show as below
function[res]=interval2Max(X,a,b)
    M=max(a-min(X),max(X)-b);
    for i=1:size(X)
        if X(i)>=a&&X(i)<=b
            X(i)=1;
        elseif X(i)<a
            X(i)=1-(a-X(i))/M;
        else
            X(i)=1-(X(i)-b)/M;
        end
    end
    res=X;
end
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

Step 2 Standardization

标准化是将每一列的每一个元素除以每一列的元素平方的求和
  • 1

The formula is as follows:
insert image description here

Probability Matrix

如果说正向化创造了发生好事的样本数,标准化就是样本数除以样本空间得到概率
  • 1

insert image description here

Step 3: Use information entropy to calculate the weight set

注意信息熵的计算公式里有对数,所以应该适当修改概率矩阵值为0的项
这个公式本质上也是对每一列中所有元素按照公式求和,最后除以ln n归一化处理
  • 1
  • 2

insert image description here

Main code

%% 读取数据
X=xlsread('blind date.xlsx');
disp("成功读取!")
%% 正向化
disp("现在进行正向化操作,请按照提示操作")
vec_col=input("请输入需要正向化的列数,以数组的形式输入n");
for i=1:size(vec_col,2)%1是行数2是列数
flag = input(['第' num2str(vec_col(i)) '列是哪类数据(【1】:极小型 【2】:中间型 【3】:区间型),请输入序号:n']);
    if flag==1
        X(:,vec_col(i))=Min2Max(X(:,vec_col(i)));
    elseif flag==2
        best=input("请你传入最佳值n");
        X(:,vec_col(i))=Mid2Max(X(:,vec_col(i)),best);
    else
        arr=input("请你输入区间的左右端点,以数组的形式n");
        X(:,vec_col(i))=Interval2Max(X(:,vec_col(i)),arr(1),arr(2));
    end
end
disp("正向化完成!");

%% 标准化
[n,m]=size(X);
Square_X=X.*X;
Sum_X=sum(Square_X).^0.5;
Stand_X=X./repmat(Sum_X,n,1);
disp("标准化完成!")
%% 概率矩阵P
P=Stand_X./repmat(sum(Stand_X),n,1);
for i=1:n
    for j=1:m
        if P(i,j)==0
            P(i,j)=0.000001
        end
    end
end
H=sum(-P.*log(P));
e=H./log(n);
d=1-e;
d=d./sum(d);
disp("计算完成,下面是正向矩阵、标准矩阵和计算得出的权重矩阵");
disp(X);
disp(Stand_X);
disp(d);```

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44