function D = measure(x,l)

q = length(x);

%l = 1; % gives the number of distance computed. 
         % l = q : full precision but long
         % l = q/4: much faster but with lower precision.

uu = [x x];

D = ones(1,l)*1000;
for i = 1:q-1
   for j = i+1:q
       distance = 0;
       for L = 1:l
           delta = uu(i+L-1)-uu(j+L-1);
           distance = distance + delta*delta';
           D(L) = min( [distance D(L)]);
       end
   end
end
D = D./(1:l);
          
