forked from mwaskom/seaborn-data
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gammas.py
33 lines (24 loc) · 882 Bytes
/
gammas.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import numpy as np
import pandas as pd
from scipy import stats
def main():
rs = np.random.RandomState(24)
n = 20
t = 10
x = np.linspace(0, t, 100)
s = np.array([stats.gamma.pdf(x, a) for a in [3, 5, 7]])
d = s[:, np.newaxis, :]
d = d * np.array([1, -1])[rs.binomial(1, .3, 3)][:, np.newaxis, np.newaxis]
d = d + rs.normal(0, .15, (3, n))[:, :, np.newaxis]
d = d + rs.uniform(0, .25, 3)[:, np.newaxis, np.newaxis]
d *= 10
d = d.transpose((1, 2, 0))
p = pd.Panel(d,
items=pd.Series(np.arange(n), name="subject"),
major_axis=pd.Series(x, name="timepoint"),
minor_axis=pd.Series(["IPS", "AG", "V1"], name="ROI"),
)
df = p.to_frame().stack().reset_index(name="BOLD signal")
df.to_csv("gammas.csv", index=False)
if __name__ == "__main__":
main()