What is the fastest way to divide data by the covariance matrix?

1 view (last 30 days)
I am doing the following calculation:
X_adj = X * C^(-1/2);
where X is my data, and C is a covariance matrix. I need to do this repeatedly. Is there a faster way? Typical data size varies between 10x200 and 100x1000.

Answers (1)

Star Strider
Star Strider on 21 Jul 2015
I would see if using the sqrtm function and doing a regular matrix right division works:
X_adj = X/sqrtm(C);
  1 Comment
precuneus
precuneus on 21 Jul 2015
This is only 5% faster on my machine. I tried also the following (inlining the code):
[E,D] = eig(C);
X_adj = X*E*diag(read(diag(D).^-.5))*E';
which turned out to be 20% faster. Would be happy about other ideas.

Sign in to comment.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!