lucky accidents
Mar. 1st, 2007 03:21 pmMy refactoring fastICA was performing better than fastICA itself (better agreement with R), so I went hunting for the difference.
This is my "buggy" code:
The "clone" is deceptive: essentially, resultMatrix is going to have the same pointers as inVectors... so changing entries in resultMatrix changes them in inVectors.
This is the correct way to clone:
I think there may be a mathematical reason why using the resultMatrix is superior to using inVectors, despite the FastICA implementation.
Another possibility is that the R implementation has the exact same bug as the one I introduced in my poorly-executed "cloning".
This is my "buggy" code:
DoubleMatrix2D resultMatrix = (DoubleMatrix2D) inVectors.clone();
The "clone" is deceptive: essentially, resultMatrix is going to have the same pointers as inVectors... so changing entries in resultMatrix changes them in inVectors.
This is the correct way to clone:
DoubleMatrix2D resultMatrix = new DenseDoubleMatrix2D(convert(inVectors));
I think there may be a mathematical reason why using the resultMatrix is superior to using inVectors, despite the FastICA implementation.
Another possibility is that the R implementation has the exact same bug as the one I introduced in my poorly-executed "cloning".