Update of permutation test from Matlab