Java Array Normalize normalizeArray(double[] hist)

Here you can find the source of normalizeArray(double[] hist)

Description

normalize Array

License

Open Source License

Declaration

public static double[] normalizeArray(double[] hist) 

Method Source Code

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

public class Main {
    public static double[] normalizeArray(double[] hist) {
        double sum = 0.0;
        for (int i = 0; i < hist.length; i++) {
            sum += hist[i];/*  ww w.j  a v a 2  s.  c o  m*/
        }
        if (sum > 0.0d) {
            for (int i = 0; i < hist.length; i++) {
                hist[i] = hist[i] / sum;
            }
        }
        return hist;
    }
}

Related

  1. normalize01(float[] array)
  2. normalize2(double[] x)
  3. normalize3(float[] result, float[] a)
  4. normalizeAndInvertValues(double[] values, double maxValue, double minValue)
  5. normalizeArray(double[] array)
  6. normalizeArrays(int normalizeToLength, String[]... arraysToNormalize)
  7. normalizeCharacterData(char[] ch, int start, int length)
  8. normalizeComplexVectorsToUnitVectors(float[] complex)
  9. normalizeComponentsOverwrite(float[][][][] in)