Here you can find the source of normalize(double[] bins)
public static double[] normalize(double[] bins)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from ww w.j a v a 2 s . c o m*/ * Scales bins to 0-1 scale. * */ public static double[] normalize(double[] bins) { double sum = 0; for (int i = 0; i < bins.length; i++) { sum += bins[i]; } double[] normbins = new double[bins.length]; for (int i = 0; i < bins.length; i++) { if (sum == 0) normbins[i] = 0; else normbins[i] = bins[i] / sum; } return (normbins); } }