Skip to content

Instantly share code, notes, and snippets.

@deep-introspection
Created November 24, 2017 13:12
Show Gist options
  • Save deep-introspection/2277a43ec192756d8861ae5bf2384602 to your computer and use it in GitHub Desktop.
Save deep-introspection/2277a43ec192756d8861ae5bf2384602 to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
trials = 200
x = np.random.randn(trials, 9, 16)
effect_size = np.linspace(0, 1, 9)
sample_size = np.linspace(10, 1000, 16)
for trial in range(trials):
for es_i,es_v in enumerate(effect_size):
for ss_i,ss_v in enumerate(sample_size):
patients = np.random.randn(ss_v)+es_v
controls = np.random.randn(ss_v)
x[trial, es_i, ss_i] = (np.mean(patients)-np.mean(controls))
plt.figure(figsize=(16,9))
plt.imshow(np.std(x, axis=0), interpolation='nearest', cmap='afmhot')
plt.xlabel('Sample size')
plt.ylabel('Effect size')
plt.gca().invert_yaxis()
plt.xticks(range(len(sample_size)), sample_size.astype(int))
plt.yticks(range(len(effect_size)), effect_size)
plt.title(r'$\phi$')
plt.colorbar()
plt.tight_layout()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment