Mercurial > hg > smallbox
annotate util/classes/@dictionary/cumcoherence.m @ 193:cc540df790f4 danieleb
Simple example that demonstrated dictionary learning... to be completed
author | Daniele Barchiesi <daniele.barchiesi@eecs.qmul.ac.uk> |
---|---|
date | Fri, 09 Mar 2012 15:12:01 +0000 |
parents | 28b20fd46ba7 |
children |
rev | line source |
---|---|
daniele@179 | 1 function mu = cumcoherence(obj,p) |
daniele@179 | 2 % Calculates the p-cumulative coherence of the dictionary, defined as |
daniele@179 | 3 % \mu_p(k) = max_|I|=k{max_j\notin I{(\sum_i \in I}|<\phi_i,\phi_j>|^p)^1/p} |
daniele@179 | 4 % |
daniele@179 | 5 % INPUT |
daniele@179 | 6 % obj: dictionary object |
daniele@179 | 7 % p: power (default 1) |
daniele@179 | 8 % |
daniele@179 | 9 % OUTPUT |
daniele@179 | 10 % mu: p-cumulative coherence |
daniele@180 | 11 if ~exist('p','var') || isempty(p), p = 1; end |
daniele@179 | 12 |
daniele@160 | 13 obj = normalize(obj); |
daniele@160 | 14 [M N] = size(obj.phi); |
daniele@160 | 15 mu = zeros(M,1); |
daniele@160 | 16 for m=1:M |
daniele@179 | 17 c = zeros(N); |
daniele@179 | 18 for i=1:N |
daniele@179 | 19 c(:,i) = abs(obj.phi'*obj.phi(:,i)).^p; |
daniele@179 | 20 c(i,i) = 0; |
daniele@179 | 21 end |
daniele@179 | 22 c = sort(c,'descend'); |
daniele@179 | 23 c = c(1:m,:); |
daniele@179 | 24 if m==1 |
daniele@180 | 25 mu(m) = max(c.^(1/p)); |
daniele@179 | 26 else |
daniele@180 | 27 mu(m) = max(sum(c).^(1/p)); |
daniele@179 | 28 end |
daniele@160 | 29 end |
daniele@160 | 30 end |