Here you can find the source of normalize(double[] doubleArray)
static double[] normalize(double[] doubleArray)
//package com.java2s; //License from project: Open Source License import java.util.Arrays; public class Main { static double[] normalize(double[] doubleArray) { // Normalize a double array double arraySum = sum(doubleArray); double[] arrayNormalized = new double[doubleArray.length]; for (int i = 0; i < doubleArray.length; i++) { arrayNormalized[i] = doubleArray[i] / arraySum; }/*w w w . j a va 2 s . c o m*/ return arrayNormalized; } public static double sum(int[] intArray) { double[] doubleArray = Arrays.stream(intArray).asDoubleStream().toArray(); return sum(doubleArray); } public static double sum(double[] doubleArray) { // Sum the elements in a double array double arraySum = 0; for (double d : doubleArray) { arraySum += d; } return arraySum; } }