Skip to content

Instantly share code, notes, and snippets.

@localmin
Last active October 14, 2017 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save localmin/bf272f79ee64d354f057941f767e892b to your computer and use it in GitHub Desktop.
Save localmin/bf272f79ee64d354f057941f767e892b to your computer and use it in GitHub Desktop.
Matlab Function for Joint Diagonalize for BSS
function G = JointDiagonalize( S )
[ ~, N ] = size( S );
halfN = N / 2;
% Make two Correlation matrices
S1 = S(:,1:halfN);
S2 = S(:,halfN + 1:N);
Ex1 = (S1 * S1')/halfN;
[ P1, D1 ] = eig( Ex1 );
rD1_inv = D1^(-1/2);
Gd = rD1_inv * P1';
Ex2 = (S2 * S2')/halfN;
Ex2d = Gd * Ex2 * Gd';
[ P2, ~ ] = eig( Ex2d );
G = P2' * Gd;
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment