权重计算⽅法⼆:熵权法(EWM)
⽬录
1.原理介绍
熵是对不确定信息的度量,熵与信息量成反⽐,熵值越⼩越好。熵值越⼩,信息量越⼤,权重越⼤。
前⽂所讲的层次分析法是⼀种具有很强主观性的赋权⽅法,⽽熵权法则是⼀种客观赋权法,即可以通过数据本⾝计算出权重。
2.基本步骤
3.步骤详解
3.1 数据归⼀化(标准化)
由于各项指标计量单位不统⼀,因此在计算综合权重前要先对其进⾏归⼀化处理,即把指标的绝对值转化为相对值。
对于正向指标:
对于负向指标:
其中系数0.998和0.002的⽬的是为了使  的值⼤于0,防⽌在后续计算时出现的情况。这⾥的0.998可以更改成任意更接近于1的数,如:0.999,0.997等。
3.2 计算第j项指标下第i个⽅案的指标值⽐重
,且
3.3 计算第j项指标的信息熵值
,其中
3.4 计算各指标权重
4.案例分析
4.1 题⽬简介
已知判断某⼀⽔域⽔质情况的好坏时可以通过x1-x9共9种指标来评判,现有A-K共11条河流的指标测量情况,请以此判断各河流⽔质的优良
河流x1x2x3x4x5x6x7x8x9
A886317505349642432
B7512431453311842
C794873624348727698
D7395934204654459
E36705351006742543
F4046926068192768
G20783598837035581
H6729383322734775
I383028724620504274
J952520421354565482
K40322714225968153 4.2 标准化后数据
河流x1x2x3x4x5x6x7x8x9
A0.9248530.6782550.1863330.5137470.4788510.6905310.8793890.2792210.338948 B0.7518670.020.020.4402110.0314710.7529060.4219720.2014550.441835 C0.8050930.5190.8073110.6398110.3641380.6749380.9902780.953195  1.018
D0.725253  1.0180.0976220.3456630.1002990.643750.7407780.020.616742 E0.2329070.7525740.5855330.041011  1.0180.02  1.0180.2921820.452124 F0.2861330.497766  1.0180.61880.650920.2227190.020.9531950.092021 G0.020.8375110.385933  1.0180.822989  1.0180.4774170.7198960.02
J  1.0180.2748090.21960.4297050.020.76850.76850.6680520.853381 K0.2861330.3491280.29722
20.1355580.1232410.8464690.075444  1.0180.55501 4.3 计算第j项指标下第i个⽅案的指标值⽐重
河流x1x2x3x4x5x6x7x8x9
A0.1553030.1212860.0428840.1038430.1127660.1109540.1439030.0450720.057057 B0.1262540.0035760.0046030.0889790.0074110.1209760.0690520.0325190.074377 C0.1351920.0928080.1857990.1293230.0857520.1084480.1620490.1538640.171366 D0.1217850.1820390.0224670.0698680.023620.1034370.1212210.0032280.10382 E0.039110.1345750.1347580.0082890.2397320.0032140.1665860.0471640.076109 F0.0480480.0890110.2342890.1250770.1532870.0357860.0032730.1538640.01549 G0.0033580.1497640.0888210.2057660.1938080.1635710.0781250.1162050.003367 H0.1083790.0567350.0964770.0040430.0560360.0558310.0055410.0931910.131531 I0.0435790.0586340.0709570.1505570.0938560.0382920.1121480.0827310.129799 J0.1709440.0491410.050540.0868550.004710.1234820.1257570.1078370.143655 K0.0480480.0624310.0684050.02740.0290220.136010.0123460.1643250.093428 4.4 计算第j项指标的信息熵值
x1x2x3x4x5x6x7x8x9
值0.9151320.9285910.8885450.8941660.8511470.927680.8840520.9191450.919939 4.5  计算各指标权重
x1x2x3x4x5x6x7x8x9
重0.097370.0819280.1278740.1214240.170780.0829740.1330280.0927660.091855 4.6 计算得分
河流x1x2x3x4x5x6x7x8x9得分
A88631750534964243248.77173 B751243145331184229.30177 C79487362434872769865.44425 D739593420465445940.37694 E3670535100674254350.31363
H672938332273477533.47667 I38302872462050427445.34118 J95252042135456548245.64744 K4032271422596815333.50219由以上得分可得河流⽔质情况由好到差依次为C>G>E>A>F>J>I>D>K>H>B
5.代码实现
5.1 代码(Java)
package EWM;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
ad.biff.BiffException;
import jxl.write.WriteException;
public class ewm {
//private String filepath;//⽂件路径
private double[][] orig; //原始矩阵
private double[][] uniform;//归⼀化后的矩阵
int rows,cols;//存储Excel的⾏和列数
Scanner input = new Scanner(System.in);
//矩阵每列最⼤值
public double[] Max(double[][] m) {
double max[] = new double[m[0].length];
for(int j=0;j < m[0].length;j++) {
max[j] = m[0][j];
for(int i=0;i < m.length;i++) {
if(m[i][j] >= max[j]) {
max[j] = m[i][j];
}
}
}
return max;
}
//矩阵每列最⼩值
public double[] Min(double[][] m) {
double min[] = new double[m[0].length];
for(int j=0;j < m[0].length;j++) {
min[j] = m[0][j];
for(int i=0;i < m.length;i++) {
if(m[i][j] <= min[j]) {
min[j] = m[i][j];
}
}
public void matrixoutput(double[][] x) {
for(int i=0;i<x.length;i++) {
for(int j=0;j<x[0].length;j++) {
System.out.print(x[i][j]+"  ");
}
System.out.println();
nextint()方法
}
}
//读取数据
public double[][] read(String filepath) throws IOException, BiffException,WriteException {
//创建输⼊流
InputStream stream = new FileInputStream(filepath);
//获取Excel⽂件对象
Workbook  rwb = Workbook(stream);
//获取⽂件的指定⼯作表默认的第⼀个
Sheet sheet = Sheet("Sheet1");
rows = Rows();
cols = Columns();
orig = new double[rows][cols];
uniform = new double[rows][cols];
//row为⾏
for(int i=0;i&Rows();i++) {
for(int j=0;j&Columns();j++) {
String[] str = new Columns()];
Cell cell = null;
cell = Cell(j,i);
str[j] = Contents();
orig[i][j] = Double.valueOf(str[j]);
//uniform[i][j] = Double.valueOf(str[j]);
}
}
return orig;
}
//数据归⼀化
public double[][] uniform(double[][] x) {
List<Integer> neg = new ArrayList<Integer>();//存储逆向指标所在列
for(int i=0;i<x.length;i++) {
for(int j=0;j<x[0].length;j++) {
uniform[i][j] = 0.998*(x[i][j] - Min(x)[j])/(Max(x)[j] - Min(x)[j]) + 0.002;
}
}
System.out.println("数据中是否有逆向指标?是:1,否:2");
int a = Int();
if(a == 1) {
System.out.println("输⼊逆向指标所在列(以“/”结尾):");
while(!input.hasNext("/")) {
neg.add(Integer.Int()));
}
for(int i=0;i<x.length;i++) {
for(int j=0;j<neg.size();j++) {
uniform[i][(j)] = 0.998*(Max(x)[(j)] - x[i][(j)])/(Max(x)[(j)] - Min(x)[(j)]) + 0.002;    }
}
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。