View source: R/multiscaleSVDxpts.R
whiten_matrix | R Documentation |
This function performs matrix whitening on the input matrix 'X' using Singular Value Decomposition (SVD). Whitening transforms the input matrix into one where the covariance matrix is the identity matrix.
whiten_matrix(X)
X |
A numeric matrix to be whitened. The matrix should have observations as rows and features as columns. |
A list containing:
whitened_matrix |
The whitened matrix where the covariance matrix is the identity matrix. |
whitening_matrix |
The whitening transformation matrix used to whiten the input matrix. |
set.seed(123)
X <- matrix(rnorm(1000), nrow = 20, ncol = 50) # Example with p = 50 and n = 20
result <- whiten_matrix(X)
X_whitened <- result$whitened_matrix
whitening_matrix <- result$whitening_matrix
# Verify that the covariance matrix of the whitened matrix is close to identity
cov_X_whitened <- cov(X_whitened)
print(round(cov_X_whitened, 2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.