tensorflow / probability

Probabilistic reasoning and statistical analysis in TensorFlow
https://www.tensorflow.org/probability/
Apache License 2.0
4.16k stars 1.08k forks source link

`LinearGaussianStateSpaceModel` filtering initial state is incorrect #1797

Open Joshuaalbert opened 3 months ago

Joshuaalbert commented 3 months ago

The initial state for filter step is wrong, and is p(x0), when it should be p(x1|x0), i.e. kalman transition should already be applied to the initial state. This line.

Since the filter step does update first and transition second, the prior input to update step is expecting input to be p(x_k | x_k-1). This is performed in linear_gaussian_update, and you can see that it takes the carry value, which would point to p(x0) initially.

Further: to see why, take a look at the sampling method. The initial state is p(x0) and the sampling performs a transition first before sampling the observables.