Java Array Normalize normalizeVector(double[] input)

Here you can find the source of normalizeVector(double[] input)

Description

This method normalizes the input vector to 1.

License

Open Source License

Declaration

public static void normalizeVector(double[] input) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*from  w w  w.j  a  v  a  2  s .c om*/
     * This method normalizes the input vector to 1.
     */
    public static void normalizeVector(double[] input) {
        int index = 0;
        double sum = 0;
        while (index < input.length) {
            sum += input[index];
            index++;
        }
        index = 0;
        while (index < input.length) {
            input[index] = input[index] / sum;
            index++;
        }

    }
}

Related

  1. normalizeToLogProbs(double[] x)
  2. normalizeToOne(double[] doubles)
  3. normalizeToSumUpTo(double[] x, double sumUp)
  4. normalizeTrimmedText(char[] ch)
  5. NormalizeVec2D(double[] vec)
  6. normalizeVector(Double[] vector)
  7. normalizeVector(final double[] v)
  8. normalizeVector(float[] samples)
  9. normalizeVectorMax(double[] input)