Here you can find the source of normData(double[] data)
Parameter | Description |
---|---|
data | the data. |
public static double[] normData(double[] data)
//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; } }