Here you can find the source of normalize(double[] array)
public static double[] normalize(double[] array)
//package com.java2s; //License from project: Open Source License public class Main { public static float[] normalize(float[] values) { float sum = sum(values); for (int i = 0; i < values.length; i++) { values[i] = values[i] / sum; }//w w w. ja v a 2 s . c o m return values; } public static double[] normalize(double[] array) { double sum = sum(array); for (int i = 0; i < array.length; i++) { array[i] = array[i] / sum; } return array; } public static double sum(double[] items) { double total = 0; for (double item : items) { total += item; } return total; } public static long sum(long[] items) { long total = 0; for (long item : items) { total += item; } return total; } public static float sum(float[] items) { float total = 0; for (float item : items) { total += item; } return total; } public static long sum(int[] items) { long total = 0; for (int item : items) { total += item; } return total; } }