whiten_matrix: Whitening Matrix

View source: R/multiscaleSVDxpts.R

whiten_matrixR Documentation

Whitening Matrix

Description

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.

Usage

whiten_matrix(X)

Arguments

X

A numeric matrix to be whitened. The matrix should have observations as rows and features as columns.

Value

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.

Examples

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))

stnava/ANTsR documentation built on April 13, 2025, 4:10 a.m.