-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstats
More file actions
executable file
·36 lines (29 loc) · 1.04 KB
/
stats
File metadata and controls
executable file
·36 lines (29 loc) · 1.04 KB
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
#!/usr/bin/env python
import glob
import yaml
import numpy as np
def ess(logw):
w = np.exp(logw - np.max(logw))
return np.sum(w)**2/np.sum(w*w);
def car(logw):
w = np.sort(np.exp(logw - np.max(logw)))
c = np.cumsum(w)
return (2*np.sum(c)/c[-1] - 1.0) / logw.size
for f in sorted(glob.glob("./output/filter*.yml")):
print("File: %s" % f)
data = yaml.load(open(f, 'r'))
if data:
logw = np.array([item['lweight'] for item in data])
print('#samples: %d' % len(logw))
print('ESS: %f' % ess(logw))
print('CAR: %f' % car(logw))
print('Mean log Z: %f' % np.mean(logw))
print('Var log Z: %f' % np.var(logw))
if './output/filter_rcpf_' in f:
g = f.replace('/output/', '/diagnostic/')
data_diag = yaml.load(open(g, 'r'))
if data_diag:
N = data_diag[0]['nparticles']
rho = np.mean(list(np.mean(item['propagations']) for item in data_diag)) / N
print('Rho: %f' % rho)
print()