Skip to content

Commit

Permalink
Merge pull request #53 from AlonDaks/gaussian-filter
Browse files Browse the repository at this point in the history
Added inter-run correlation simulation
  • Loading branch information
Ying Luo committed Dec 9, 2015
2 parents 16f9c53 + 7c19c3a commit 670adf1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
28 changes: 28 additions & 0 deletions code/stat159lambda/simulations/correlation_simulation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
from stat159lambda.config import REPO_HOME_PATH


def simulate_inter_run_correlation():
subj_1 = np.concatenate((np.random.normal(5, 2, 100), np.random.normal(
10, 2, 100)))
subj_2 = np.concatenate((np.random.normal(5, 2, 100), np.random.normal(
10, 2, 100)))
correlations = [stats.pearsonr(subj_1, subj_2),
stats.pearsonr(subj_1[:100], subj_2[:100]),
stats.pearsonr(subj_1[100:], subj_2[100:])]
fig = plt.figure()
ax1 = fig.add_subplot(111)
ax1.plot(subj_1, c='b', label='Subject a')
ax1.plot(subj_2, c='r', label='Subject b')
ax1.axvline(100, color='g', linestyle='solid')
plt.legend(loc='upper left')
plt.savefig('{0}/figures/sim_inter_run.png'.format(REPO_HOME_PATH))
np.savetxt(
'{0}/figures/sim_inter_run_correlations.txt'.format(REPO_HOME_PATH),
correlations)


if __name__ == '__main__':
simulate_inter_run_correlation()
3 changes: 2 additions & 1 deletion figures/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.png
*.png
*.txt

0 comments on commit 670adf1

Please sign in to comment.