-
-
Notifications
You must be signed in to change notification settings - Fork 305
Open
Description
I have the following issue using the Kalman-Filter. Start with the following setup (the numbers don't really matter):
A = [0.4 0.; 0. 0.9]
G = [1. 0.6; 1. 0.]
R = [0. 0.; 0. 0.5]
Q = [1. 0.; 0. 1.5]
k = Kalman(A,G,Q,R)
Sigma_Inf, K_inf = stationary_values(k)
ishermitian(Sigma_Inf) -> false
Sigma_Inf ≈ conj(Sigma_Inf) -> true
set_state!(k,[0;0],Sigma_Inf)
update!(k,[1. ;1.])
update!(k,[1. ;1.])
ishermitian(k.cur_sigma) -> false
k.cur_sigma ≈ conj(k.cur_sigma) -> true
This is in both cases due to
k.cur_sigma[1,2] ≈ conj(k.cur_sigma[2,1]) -> true
k.cur_sigma[1,2] == conj(k.cur_sigma[2,1]) -> false
Now I am not sure if this warrants changes inside the ishermitian()
function, i.e. changing ==
to ≈
, or if inside this package we should make sure that k.cur_sigma[1,2] == conj(k.cur_sigma[2,1])
holds exactly.
What do you guys think?
In case you wonder why this may be important: Some other functions that take a VCOV matrix (e.g. qnwnorm
) control if the VCOV matrix is indeed Hermitian. A natural application would be
Kalman-Filtering -> obtaining estimates and vcov -> using these to form expectations over another function:
nodes, weights = qnwnorm(10,k.cur_x_hat,k.cur_sigma)
PosDefException: matrix is not Hermitian; Cholesky factorization failed.
in top-level scope at base\none
in qnwnorm at QuantEcon\7w41U\src\quad.jl:573
in qnwnorm at QuantEcon\7w41U\src\quad.jl:555
in cholesky at stdlib\v1.1\LinearAlgebra\src\cholesky.jl:275
in cholesky at stdlib\v1.1\LinearAlgebra\src\cholesky.jl:275
in #cholesky#101 at stdlib\v1.1\LinearAlgebra\src\cholesky.jl:275
in #cholesky! at base\none
in #cholesky! at base\none
in #cholesky!#97 at stdlib\v1.1\LinearAlgebra\src\cholesky.jl:182
in checkpositivedefinite at stdlib\v1.1\LinearAlgebra\src\factorization.jl:11
Metadata
Metadata
Assignees
Labels
No labels