-
Notifications
You must be signed in to change notification settings - Fork 0
/
Seasonal.py
61 lines (50 loc) · 1.66 KB
/
Seasonal.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
import EspaceState as EE
import numpy as np
class Seasonal:
def __init__(self):
self.EE = EE.EspaceState()
self.__init_exatc()
self.__init_params()
self.__init_matrix()
self.EE.set_system(self.z,self.t,self.r,self.h,self.q,self.c,self.d,self.params)
self.EE.set_init(self.burn,self.Pinf,self.Pstar)
def filter(self,y):
return self.EE.diffuse_filter(y)
def exact_filter(self,y):
return self.EE.exact_filter(y)
def simulate(self,nr_params):
return self.EE.simulate(nr_params)
def ll(self,y):
return self.EE.ll_func(y)
def fit(self,y):
return self.EE.optimize(y)
def smooth(self,y):
return self.EE.diffuse_smooth(y)
def __init_matrix(self):
self.z = np.matrix([1,0,0,0,0])
self.t = np.matrix([[-1,-1,-1,-1,-1],[0,0,0,0,0],[0,1,0,0,0],[0,0,1,0,0],[0,0,0,1,0]])
self.r = np.matrix([[1],[0],[0],[0],[0]])
self.q = np.matrix([1])
self.h = np.matrix([1])
self.c = np.matrix([[0],[0],[0],[0],[0]])
self.d = np.matrix([[0],[0],[0],[0],[0]])
def __init_params(self):
params = {}
params['Z'] = []
params['T'] = []
params['R'] = []
params['Q'] = []
params['Q'].append(
{'position':[0,0],'type':'positive','value':0}
)
params['H'] = []
params['H'].append(
{'position':[0,0],'type':'positive','value':0}
)
params['C'] = []
params['D'] = []
self.params = params
def __init_exatc(self):
self.burn = 5
self.Pinf = np.matrix([1])
self.Pstar = np.matrix([0])