Created
June 27, 2022 14:56
-
-
Save alexpghayes/6fa2d111508d2a0c774eb29092ed0f63 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rotate Y to align it to X | |
mypro <- function(X, Y) { | |
XY <- crossprod(X, Y) | |
s <- svd(XY) | |
rotation <- s$v %*% t(s$u) | |
Yrot <- Y %*% rotation | |
diff <- X - Yrot | |
sum_squared_error <- sum(diff^2) | |
list( | |
s = s, | |
rotation = rotation, | |
Yrot = Yrot, | |
diff = diff, | |
sum_squared_error = sum_squared_error | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment