function AverageDist = dictdist(approxD,D)
% compute the average distance from D and approxD
% please note the distance defined here is not a real distance and is not
%       symmetric. 
%
% Wei Dai, Tao Xu, Wenwu Wang
% Imperial College London, University of Surrey
% wei.dai1@imperial.ac.uk  t.xu@surrey.ac.uk  w.wang@surrey.ac.uk
% October 2011

[m,d] = size(D);
DistV = zeros(1,d);
for cn = 1:d
    dist_t = 1-abs(D(:,cn)'*approxD);
    DistV(cn) = min(dist_t);
end
AverageDist = mean(DistV);

