calc_pvalue function

Calculate the p-value for a permutation test