assertEquals(0d, mat.get(0, 6), 1e-4);
}
@Test
public void testFeatureNormalize() {
DoubleMatrix mat = new DenseDoubleMatrix(new double[][] { { 2, 5 },
{ 5, 1 }, { 7, 25 } });
Tuple3<DoubleMatrix, DoubleVector, DoubleVector> normal = MathUtils
.meanNormalizeColumns(mat);
DoubleVector mean = normal.getSecond();
assertSmallDiff(mean, new DenseDoubleVector(new double[] { 14d / 3d,
31d / 3d }));
DoubleVector stddev = normal.getThird();
assertSmallDiff(stddev, new DenseDoubleVector(new double[] { 2.0548046,
10.498677 }));
DoubleMatrix meanNormalizedMatrix = normal.getFirst();
DoubleMatrix matNormal = new DenseDoubleMatrix(new double[][] {
{ -1.2977713, -0.508 }, { 0.162221421, -0.889 }, { 1.135549, 1.397 } });
for (int i = 0; i < 3; i++) {
assertSmallDiff(meanNormalizedMatrix.getRowVector(i),
matNormal.getRowVector(i));
}
}