Here you can find the source of normalize(double[] ar)
Parameter | Description |
---|---|
ar | Input array |
public static double[] normalize(double[] ar)
//package com.java2s; public class Main { /** Returns a new array which has the numbers in the input array * L1-normalized./* www . ja v a2 s. co m*/ * * @param ar Input array * @return New array that has L1 normalized form of input array */ public static double[] normalize(double[] ar) { double[] ar2 = new double[ar.length]; double total = 0.0; for (double d : ar) { total += d; } for (int i = 0; i < ar.length; i++) { ar2[i] = ar[i] / total; } return ar2; } }