Here you can find the source of normalize(double[] data)
public static double[] normalize(double[] data)
//package com.java2s; //License from project: Open Source License public class Main { /**/* w w w . ja v a2 s. c o m*/ * normalize histogram, sum of all fractional counts = 1. * */ public static double[] normalize(double[] data) { double[] norm = new double[data.length]; double total_sum = 0.0; for (int i = 0; i < data.length; ++i) { total_sum += data[i]; } for (int i = 0; i < data.length; ++i) { norm[i] = data[i] / total_sum; } return norm; } }