% Use resampling to determine whether the difference in mean between
% data sets V and W is significant. Discussed section 12.7, p. 368.

function sig = RelabellingSig(V,W,MeanDiff)
   MeanDiff=abs(MeanDiff);
   NTEST = 10;
   M=length(V);
   C([1:M]) = V;
   C([M+1:2*M]) = W;
   LargerDiff = 0;
   for I = 1:NTEST
     D = C([randperm(2*M)]);
     if MeanDiff > mean(D([1:M])) - mean(D([M+1:2*M])) 
       LargerDiff = LargerDiff+1;
     end
   end
   sig = LargerDiff/NTEST;
end
