Here you can find the source of normalize(double[] in)
public static double[] normalize(double[] in)
//package com.java2s; //License from project: Open Source License public class Main { /**Complexity: O( 2 * N ) * /* w w w.j a v a 2 s . c om*/ * Should in contain only one unique number, this method return an array of 0's */ public static double[] normalize(double[] in) { double min = Double.POSITIVE_INFINITY, max = Double.NEGATIVE_INFINITY; //Find minimum and maximum value in the array for (double val : in) { if (val > max) max = val; if (val < min) min = val; } return normalize(in, min, max); } /**Complexity: O( N ) * * Should min == max, this method return an array of 0's */ public static double[] normalize(double[] in, double min, double max) { //Create normalized data double[] out = new double[in.length]; for (int i = 0; i < out.length; i++) { out[i] = normalize(in[i], min, max); } return out; } /**Complexity: O( 1 ) */ public static double normalize(double in, double min, double max) { return min == max ? 0 : (in - min) / (max - min); } }