Java Array Normalize normalize(double[] data)

Here you can find the source of normalize(double[] data)

Description

normalize histogram, sum of all fractional counts = 1.

License

Open Source License

Declaration

public static double[] normalize(double[] data) 

Method Source Code

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

public class Main {
    /**/*  w w w . ja  v a2 s. c  o m*/
     * normalize histogram, sum of all fractional counts = 1.
     *
     */
    public static double[] normalize(double[] data) {

        double[] norm = new double[data.length];
        double total_sum = 0.0;

        for (int i = 0; i < data.length; ++i) {
            total_sum += data[i];
        }

        for (int i = 0; i < data.length; ++i) {
            norm[i] = data[i] / total_sum;
        }

        return norm;
    }
}

Related

  1. normalize(double[] array)
  2. normalize(double[] array)
  3. normalize(double[] array)
  4. normalize(double[] bins)
  5. normalize(double[] d)
  6. normalize(double[] data, double floor)
  7. normalize(double[] descriptor)
  8. normalize(double[] doubleArray)
  9. normalize(double[] doubles)