Skip to content

Instantly share code, notes, and snippets.

@VictorSaenger
Last active October 15, 2019 12:30
Show Gist options
  • Select an option

  • Save VictorSaenger/a7417333a1f172834e64a4b1c40dbda5 to your computer and use it in GitHub Desktop.

Select an option

Save VictorSaenger/a7417333a1f172834e64a4b1c40dbda5 to your computer and use it in GitHub Desktop.
#Compute ground truth correlation:
[r,pv] =stats.pearsonr(feat_set[:,1],feat_set[:,0])
#Copy one of the features:
pS = copy.copy(feat_set[:,1])
#Initialize variables:
pR = []
#Choose number of permutations:
p=10000
#Initialize permutation loop:
for i in range(0,p):
#Shuffle one of the features:
random.shuffle(pS)
#Computed permuted correlations and store them in pR:
pR.append(stats.pearsonr(pS,feat_set[:,0])[0])
#Significance:
p_val = len(np.where(np.abs(pR)>=np.abs(r))[0])/p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment