rsvd_align | R Documentation |
Singular value decomposition is specified up to the sign (+/-) of the singular vectors. This algorithm attempts to align the singular vectors with the majority of vectors of the input matrix.
svd_align(x, r = NA)
x |
A data matrix. |
r |
An integer; number of columns to include as a reduced rank SVD solution. Defaults to full rank. |
svd_flip
Aligned svd
Bro, R., Acar, E., & Kolda, T. G. (2008). Resolving the sign ambiguity in the singular value decomposition. Journal of Chemometrics: A Journal of the Chemometrics Society, 22(2), 135-140.
# Generate data
x <- cbind(runif(10, -0.5, 2), runif(10, -0.5, 2))
svd_flip <- svd_align(x)
# Extract components of svd and plot
U <- svd_flip$u
Sigma <- svd_flip$d
VT <- t(svd_flip$v)
# Plot data
plot(0, 0, xlim=c(-2,2), ylim=c(-2,2), type="n")
for (i in 1:dim(x)[1]){
arrows(0, 0, x[i,1], x[i,2], lwd=2)
}
arrows(0, 0, VT[1, 1], VT[1, 2], col='red')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.