Skip to content

Instantly share code, notes, and snippets.

@thistleknot
Created December 7, 2021 01:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thistleknot/d8ea9064bb90564f3028d3f742973570 to your computer and use it in GitHub Desktop.
Save thistleknot/d8ea9064bb90564f3028d3f742973570 to your computer and use it in GitHub Desktop.
ZCA SVD in R
ZCA_svd <- function(x)
{
internal <- svd(x)
U = internal$u
#print(U)
#Vt = internal$v
Vt = t(internal$v)
#print(Vt)
s = internal$d
#U, s, Vt = np.linalg.svd(X, full_matrices=False)
# U and Vt are the singular matrices, and s contains the singular values.
# Since the rows of both U and Vt are orthonormal vectors, then U * Vt
# will be white
#dot(U,Vt)
X_white = U%*%Vt
#np$dot(U,Vt)
#
return(X_white)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment