gusl: (Default)
[personal profile] gusl
My refactoring fastICA was performing better than fastICA itself (better agreement with R), so I went hunting for the difference.

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".

(no subject)

Date: 2007-03-02 12:25 am (UTC)
From: [identity profile] ekorber.livejournal.com
Haha, as I repeated to my students many times last summer... when coding in Java, if you didn't type the word new, NO new object will be created.

February 2020

S M T W T F S
      1
2345678
9101112131415
16171819202122
23242526272829

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags