Skip to content

Covariance matrices estimation speed #2

@lkorczowski

Description

@lkorczowski

Hi,

I wanted to know if there is a specific reason why, in asr_calibrate, the following loop was used for the covariance estimation

line 158

% calculate the sample covariance matrices U (averaged in blocks of blocksize successive samples)
U = zeros(length(1:blocksize:S),C*C);
for k=1:blocksize
    range = min(S,k:blocksize:(S+k-1));
    U = U + reshape(bsxfun(@times,reshape(X(range,:),[],1,C),reshape(X(range,:),[],C,1)),size(U));
end

A faster and less memory intensive implementation would be something like this:

U2 = zeros(length(1:blocksize:S),C*C);
indx=1:blocksize:S;
for i=k:length(1:blocksize:S)
    indices=indx(k):min(S,indx(k)+blocksize-1);
    U2(k,:) = reshape(X(indices,:)' * X(indices,:),[1 C*C]);
end

Also, I see that that the default blocksize is 10 which seems very low for a correct empirical covariance estimation. Shouldn't we prefer a blocksize at least greater than the number of electrodes (or even blocksize>2*C) ?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions