With two relatively inaccurate sensors we are able to deduce an extremely accurate result.
So two sensors, even if one is less accurate than the other, is better than one. I will harp on this for the remainder of the book. We never throw information away, no matter how poor it is. We will be developing math and algorithms that allow us to include all possible sources of information to form the best estimate possible.
NumPy does! We want to draw a line through the measurements that looks 'about' right. NumPy has functions that will do this according to a rule called "least squares fit"
The key insight to this entire book is in the next paragraph. Read it carefully!
量测与预测,measurement and prediction,estimate
some kind of blend of the prediction and measurement
The g-h Filter
This algorithm is known as the g-h filter or the αα-ββ filter. gg and hh refer to the two scaling factors that we used in our example. gg is the scaling we used for the measurement (weight in our example), and hh is the scaling for the change in measurement over time (lbs/day in our example). αα and ββ are just different names used for this factors.
Let me repeat the key points as they are so important. If you do not understand these you will not understand the rest of the book. If you do understand them, then the rest of the book will unfold naturally for you as mathematical elaborations to various 'what if' questions we will ask about gg and hh. The math may look profoundly different, but the algorithm will be exactly the same.
- Multiple data points are more accurate than one data point, so throw nothing away no matter how inaccurate it is.
- Always choose a number part way between two data points to create a more accurate estimate.
- Predict the next measurement and rate of change based on the current estimate and how much we think it will change.
- The new estimate is then chosen as part way between the prediction and next measurement scaled by how accurate each is.