// Return the sum of three discrepancy measures.
return Math.abs(f.minValue()) + Math.abs(f.maxValue() - 6) + Math.abs(f.norm(1) - 6);
}
});
// Verify all errors are nearly zero.
assertEquals(0, columnNorms.norm(1) / columnNorms.size(), 0.1);
// Verify that the centroids are a permutation of the original ones.
SingularValueDecomposition svd = new SingularValueDecomposition(x);
Vector s = svd.getS().viewDiagonal().assign(Functions.div(6));
assertEquals(5, s.getLengthSquared(), 0.05);