Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Transform data such that its covariance matrix is the identity matrix
ResourceFunction["WhiteningTransform"][data] whitens data such that its covariance matrix is the identity matrix. |
Show some original data:
In[1]:= |
Out[2]= |
Apply the whitening transform and show the result:
In[3]:= |
Out[4]= |
Verify that the covariance matrix is an identity matrix (up to small numerical errors):
In[5]:= |
Out[5]= |
Data can also be in higher dimensions:
In[6]:= |
Out[7]= |
Apply the transform:
In[8]:= |
Out[9]= |
Verify that the covariance matrix is the identity matrix up to numerical error:
In[10]:= |
Out[10]= |
Use the default method and the "SVD" method and check how far the covariance matrices deviate from the identity matrix:
In[11]:= |
Out[14]= |
Create some 6 dimensional correlated data and visualize it:
In[15]:= |
Out[16]= |
Show the plots of 2D projections:
In[17]:= |
Out[17]= |
Whiten the data and visualize the output to verify that all off-diagonal plots are "sphered" and the diagonals are on a line:
In[18]:= |
Out[19]= |
Verify that the covariance matrix is the identity matrix:
In[20]:= |
Out[20]= |
This work is licensed under a Creative Commons Attribution 4.0 International License