Here you can find the source of normalizeTo(float[] in, float normsum)
public static final float[] normalizeTo(float[] in, float normsum)
//package com.java2s; //License from project: Apache License public class Main { public static final float[] normalizeTo(float[] in, float normsum) { float sum = 0; float[] out = new float[in.length]; for (int i = 0; i < in.length; i++) { sum += in[i];/*from w w w .j a va2s . co m*/ } for (int i = 0; i < in.length; i++) { out[i] = normsum * in[i] / sum; } return out; } public static final double[] normalizeTo(double[] in, double normsum) { double sum = 0; double[] out = new double[in.length]; for (int i = 0; i < in.length; i++) { sum += in[i]; } for (int i = 0; i < in.length; i++) { out[i] = normsum * in[i] / sum; } return out; } }