99"""
1010from textwrap import dedent
1111import numpy as np
12- from numpy import dot
1312from scipy .linalg import inv
1413from quantecon .lss import LinearStateSpace
1514from quantecon .matrix_eqn import solve_discrete_riccati
@@ -163,7 +162,9 @@ def whitener_lss(self):
163162 A , C , G , H = self .ss .A , self .ss .C , self .ss .G , self .ss .H
164163
165164 Atil = np .vstack ([np .hstack ([A , np .zeros ((n , n )), np .zeros ((n , l ))]),
166- np .hstack ([dot (K , G ), A - dot (K , G ), dot (K , H )]),
165+ np .hstack ([np .dot (K , G ),
166+ A - np .dot (K , G ),
167+ np .dot (K , H )]),
167168 np .zeros ((l , 2 * n + l ))])
168169
169170 Ctil = np .vstack ([np .hstack ([C , np .zeros ((n , l ))]),
@@ -204,11 +205,11 @@ def prior_to_filtered(self, y):
204205 # === and then update === #
205206 y = np .atleast_2d (y )
206207 y .shape = self .ss .k , 1
207- E = dot (self .Sigma , G .T )
208- F = dot (dot (G , self .Sigma ), G .T ) + R
209- M = dot (E , inv (F ))
210- self .x_hat = self .x_hat + dot (M , (y - dot (G , self .x_hat )))
211- self .Sigma = self .Sigma - dot (M , dot (G , self .Sigma ))
208+ E = np . dot (self .Sigma , G .T )
209+ F = np . dot (np . dot (G , self .Sigma ), G .T ) + R
210+ M = np . dot (E , inv (F ))
211+ self .x_hat = self .x_hat + np . dot (M , (y - np . dot (G , self .x_hat )))
212+ self .Sigma = self .Sigma - np . dot (M , np . dot (G , self .Sigma ))
212213
213214 def filtered_to_forecast (self ):
214215 """
@@ -222,8 +223,8 @@ def filtered_to_forecast(self):
222223 Q = np .dot (C , C .T )
223224
224225 # === and then update === #
225- self .x_hat = dot (A , self .x_hat )
226- self .Sigma = dot (A , dot (self .Sigma , A .T )) + Q
226+ self .x_hat = np . dot (A , self .x_hat )
227+ self .Sigma = np . dot (A , np . dot (self .Sigma , A .T )) + Q
227228
228229 def update (self , y ):
229230 """
@@ -268,9 +269,9 @@ def stationary_values(self, method='doubling'):
268269
269270 # === solve Riccati equation, obtain Kalman gain === #
270271 Sigma_infinity = solve_discrete_riccati (A .T , G .T , Q , R , method = method )
271- temp1 = dot (dot (A , Sigma_infinity ), G .T )
272- temp2 = inv (dot (G , dot (Sigma_infinity , G .T )) + R )
273- K_infinity = dot (temp1 , temp2 )
272+ temp1 = np . dot (np . dot (A , Sigma_infinity ), G .T )
273+ temp2 = inv (np . dot (G , np . dot (Sigma_infinity , G .T )) + R )
274+ K_infinity = np . dot (temp1 , temp2 )
274275
275276 # == record as attributes and return == #
276277 self ._Sigma_infinity , self ._K_infinity = Sigma_infinity , K_infinity
@@ -300,14 +301,14 @@ def stationary_coefficients(self, j, coeff_type='ma'):
300301 P_mat = A
301302 P = np .identity (self .ss .n ) # Create a copy
302303 elif coeff_type == 'var' :
303- coeffs .append (dot (G , K_infinity ))
304- P_mat = A - dot (K_infinity , G )
304+ coeffs .append (np . dot (G , K_infinity ))
305+ P_mat = A - np . dot (K_infinity , G )
305306 P = np .copy (P_mat ) # Create a copy
306307 else :
307308 raise ValueError ("Unknown coefficient type" )
308309 while i <= j :
309- coeffs .append (dot (dot (G , P ), K_infinity ))
310- P = dot (P , P_mat )
310+ coeffs .append (np . dot (np . dot (G , P ), K_infinity ))
311+ P = np . dot (P , P_mat )
311312 i += 1
312313 return coeffs
313314
@@ -317,4 +318,4 @@ def stationary_innovation_covar(self):
317318 R = np .dot (H , H .T )
318319 Sigma_infinity = self .Sigma_infinity
319320
320- return dot (G , dot (Sigma_infinity , G .T )) + R
321+ return np . dot (G , np . dot (Sigma_infinity , G .T )) + R
0 commit comments