Canonical Correlation Analysis, reversiblity

Hello everyone,
I have little problem with the function canoncorr(...).
If I've understood correctly, the function returns two values a and b respecting a.X = b.Y.
So, if if I do:
[a,b] = canoncorr(X,Y)
I should get the same as:
[b,a] = canoncorr(Y,X)
But for some reason, when I have large matrices (I've actually seen this happen with 3*900 matrices), the results vary slightly.
Is this a problem of inaccuracy with matlab or do I need to brush up on my maths lessons?
Thank you lot for you answers

 Accepted Answer

It is expected that the results would differ slightly, due to different order of operations.
Internally, the code computes two qr() independently -- that part should produce exactly the same results regardless of which order the matrices are.
But then the code does svd(Q1' * Q2,0) . It is to be expected that Q1' * Q2 differs slightly from Q2' * Q1 that you would get if the arrays were switched.

More Answers (0)

Asked:

on 10 Dec 2024

Commented:

on 10 Dec 2024

Community Treasure Hunt

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

Start Hunting!