Based topsis and Entropy Law

. 1 %% X-data matrix
 2 %% number n data matrix rows i.e., the number of subjects evaluated
 . 3 %% m number of columns of the data matrix i.e., the number of economic indicators
 . 4 %% B multiplied by the entropy of the data matrix
 . 5 % D% + Dist_max and Maximum distance vector
 . 6 % D-% Dist_min distance vector and the minimum value
 . 7 %% E entropy listing
 . 8 %% D redundancy information entropy
 . 9 %% W weight table
 10 %% stand_S normalized matrix
 . 11 %% sorted_S accordance descending order of the data matrix
 12 is  
13 is %%   Step: copy the data to the work area, and the matrix is designated X-
 14  Clear; CLC
 15 jingjizhibiao.mat Load;
 16  
. 17 [n-, m] = size (X-);
 18 is DISP ([ ' total ' num2str (n-) ' regions, ' num2str (m) ' th Economic Indicators ' ]);
 . 19  
20 is  
21 is % % Step: entropy weight method
 22 %% calculated by the following indices j-th, the i-th sample index representing the proportion of P (i, j)
 23 is  for i = . 1 : n-
 24      for j = . 1 : m
 25          P (I, J) = X-(I, J) / SUM (X-(:, J));
 26 is      End
 27  End
 28 %%Calculating the j-th index entropy values E (j)
 29 K = . 1 / log (n-);
 30  for j = . 1 : m
 31 is      E (j) = - K * SUM (P (:, j) *. Log ( P (:, J)));
 32  End
 33 is D = ones ( . 1 , m) -e;% calculated entropy redundancy
 34 is W = D / SUM (D);%. seeking weights W
 35 DISP ( ' the final weight is; = W ' )
 36  W
 37 [ B = X. * repmat (W, n-, . 1 ); %% each metadata value is multiplied by the corresponding entropy indicator,
 38 is  
39 DISP ( ' added on entropy matrix = B ' );
 40  DISP (B);
 41 is 
42 is Clear ij of; %% release independent variable
 43 is % B% ./ repmat the Z = (SUM (B B. *) ^. 0.5 , n-, . 1 );
 44 is %% DISP ( ' normalized matrix = the Z ' )
 45 %% DISP (the Z)
 46 is  
47 %% from the third step calculates the maximum value and the minimum value of the distance, and calculates the score, (TOPSIS analysis)
 48  
49 Dist_max = SUM ([(B - repmat (max (B), n-, . 1 .)) ^ 2 ], 2 .) ^ 0.5 ;% D + and distance vector maximum
 50 Dist_min = SUM ([(B - repmat (min (B), n-, . 1 .)) ^ 2 ], 2 ) ^ 0.5;% D- and minimum distance vector
 51 is DISP ( ' D + is a ' )
 52 is  Dist_max
 53 is  
54 is DISP ( ' D - is a ' )
 55  Dist_min
 56 is  
57 is S = Dist_min ./ (Dist_max Dist_min +);% unnormalized score of
 58 DISP ( ' final score is: ' )
 59 stand_S = S / SUM (S)
 60 [sorted_S, index] = Sort (stand_S, ' the descend ' )

matlab

Guess you like

Origin www.cnblogs.com/shewhen/p/11965199.html
law