-
Notifications
You must be signed in to change notification settings - Fork 31
/
running_oas_covariance.py
30 lines (21 loc) · 1000 Bytes
/
running_oas_covariance.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
from precise.skatertools.syntheticdata.miscellaneous import create_correlated_dataset
from precise.skaters.covariance.bufsk import buf_sk_oas_pcov_d0_n100
from precise.skaters.covariance.runemp import run_emp_pcov_d0
from precise.skaters.covarianceutil.statefunctions import oas
from pprint import pprint
# Basic show_em of running OAS covariancecomparisonutil
# (just a simple function of the running state)
if __name__=='__main__':
ys = create_correlated_dataset(n=50)
# Method 1: Use the buffered OAS skater
s1 = {}
for y in ys:
x, x_cov, s1 = buf_sk_oas_pcov_d0_n100(s=s1, y=y)
print(x_cov)
# Method 2: Use the empirical skater and, when you need it, apply the OAS helper
# (Will be the same but only so long as n<n_buffer)
s2 = {}
for i,y in enumerate(ys):
x, x_cov, s2 = run_emp_pcov_d0(s=s2, y=y)
print(oas(**s2)) # <--- Lazy style often works for statefunctions
print(oas(pcov=x_cov,n_samples=i+1) ) # <--- Explicit style