jacobnzw / SSMToybox

Nonlinear Sigma-Point Kalman Filters based on Bayesian Quadrature
MIT License
12 stars 0 forks source link

Re-Run the TPQSF Experiments #29

Closed jacobnzw closed 3 years ago

jacobnzw commented 3 years ago

Looks like there is a bug in the code in the StudentProcessKalman and StudentProcessStudent. The output dimension argument dim_out is improperly set to 1. For example: https://github.com/jacobnzw/SSMToybox/blob/1e2a8fd0634f6d53a30e24c21465c8e32c88999b/ssmtoybox/ssinf.py#L831-L832

This means that in the term self.I_out is of shape (1, 1), as per the following: https://github.com/jacobnzw/SSMToybox/blob/1e2a8fd0634f6d53a30e24c21465c8e32c88999b/ssmtoybox/bq/bqmtran.py#L58

which then affects the computation of covariance in https://github.com/jacobnzw/SSMToybox/blob/1e2a8fd0634f6d53a30e24c21465c8e32c88999b/ssmtoybox/bq/bqmtran.py#L414-L415

This affects research code. Usually, the expected model variance (emv) is a tiny number, so I don't expect the results to be dramatically affected and the conclusion of the research will be unchanged.

The EMV in the following line is computed wrong! https://github.com/jacobnzw/SSMToybox/blob/1e2a8fd0634f6d53a30e24c21465c8e32c88999b/ssmtoybox/bq/bqmod.py#L1158

The error is in the quadratic form. We need y_e.dot(iK).dot(y_e) for all e, which should yield a vector of values! Not a matrix as it is now. This can be fixed with np.einsum().

Also, note the -2 in the numerator and denominator. In the fusion paper, the posterior TP covariance (eq. 32) and the filtered covariance in the t-filter (eq. 42) are expressed in terms of covariances. In the Michael Roth's technical note, the (eq. 5.4) is an expression for the filtered (conditional/posterior) scale matrix - not covariance. This expression, from Roth, is used in the _measurement_update(), which is expressed in terms of scale matrices.

Need to verify this!

jacobnzw commented 3 years ago

The effect on experiment results was marginal as expected.