# Kalman filter in data fusion

I am very new to Kalman filter. I am doing a project using one sensor the track the sensor's position. I developed 2 methods to solve the position, one in better accuracy and one is less accurate.

I would like to know that can I use Kalman filter to fuse the 2 position-solving algorithms to achieve a better performance? I know Kalman filter is often used in sensor fusion(multiple sensors). I don't know is it also work on fusing algorithms(single sensor).

• Hello, I posted an answer and I edited it a lot because I'm not sure to understand your question very well. Do you want to know how to implement Kalman for sensor fusion or do you want to if it might work on your problem? If you are in the second case please be more explicit about your input data and your two algorithms. Commented Feb 21, 2023 at 9:56
• Thanks for your contribution. It is the second case. I would like to know if kalman filter work on my problem. To be specific, I have one magnetic sensor. I have 2 methods to solve the real-time sensor's position (x,y,z) . I just want to know if I run 2 methods simultaneously, then I will get 2 sets of sensor's position ( one in higher accuracy, and the other in lower accuracy). Can i use kalman filter to fuse the 2 sets of data and get a better performance than just using1 method alone? Commented Feb 21, 2023 at 10:37
• Does your sensor have Gaussian noise? Are your algorithms linear? if not, do their output show Gaussian-ish noise?(you need Gaussian noise to perform the vanilla Kalman filter) Do you even know their variance-covariance matrices, which in my knowledge would be a prerequisite for sensor fusion? My personal belief is that without more exogenous output Kalman filter will not outperform your best algorithm but maybe I'm wrong. You should try it in a simple simulation and come back to tell your results. I'm actually curious about the answer. Commented Feb 21, 2023 at 10:54
• I have read some papers about using kalman filter on the magnetic sensor localization. I think it is not linear. And people actually is using unscented kalman filter. However, i am just wondering can i do the fusion on One single sensor with 2 algorithms. I haven't completed the second algorithm, so i cannot tell their variance-covariance. Commented Feb 22, 2023 at 7:32
• If you have two data points and two associated variance-covariances matrices at each step, you will be able to perform Kalman filtering. If you don't have ridiculous outliers, it is likely that your Kalman filter will not derail into nothingness. Now will the Kalman yield better results than your best algorithm... I have no clue. It would feel weird because you don't incorporate new information but why not? This tutorial shows that one can estimate a position and its derivative with the stupidest of models for instance. Commented Feb 22, 2023 at 7:42

To be more accurate, in the formalism found here one algorithm gives you $$\hat{X}_{k|k-1}$$ and $$\hat{P}_{k|k-1}$$ and the other gives you $$z_k$$ and $$R_k$$.
Then the update would look something like that : $$X_{k|k} = \hat{X}_{k|k-1}+\hat{P}_{k|k-1}(\hat{P}_{k|k-1}+R_k)^{-1}(z_k-\hat{X}_{k|k})$$