In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the relevant knowledge of "how to achieve Kalman filter data processing in python". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to achieve Kalman filter data processing in python" can help you solve the problem.
What is Kalman filter
First look at the Baidu encyclopedia explanation ha: Kalman filter (Kalman filtering) is a linear system state equation, through the system input and output observation data, the optimal estimation of the system state algorithm. Because the observed data include the influence of noise and interference in the system, the optimal estimation can also be regarded as a filtering process.
Say the important thing three times:
Might as well not look at it!
You might as well not look at it!
It would be better not to look!
In fact, we do not need to regard Kalman filter as a very complex thing, in popular words, Kalman filter algorithm is only a filtering algorithm, its function is filtering, the function of filtering is to reduce the impact of noise and interference on data measurement.
How to filter Kalman filter
Next, I will summarize the operation of Kalman filter in one sentence:
Kalman filter is a kind of optimal prediction value which is calculated by the combination of historical data, historical accumulated error, current measurement data and current error.
First of all, you need to understand what is the optimal predicted value currently being measured:
There are two important concepts, namely the optimal value and the predicted value:
This means:
1. The result of Kalman filter is not really measured, but the prediction result calculated by formula (it does not mean that the prediction result is not good, there are still errors in measurement! )
2. The best reason is that Kalman filter considers a lot, it combines four parameters to predict the current measurement, so the effect is better.
Next, we should understand the concepts of historical data, historical accumulated errors, current measurement data and current errors.
I will tell you the concept of these four things through examples.
Kalman filter example
Suppose we are using ultrasonic to measure the distance! Now it is t time, and we need to estimate the distance of t time with the distance of tmur1 time.
If the optimal predicted value of ultrasonic wave is 50cm at t Mel 1 time, and the accumulated error 3cm at t mi 1 time, and your own uncertainty error for prediction is 4cm, then the total error is (32-42) 1/2=5cm at t Mel 1 time.
At t moment, the actual value measured by ultrasound is 53cm, and the measurement error is 2cm, so how can we believe the predicted value of the last moment and the actual value of this moment? Because neither of them is accurate, we can use the error to calculate.
Therefore, we combine historical data, historical accumulated errors, current measurement data and current errors to calculate:
So the current optimal prediction is 52.59.
The python code of Kalman filter realizes import numpy as npimport matplotlib.pyplot as plt# Q as the mental estimation error of this round Q = 0.0000r as the measurement error of the next round R = 0.1 Accumulated_Error as the estimation error of the previous round The cumulative Accumulated_Error of all errors is shown as kalman_adc_old = initial old value kalman_adc_old = 0SCOPE = 50def kalman (ADC_Value): when the difference between the new value of global kalman_adc_old global Accumulated_Error # and the old value is too large, track if (abs (ADC_Value-kalman_adc_old) / SCOPE > 0.25): Old_Input = ADC_Value*0.382 + kalman_adc_old*0. 618 else: Old_Input = kalman_adc_old # Total error = cumulative error ^ 2 + estimation error ^ 2 Old_Error_All = (Accumulated_Error**2 + QTL 2) * * (1 beat 2) # R is the prediction error of this round # H is the confidence level H = Old_Error_All**2/ (Old_Error_All) calculated by using the mean square error * * 2 + Roundup 2) # Old value + 1.00001 / (1.00001x0.1) * (new value-old value) kalman_adc = Old_Input + H * (ADC_Value-Old_Input) # calculate the new cumulative error Accumulated_Error = ((1-H) * Old_Error_All**2) * * (1top 2) # the new value becomes the old value kalman_adc_old = kalman_ Adc return kalman_adcarray = np.array ([50] * 200) s = np.random.normal (0 5,200) test_array = array + splt.plot (test_array) adc= [] for i in range: adc.append (kalman (test_ Array [I]) plt.plot (adc) plt.plot (array) plt.show ()
The experimental results are as follows:
This is the end of the introduction of "how to achieve Kalman filter data processing by python". Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.