赞
踩
目录
熵是对不确定信息的度量,熵与信息量成反比,熵值越小越好。熵值越小,信息量越大,权重越大。
前文所讲的层次分析法是一种具有很强主观性的赋权方法,而熵权法则是一种客观赋权法,即可以通过数据本身计算出权重。
由于各项指标计量单位不统一,因此在计算综合权重前要先对其进行归一化处理,即把指标的绝对值转化为相对值。
对于正向指标:
对于负向指标:
其中系数0.998和0.002的目的是为了使 的值大于0,防止在后续计算时出现的情况。这里的0.998可以更改成任意更接近于1的数,如:0.999,0.997等。
,且
,其中
已知判断某一水域水质情况的好坏时可以通过x1-x9共9种指标来评判,现有A-K共11条河流的指标测量情况,请以此判断各河流水质的优良
河流 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 |
A | 88 | 63 | 17 | 50 | 53 | 49 | 64 | 24 | 32 |
B | 75 | 1 | 2 | 43 | 14 | 53 | 31 | 18 | 42 |
C | 79 | 48 | 73 | 62 | 43 | 48 | 72 | 76 | 98 |
D | 73 | 95 | 9 | 34 | 20 | 46 | 54 | 4 | 59 |
E | 36 | 70 | 53 | 5 | 100 | 6 | 74 | 25 | 43 |
F | 40 | 46 | 92 | 60 | 68 | 19 | 2 | 76 | 8 |
G | 20 | 78 | 35 | 98 | 83 | 70 | 35 | 58 | 1 |
H | 67 | 29 | 38 | 3 | 32 | 27 | 3 | 47 | 75 |
I | 38 | 30 | 28 | 72 | 46 | 20 | 50 | 42 | 74 |
J | 95 | 25 | 20 | 42 | 13 | 54 | 56 | 54 | 82 |
K | 40 | 32 | 27 | 14 | 22 | 59 | 6 | 81 | 53 |
河流 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 |
A | 0.924853 | 0.678255 | 0.186333 | 0.513747 | 0.478851 | 0.690531 | 0.879389 | 0.279221 | 0.338948 |
B | 0.751867 | 0.02 | 0.02 | 0.440211 | 0.031471 | 0.752906 | 0.421972 | 0.201455 | 0.441835 |
C | 0.805093 | 0.519 | 0.807311 | 0.639811 | 0.364138 | 0.674938 | 0.990278 | 0.953195 | 1.018 |
D | 0.725253 | 1.018 | 0.097622 | 0.345663 | 0.100299 | 0.64375 | 0.740778 | 0.02 | 0.616742 |
E | 0.232907 | 0.752574 | 0.585533 | 0.041011 | 1.018 | 0.02 | 1.018 | 0.292182 | 0.452124 |
F | 0.286133 | 0.497766 | 1.018 | 0.6188 | 0.65092 | 0.222719 | 0.02 | 0.953195 | 0.092021 |
G | 0.02 | 0.837511 | 0.385933 | 1.018 | 0.822989 | 1.018 | 0.477417 | 0.719896 | 0.02 |
H | 0.645413 | 0.317277 | 0.4192 | 0.02 | 0.237954 | 0.347469 | 0.033861 | 0.577325 | 0.781361 |
I | 0.25952 | 0.327894 | 0.308311 | 0.744863 | 0.398552 | 0.238312 | 0.685333 | 0.512519 | 0.771072 |
J | 1.018 | 0.274809 | 0.2196 | 0.429705 | 0.02 | 0.7685 | 0.7685 | 0.668052 | 0.853381 |
K | 0.286133 | 0.349128 | 0.297222 | 0.135558 | 0.123241 | 0.846469 | 0.075444 | 1.018 | 0.55501 |
河流 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 |
A | 0.155303 | 0.121286 | 0.042884 | 0.103843 | 0.112766 | 0.110954 | 0.143903 | 0.045072 | 0.057057 |
B | 0.126254 | 0.003576 | 0.004603 | 0.088979 | 0.007411 | 0.120976 | 0.069052 | 0.032519 | 0.074377 |
C | 0.135192 | 0.092808 | 0.185799 | 0.129323 | 0.085752 | 0.108448 | 0.162049 | 0.153864 | 0.171366 |
D | 0.121785 | 0.182039 | 0.022467 | 0.069868 | 0.02362 | 0.103437 | 0.121221 | 0.003228 | 0.10382 |
E | 0.03911 | 0.134575 | 0.134758 | 0.008289 | 0.239732 | 0.003214 | 0.166586 | 0.047164 | 0.076109 |
F | 0.048048 | 0.089011 | 0.234289 | 0.125077 | 0.153287 | 0.035786 | 0.003273 | 0.153864 | 0.01549 |
G | 0.003358 | 0.149764 | 0.088821 | 0.205766 | 0.193808 | 0.163571 | 0.078125 | 0.116205 | 0.003367 |
H | 0.108379 | 0.056735 | 0.096477 | 0.004043 | 0.056036 | 0.055831 | 0.005541 | 0.093191 | 0.131531 |
I | 0.043579 | 0.058634 | 0.070957 | 0.150557 | 0.093856 | 0.038292 | 0.112148 | 0.082731 | 0.129799 |
J | 0.170944 | 0.049141 | 0.05054 | 0.086855 | 0.00471 | 0.123482 | 0.125757 | 0.107837 | 0.143655 |
K | 0.048048 | 0.062431 | 0.068405 | 0.0274 | 0.029022 | 0.13601 | 0.012346 | 0.164325 | 0.093428 |
指标 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 |
信息熵值 | 0.915132 | 0.928591 | 0.888545 | 0.894166 | 0.851147 | 0.92768 | 0.884052 | 0.919145 | 0.919939 |
指标 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 |
权重 | 0.09737 | 0.081928 | 0.127874 | 0.121424 | 0.17078 | 0.082974 | 0.133028 | 0.092766 | 0.091855 |
河流 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | 得分 |
A | 88 | 63 | 17 | 50 | 53 | 49 | 64 | 24 | 32 | 48.77173 |
B | 75 | 1 | 2 | 43 | 14 | 53 | 31 | 18 | 42 | 29.30177 |
C | 79 | 48 | 73 | 62 | 43 | 48 | 72 | 76 | 98 | 65.44425 |
D | 73 | 95 | 9 | 34 | 20 | 46 | 54 | 4 | 59 | 40.37694 |
E | 36 | 70 | 53 | 5 | 100 | 6 | 74 | 25 | 43 | 50.31363 |
F | 40 | 46 | 92 | 60 | 68 | 19 | 2 | 76 | 8 | 47.95403 |
G | 20 | 78 | 35 | 98 | 83 | 70 | 35 | 58 | 1 | 54.82417 |
H | 67 | 29 | 38 | 3 | 32 | 27 | 3 | 47 | 75 | 33.47667 |
I | 38 | 30 | 28 | 72 | 46 | 20 | 50 | 42 | 74 | 45.34118 |
J | 95 | 25 | 20 | 42 | 13 | 54 | 56 | 54 | 82 | 45.64744 |
K | 40 | 32 | 27 | 14 | 22 | 59 | 6 | 81 | 53 | 33.50219 |
由以上得分可得河流水质情况由好到差依次为C>G>E>A>F>J>I>D>K>H>B
- 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;
- import jxl.read.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];
- }
- }
- }
- return min;
- }
-
- 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();
- }
- }
-
- //读取数据
- public double[][] read(String filepath) throws IOException, BiffException,WriteException {
- //创建输入流
- InputStream stream = new FileInputStream(filepath);
- //获取Excel文件对象
- Workbook rwb = Workbook.getWorkbook(stream);
- //获取文件的指定工作表 默认的第一个
- Sheet sheet = rwb.getSheet("Sheet1");
- rows = sheet.getRows();
- cols = sheet.getColumns();
- orig = new double[rows][cols];
- uniform = new double[rows][cols];
- //row为行
- for(int i=0;i<sheet.getRows();i++) {
- for(int j=0;j<sheet.getColumns();j++) {
- String[] str = new String[sheet.getColumns()];
- Cell cell = null;
- cell = sheet.getCell(j,i);
- str[j] = cell.getContents();
- 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 = input.nextInt();
- if(a == 1) {
- System.out.println("输入逆向指标所在列(以“/”结尾):");
- while(!input.hasNext("/")) {
- neg.add(Integer.valueOf(input.nextInt()));
- }
- for(int i=0;i<x.length;i++) {
- for(int j=0;j<neg.size();j++) {
- uniform[i][neg.get(j)] = 0.998*(Max(x)[neg.get(j)] - x[i][neg.get(j)])/(Max(x)[neg.get(j)] - Min(x)[neg.get(j)]) + 0.002;
- }
- }
- }
-
-
-
- return uniform;
- }
-
- //确定第j个指标在第i个项目的比重Pij
- public double[][] Pig(double[][] m){
- double[][] p = new double[m.length][m[0].length];
- double[] sum = new double[m[0].length];
- //每列之和
- for(int j=0;j<m[0].length;j++) {
- sum[j] = 0;
- for(int i=0;i<m.length;i++) {
- sum[j] += m[i][j];
- }
- }
-
- for(int j=0;j<m[0].length;j++) {
- for(int i=0;i<m.length;i++) {
- p[i][j] = m[i][j]/sum[j];
- }
- }
-
- return p;
- }
-
- //计算第j项指标的信息熵值eij
- public double[] Eij(double[][] p) {
- double[] e = new double[p[0].length];
- double k = 1/Math.log(p.length);
- double[] sum = new double[p[0].length];
-
- for(int j=0;j<p[0].length;j++) {
- sum[j] = 0;
- for(int i=0;i<p.length;i++) {
- sum[j] += p[i][j]*Math.log(p[i][j]);
- }
- }
-
- for(int j=0;j<p[0].length;j++) {
- e[j] = -1*k*sum[j];
- }
-
- return e;
- }
-
- //计算各指标的权值
- public double[] weight(double[] e) {
- double[] w = new double[e.length];
- double sum = 0;
-
- for(int j=0;j<e.length;j++) {
- sum += (1-e[j]);
- }
-
- for(int j=0;j<e.length;j++) {
- w[j] = (1-e[j])/sum;
- }
-
- return w;
- }
- }
- package EWM;
-
- import java.io.IOException;
-
- import jxl.read.biff.BiffException;
- import jxl.write.WriteException;
-
- public class ewmmain {
- public static void main(String args[]) throws BiffException, WriteException, IOException {
- ewm ewm = new ewm();
-
- double[][] a = ewm.read("ewm.xls");
- //输出原始矩阵,行为评价对象,列为评价指标
- System.out.println("原始矩阵为:");
- ewm.matrixoutput(a);
-
- double[][] x = ewm.uniform(a);
- System.out.println("标准化(归一化)矩阵:");
- ewm.matrixoutput(x);
-
- double[][] p = ewm.Pig(x);
- System.out.println("确定第j个指标在第i个项目的比重Pij矩阵:");
- ewm.matrixoutput(p);
-
- double[] e = ewm.Eij(p);
- System.out.println("确定第j个指标的信息熵值:");
- for(int i=0;i<e.length;i++) {
- System.out.print(e[i]+" ");
- }
- System.out.println();
-
- double[] w = ewm.weight(e);
- System.out.println("确定各指标的权值:");
- for(int i=0;i<w.length;i++) {
- System.out.print(w[i]+" ");
- }
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。