Add tests for matrix scale consistency
karlrohe opened this issue · 0 comments
karlrohe commented
The scale of the output from vsp is messed up. ZBY' should be equal to UDV' (from the svds). However, it isn't even property scaled...
# devtools::install_github("RoheLab/fastRG")
library(fastRG)
library(vsp)
n = 1000
A = erdos_renyi(n, avg_deg = 20)+0
# first, without normalize
fa = vsp(A, normalize = F)
Ahat_svd = fa$U%*%diag(fa$d)%*%t(fa$V)
sum(Ahat_svd^2)
Ahat = fa$Z%*%fa$B%*%t(fa$Y)
sum(Ahat^2)
sum(Ahat^2)/n^2 # this fixes it!
fa = vsp(A, normalize = T)
Ahat_svd = fa$U%*%diag(fa$d)%*%t(fa$V)
sum(Ahat_svd^2)
Ahat = fa$Z%*%fa$B%*%t(fa$Y)
sum(Ahat^2)
sum(Ahat^2)/n # this does not fix it, nor does n^2