public void normalize() {
final double[] mean = new double[this.numOfDimensions()];
for (int col = 0; col < numOfDimensions(); col++) {
double currentSum = 0.0;
for (int row = 0; row < this.size(); row++)
currentSum += this.getMeasurement(row, col);
mean[col] = currentSum / this.size();
}
final double[] stdDev = new double[numOfDimensions()];
for (int col = 0; col < numOfDimensions(); col++) {
double variance = 0.0;
for (int row = 0; row < this.size(); row++)
variance += Math.abs(getMeasurement(row, col) - mean[col]);
stdDev[col] = variance / this.size();
}
for (int row = 0; row < this.size(); row++) {
for (int col = 0; col < numOfDimensions(); col++) {
if (stdDev[col] == 0.0)
setMeasurement(row, col, 0.0);
else
setMeasurement(row, col, (getMeasurement(row, col) - mean[col]) / stdDev[col]);
}
}
}