stat/mds: ~0 Eigenvalues returned by TorgersonScaling are problematic
Created by: kortschak
What are you trying to do?
Run mds.TorgersonScaling
on the R eurodist sample dataset and get reasonable agreement with the R output.
What did you do?
Run the code at https://play.golang.org/p/z7kPeRXDuAI both with -tags noasm
and without tags.
What did you expect to happen?
Output of Eigenvalue similar to the output given by R.
$eig
[1] 1.953838e+07 1.185656e+07 1.528844e+06 1.118742e+06 7.893472e+05
[6] 5.816552e+05 2.623192e+05 1.925976e+05 1.450845e+05 1.079673e+05
[11] 5.139484e+04 -3.259629e-09 -9.496124e+03 -5.305820e+04 -1.322166e+05
[16] -2.573360e+05 -3.326719e+05 -5.162523e+05 -9.191491e+05 -1.006504e+06
[21] -2.251844e+06
What actually happened?
Two different values for Eigenvalue 12, both of which are greater than 0 where the R-returned value is less than 0.
~ $ go run main.go
1.953838e+07 1.185656e+07 1.528844e+06 1.118742e+06 7.893472e+05
5.816552e+05 2.623192e+05 1.925976e+05 1.450845e+05 1.079673e+05
5.139484e+04 7.598369e-11 -9.496124e+03 -5.305820e+04 -1.322166e+05
-2.573360e+05 -3.326719e+05 -5.162523e+05 -9.191491e+05 -1.006504e+06
-2.251844e+06
~ $ go run -tags noasm main.go
1.953838e+07 1.185656e+07 1.528844e+06 1.118742e+06 7.893472e+05
5.816552e+05 2.623192e+05 1.925976e+05 1.450845e+05 1.079673e+05
5.139484e+04 1.348610e-10 -9.496124e+03 -5.305820e+04 -1.322166e+05
-2.573360e+05 -3.326719e+05 -5.162523e+05 -9.191491e+05 -1.006504e+06
-2.251844e+06
This is pretty clearly an issue with small values, but there is also an issue of difference between the ASM and pure-Go implementations.
While the issue appears trivial, with MDS using Torgerson Scaling the choice of k, the maximum dimension of the space which the data are to be can represented in, is based on the number of Eigenvalues above zero, so in this case we estimate k one greater than does R (R's result looks correct when the coordinates are examined).
What version of Go and Gonum are you using?
go version go1.11.4 linux/amd64 29fdfdf1fb2efa00da0e381574856bf5b4c399c1
Does this issue reproduce with the current master?
Yes.
/cc @vladimir-ch @btracey @Kunde21