the threshold function is in s0793293/ID4513/permutations2.R