Last active
October 15, 2019 12:30
-
-
Save VictorSaenger/a7417333a1f172834e64a4b1c40dbda5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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