The +1 is for counting the original unpermuted data. This also ensures that the p-value never drops below ```1 / (num_perms + 1)``` . This is how nonparametric p-values are computed in R and elsewhere in our stats code. I've also read papers / online sources that describe this method of computing monte carlo p-values (can dig those up if you want).