Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { /** * scales all data between -1 and 1 * * @param data the data to scale * @return scaled data */ public static double[] scaleToOne(double[] data) { double max = Double.MIN_VALUE; for (double d : data) { if (d > max) max = d; } for (int i = 0; i < data.length; i++) data[i] /= max; return data; } }