Here you can find the source of normalize(double arr[])
public static double[] normalize(double arr[])
//package com.java2s; //License from project: Open Source License public class Main { public static double[] normalize(double arr[]) { double sum = fsum(arr); for (int i = 0; i < arr.length; i++) { arr[i] = arr[i] / sum;/*from www . ja v a2 s . co m*/ } return arr; } public static double fsum(double arr[]) { double sum = 0.0; for (double val : arr) { sum += val; } return sum; } }