java中,归一化list里面的数据
/** * 归一化 * @param listInt * @return */ public static List<Double> normalListInteger(List<Integer> listInt){ List<Double> list_d = new ArrayList<Double>(); int maxValue = listInt.get(0); int minValue = listInt.get(0); for(int k = 0;k<listInt.size();k++) { int indexValue = listInt.get(k); if(indexValue<minValue) { minValue = indexValue; } if(indexValue>maxValue) { maxValue = indexValue; } } for(int k = 0;k<listInt.size();k++) { int indexValue = listInt.get(k); //x = (x - Min) / (Max - Min); double indexDValue = (double)(indexValue-minValue)/(double)(maxValue-minValue); list_d.add(indexDValue); } return list_d; }
########################