MDS missing sqrt?
Hello,
I wonder if the MDS method is missing an sqrt
of the eigenvalues for constructing the points cloud.
Or if there is a developing decision behind not using it.
I am not a specialist in the method, so I am just curious,
In here the code is:
// return X = U+ * S^(1/2)
...
X.scaleCols(npos, eigen_positive);
The comment also states S^(1/2)
.
The current code with the atlas_guyane_trnH_0.h5
and svd
gives for the first 2 points and 3 dimensions:
PC1 | PC2 | PC3 | ... |
---|---|---|---|
-48045.2 | -14850.0 | 931.0 | ... |
27599.7 | -9374.9 | -19550.5 | ... |
The distance of the first two points in the dataset is 136.5
. However, with these points, the distance is 49689.4
.
However, if we use the following patch:
diff --git a/include/diodon/methods/mds.hpp b/include/diodon/methods/mds.hpp
index f969011..e444c98 100644
--- a/include/diodon/methods/mds.hpp
+++ b/include/diodon/methods/mds.hpp
@@ -270,7 +270,11 @@ int mds(MATRIX &A, MATRIX &X, std::vector<typename MATRIX::value_type> &L,
if (isTimed) {
timeScale.tic();
}
- X.scaleCols(npos, eigen_positive);
+ std::vector<Real_t> sqrt_eigen_positive(eigen_positive.size());
+ for(std::size_t i=0; i < eigen_positive.size(); ++i){
+ sqrt_eigen_positive[i] = std::sqrt(eigen_positive[i]);
+ }
+ X.scaleCols(npos, sqrt_eigen_positive);
if (isTimed) {
timeScale.tac();
}
The new points are:
PC1 | PC2 | PC3 | ... |
---|---|---|---|
-70.0 | -23.0 | 1.5 | ... |
40.2 | -14.5 | -31.6 | ... |
which have a distance of 115.4
, near to the original 136.5
.
Moreover, if we use R's function cmdscale with the dataset, the result is:
PC1 | PC2 | PC3 | ... |
---|---|---|---|
-70.0 | -23.0 | 1.5 | ... |
40.2 | -14.5 | -31.6 | ... |
The same as adding the sqrt
.
The cmdscale
's implementation also has a sqrt
.
I noticed this sqrt here after having eigen_positive
, but I now sure if its intention is the same.
Thanks