Here you can find the source of normalize(double[] values)
public static double[] normalize(double[] values)
//package com.java2s; //License from project: Open Source License public class Main { public static double[] normalize(double[] values) { double sum = 0; for (int i = 0; i < values.length; i++) { sum += (values[i] * values[i]); }/*from ww w.j a v a2 s . c o m*/ sum = Math.sqrt(sum); double[] newValues = new double[values.length]; for (int i = 0; i < newValues.length; i++) { newValues[i] = values[i] / sum; } return newValues; } }