forked from lanadescheemaeker/logistic_models
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoise_color_analysis.py
91 lines (67 loc) · 2.74 KB
/
noise_color_analysis.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
def check_consistency_noise_color(fts, ffig):
transient = 100
a = transient + 1000
b = a + 1000
species = [0,1]
data = np.loadtxt(fts)
fig = plt.figure()
ax = fig.add_subplot(1,4,1)
ax.plot(data[species, transient:b].T)
for i in [a]:
ax.axvline(x=i)
axa = fig.add_subplot(1, 4, 2)
axb = fig.add_subplot(1, 4, 3, sharex=axa, sharey=axa)
axt = fig.add_subplot(1, 4, 4, sharex=axa, sharey=axa)
for s in species:
example_noise_fit(axa, data[s, transient:a])
example_noise_fit(axb, data[s, a:b])
example_noise_fit(axt, data[s, transient:b])
axa.legend()
axb.legend()
axt.legend()
if False:
df = pd.DataFrame(data.T, columns=['species_%d' % i for i in range(100)])
df2 = pd.DataFrame(data[:,100:].T, columns=['species_%d' % i for i in range(100)])
print(noise_slope(df))
print(noise_slope(df2))
plt.show()
#plt.savefig(ffig)
def check_consistency_noise_color2(fts):
data = np.loadtxt(fts)
halfway = int(len(data[0])/2)
fig = plt.figure(tight_layout=True)
df = pd.DataFrame(data[:,:halfway].T, columns=['species_%d' % i for i in range(100)])
df2 = pd.DataFrame(data[:,halfway:].T, columns=['species_%d' % i for i in range(100)])
n1 = noise_slope(df)
n2 = noise_slope(df2)
idx = np.where(abs(n1['slope_linear']-n2['slope_linear']) > 1)[0][0]
fig2 = plt.figure()
ax = fig2.add_subplot(111)
ax.grid()
example_noise_fit(ax, df['species_%d'%(idx)], label='%.2f'%n1['slope_linear'][idx])
example_noise_fit(ax, df2['species_%d'%(idx)], label='%.2f'%n2['slope_linear'][idx])
ax.legend()
df = pd.DataFrame(data[:, 100:halfway].T, columns=['species_%d' % i for i in range(100)])
#df2 = pd.DataFrame(data[:, halfway+100:].T, columns=['species_%d' % i for i in range(100)])
n1_notrans = noise_slope(df)
#n2_notrans = noise_slope(df2)
ax = fig.add_subplot(2,1,1)
ax.set_title('with transient in first half')
ax.scatter(n1['slope_linear'], n2['slope_linear'], label=None)
e = n1['slope_linear'] - n2['slope_linear']
mse = np.mean(e[np.isfinite(e)] ** 2)
ax.plot([-3,0], [-3,0], label='MSE = %.2f' % mse)
ax.set_xlabel('slope noise first half')
ax.set_ylabel('slope noise second half')
ax.legend()
ax = fig.add_subplot(2,1,2)
ax.set_title('without transient in first half')
ax.scatter(n1_notrans['slope_linear'], n2['slope_linear'], label=None)
e = n1_notrans['slope_linear'] - n2['slope_linear']
mse = np.mean(e[np.isfinite(e)]**2)
ax.plot([-3,0], [-3,0], label='MSE = %.2f' % mse)
ax.set_xlabel('slope noise first half')
ax.set_ylabel('slope noise second half')
ax.legend()
#plt.show()
#plt.savefig(ffig)