Java Array Normalize normData(double[] data)

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

Description

\ingroup isti_utils_public_functions \brief Demeans data in-place.

License

Open Source License

Parameter

Parameter Description
data the data.

Declaration

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

Method Source Code

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

public class Main {
    /**/*from  w w  w. j a va2  s  .  c om*/
     * \ingroup isti_utils_public_functions \brief Demeans data in-place.
     * 
     * @param data
     *            the data.
     */
    public static double[] normData(double[] data) {
        double[] ret = new double[data.length];
        double sumData = 0.0;
        for (int i = 0; i < data.length; i++)
            sumData += data[i];
        final double meanData = sumData / data.length;
        for (int i = 0; i < data.length; i++)
            ret[i] = data[i] - meanData;
        return ret;
    }

    public static double[] normData(int[] data) {
        double[] ret = new double[data.length];
        double sumData = 0.0;
        for (int i = 0; i < data.length; i++)
            sumData += data[i];
        final double meanData = new Double(sumData) / data.length;
        for (int i = 0; i < data.length; i++)
            ret[i] = data[i] - meanData;
        return ret;
    }
}

Related

  1. normalizeVectors(float[][] vectors, boolean maxMin)
  2. normalizeVoxelDimensions(final double[] voxelDimensions)
  3. normalizeWith(double[] arr, double v)
  4. normalizeZscore(double[] x)
  5. normBySortedPointersInverse(double[] d, int[] pointers)
  6. normII(double[] b)
  7. normLat(double[] latLng)
  8. normLng(double[] latLng)
  9. normOf(float[] vector)