New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dot #424
Comments
Can you explain what you mean? dot is implementing matrix multiplications. In general, MxN @ NxP yields a shape of MxP the 2nd dimension of the first matrix must equal the 1st dimension of the second. So, 2x1 @ 1x1 yields a 2x1 result, which is correct. '*' is element wise multiplication, and definitely not what you want to do. I don't know 'does not work' means. You think the mathematical result is wrong, you are getting an exception, or ? If you are getting an exception, one of your matrices has the wrong dimensionality. Share an example and we can help you through it. |
For example, in EKF.update(), self.K = PHT.dot(linalg.inv(self.S)) pops up an error: ValueError: shapes (3,) and (1,1) not aligned: 3 (dim 0) != 1 (dim 0)....In this code, the shape of PHT is (3,) whilst self.S is (1,1). |
i met many such ValueError when using dot function. |
The filter needs to be designed correctly. You are either initializing it with the wrong values or your hx or jacobian is returning something of the wrong shape. you can
to see all of the matrices and identify where the problem is. I'm going to close this as matrix multiplication is the correct behavior, not element-wise multiplication. But feel free to respond with example code if you want me to take a look. In your example PHT is shape 3, which is almost certainly wrong. It makes me think your H is designed wrong, or maybe P. H is supposed to convert P to an array shaped the same as your measurement. If PHT is shape 3, that tells me you are expecting z to be shape 3,. But then the shape of S is 1, and S is the covariance of the system in measurement, so it implies the shape of z is 1,. This is not consistent, and so it raises an exception. The math is correct, the input is wrong. |
In Kalman_filter.update(), dot(PHT,self.SI) does not work because PHT is 21 whilst self.SI is 11. so dot can not compute these two matrixs with different dimensions. Therefore, we should change it to PHT*self.SI. This is also true of other functions such as dot(self.K,self.y)
The text was updated successfully, but these errors were encountered: