Excellent question! This is actually one of the biggest practical challenges with Kalman Filters. You've hit on a key limitation.
The Standard Kalman Filter Does NOT Learn
The classic Kalman Filter is not adaptive—it doesn't learn or correct the uncertainty parameters (Q and R) on its own. If you give it bad values, it will stick with them forever and give you suboptimal results.
What happens with bad parameters:
- Q too small: The filter becomes overconfident in its predictions and ignores useful sensor data.
- Q too large: The filter becomes jittery and follows every noisy measurement.
- R too small: The filter trusts bad sensors too much.
- R too large: The filter ignores good sensor data.
But There Are Solutions
1. Adaptive Kalman Filters
These are enhanced versions that do learn and adjust Q and R over time:
- Innovation-based adaptive filters: They monitor the "innovation" (the difference between predicted and measured values) and adjust parameters when the pattern changes.
- Maximum likelihood estimation: They continuously estimate what Q and R should be based on recent data.
- Multiple model filters: They run several Kalman filters with different parameter sets and choose the best-performing one.
2. Practical Tuning Methods
Even with standard Kalman filters, you can iteratively improve your parameter estimates:
- Start conservative: Begin with larger uncertainty values (higher Q and R) rather than smaller ones.
- Monitor performance: Look at the innovation sequence—if it's consistently large, your parameters might be off.
- Use real data: Collect actual sensor data and calculate the real noise statistics.
Real-World Example: Your Phone's GPS
Your phone doesn't know the exact uncertainty of its GPS sensor when you first turn it on. But here's what happens:
- Initial guess: The system starts with reasonable default values for Q and R.
- Learning over time: Modern systems use adaptive algorithms that notice patterns:
- If you're consistently moving faster than predicted, it increases Q (process noise).
- If GPS readings are consistently jumping around, it increases R (measurement noise).
- Context awareness: Your phone also uses other information (accelerometer, known road maps) to cross-check and improve its estimates.
A Simple Check You Can Do
Here's a practical way to tell if your parameters are reasonable:
Monitor the "residuals" (the difference between what you predicted and what you measured):
- If residuals are consistently large in one direction, your model might be biased.
- If residuals are much larger or smaller than expected, your noise estimates are probably wrong.
- Good parameters should give you residuals that look like random noise with no clear pattern.
Bottom Line
- Standard Kalman Filter: No learning—you're stuck with your initial guesses.
- Adaptive versions: Yes, they can learn and improve over time.
- In practice: Most modern applications (like your phone's GPS) use some form of adaptive filtering or parameter tuning.
So if you're implementing a Kalman filter and don't know the exact noise parameters, you have options! Start with reasonable estimates, use an adaptive version if possible, or be prepared to tune the parameters based on real performance data.
The key is that even with imperfect parameters, a Kalman filter often performs better than using predictions or measurements alone—it's quite robust to parameter misestimation, just not optimal.