在好例子网,分享、交流、成长!
您当前所在位置:首页Others 开发实例一般编程问题 → Kalman and Bayesian Filters in Python

Kalman and Bayesian Filters in Python

一般编程问题

下载此实例
  • 开发语言:Others
  • 实例大小:6.90M
  • 下载次数:3
  • 浏览次数:167
  • 发布时间:2020-07-27
  • 实例类别:一般编程问题
  • 发 布 人:robot666
  • 文件格式:.pdf
  • 所需积分:2
 

实例介绍

【实例简介】
用python实现卡尔曼滤波与贝叶斯滤波,Roger R Labbe Jr,May 8, 2018
Contents Preface 0.1 Kalman and Bayesian Filters 0.2 Motivation for this book 12 0.3 Reading Online 13 0. 4 PDF Version 13 0.5 Downloading and running the book .....13 0.6 Jupyter 14 0.7 SciPy, NumPy, and Matplotlib 15 0.7.1 Exercise- Create arrays .,,,,,,,,,19 0.7.2 Solution ..,,,,.,.19 0.8 Companion Software 20 0. 9 Thoughts on Python and Coding math 20 0.10 License 21 0.11 Contact 21 0.12 Resources 21 1 The g-h Filter 1.1 Building Intuition via Thought Experiments 1.2 The g-h Filter 35 1. 3 Notation 38 1.4 Exercise: Write Generic Algorithm 1.4.1 Solution and Discussion 着垂 1.5 Choice of g and h 1.6 Exercise: create measurement function 1.6.1 Solution 1.6.2 Discussion 41 1. 7 Exercise: Bad Initial Conditions 1.7.1 Solution and Discussion 1.8 Exercise: Extreme Noise 42 1.8.1 Solution and Discussion 43 1.9 Exercise: The Effect of Acceleration 43 1.9.1 Solution and discussion 1.10 Exercise: Varying g 1.10.1 Solution and Discussion 1.11V 47 1.12 Interactive Example 48 1.13 Dont lie to the filter 1. 14 Tracking a Train 51 1.15 g-h Filters with FilterPy 56 1.16 Summary 58 3 CONTENTS 2 Discrete Bayes Filter 2.1 Tracking a Dog 2.2 Extracting Information from Sensor Readings 62 2.3 Noisy Sensors 62 2.4 Incorporating Movement 2.5 Terminology 2.6 Adding Uncertainty to the Prediction 68 2.7 Generalizing with Convolution 70 2.8 Integrating Measurements and Movement Updates 2. 9 The Discrete Bayes Algorithm ,,,,,,,74 2.10 The Effect of Bad Sensor Data 77 2.11 Drawbacks and limitations 2.12 Tracking and control 9 2. 12.1 Simulating the Train behavior 2.13 Bayes Theorem 83 2. 14 Total Probability Theorem 2.15 Summary 5 2.16 References .85 3 Gaussian probabilities 87 3.1 Introduction 3.2 Mean, Variance, and Standard Deviations 7 3.2.1 Random variables 3.3 Probability Distribution 3.3.1 The Mean, Median, and Mode of a random variable 3.4 Expected Value of a Random Variable 34.1 Variance of a random variable'·· 90 3.4.2 Why the square of the Differences 3.5 Gaussians 3.6 Nomenclature 3.7 Gaussian Distributions 98 3. 8 The Variance and Belief 101 3.9The68-95-997Rule. 102 3.10 Interactive Gaussians 103 3.11 Computational Properties of Gaussians 104 3.11.1 Product of Gaussians 104 3.11.2 Sum of Gaussians 106 3.12 Computing Probabilities with scipy stats ...106 3.13 Limitations of Using Gaussians to Model the World .· 108 3. 14 Summary and Key points 111 3.15 References 111 3.16 Useful Wikipedia Links ,,,,,111 4 One Dimensional Kalman Filters 113 4.1 Problem Description 113 4.2 Beliefs as Gaussians l14 4.3 Tracking with Gaussian Probabilities 115 4.4 Predictions with Gaussians 116 4.5 Updates with Gaussians 118 4.5.1 Understanding Gaussian Multiplication 119 4.5.2 Interactive Example 123 4.6 First Kalman filter 123 4.7 Code Walkthrough 126 4.7.1 Exercise: Modify Variance values 129 CONTENTS 4.7.2 KF Animation ,,,129 4. 8 Kalman gain 129 4.9 Full Description of the Algorithm .,,.....131 4.10 Comparison with g-h and discrete Bayes Filters .132 4.11 Introduction to Designing a Filter 134 4.11.1 Animation 137 4.12 Example: Extreme Amounts of noise ..137 4.13 Example: Incorrect Process Variance ..138 4.14 Example: Bad Initial Estimate 139 4.15 Example: Large Noise and Bad Initial Estimate 140 4.16 Exercise: Interactive plots 142 4.16. 1 Solution 142 4.17 Exercise-Nonlinear Systems 143 4.17.1 Solutio 144 4.17.2 Discussion 144 4.18 Fixed Gain Filters 145 4.19 FilterPy's Implementation 145 4. 20 Summary .146 5 Multivariate gaussians 147 5.1 Introduction ,,,147 5.2 Multivariate Normal Distributions ,,,147 5.3 Correlation and Covariance 148 5.4 Multivariate Normal Distribution Equation 153 5.4.1 Pearson's Correlation Coefficient 164 5.5 Using Correlations to Improve Estimates 165 5.6 Multiplying Multidimensional gaussians 166 5.7 Hidden variables ,,174 5.8 Higher Dimensions 179 5.9 ST 180 5.10 References 6 Multivariate Kalman Filters 181 6.1 Introduction 181 6.2 Newtons Equations of Motion 181 6.3 Kalman Filter Algorithm .182 6.4 Tracking a Dog 184 6.5 Predict Step·.· 184 6.5.1 Design State variable ...184 6.5.2 Design State Covariance ,186 6.5.3 Design the Process Model 187 6.5.4 Design Process noise 190 6.5.5 Design the Control Function ...19 6.6 Update Step ..192 6.6.1 Design the Measurement Function .192 6.7 Implementing the Kalman Filter .194 6. 8 The Saver Class 199 6. 9 The Kalman Filter Equations 201 6.9.1 Prediction Equations 201 6.9.2 Update Equations 205 6.9.3 An Example not using FilterPy 207 6.9.4 Summary 209 6.10 Exercise: Show Effect of Hidden Variables ,,210 6.10.1 Solution 210 CONTENTS 6.10.2 Discussion 211 6.11 How Velocity is Calculated 213 6. 12 Adjusting the Filter 214 6.13 A Detailed Examination of the Covariance Matrix .219 6.14 Question: Explain Ellipse Differences ...225 6.14.1 Solution 6.15 Filter Initialization 7 6.16 Batch Processing .227 6. 17 Smoothing the results 229 6.18 Exercise: Compare Velocities ..,.....231 6.18.1 Solution .231 6. 19 Discussion and Summary ...232 6.20 References 233 7 Kalman filter math 235 7.1 Modeling a Dynamic System 235 7. 2 State-Space Representation of Dynamic Systems 237 7.2.1 Forming First Order Equations from Higher Order Equations 238 7.2.2 First Order Differential Equations In State-Space Form 238 7.2.3 Finding the Fundamental Matrix for Time Invariant Systems 239 7.2.4 The Matrix Exponential ..,,,.239 7.2.5 Time Invariance ,,241 7. 2.6 Linear Time Invariant Theory 242 7. 2.7 Numerical Solutions 242 7.3 Design of the Process Noise Matrix 243 7.3.1 Continuous white noise model 243 7.3.2 Piecewise White noise model 245 7.3.3 Using FilterPy to Compute Q 247 7.3.4 Simplification of Q 247 7.4 Stable Compution of the Posterior Covariance 248 7.5 Deriving the Kalman Gain Equation 250 7.6 Numeric Integration of Differential Equations 251 7.6.1 Euler's Method 251 7.6.2 Runge Kutta Methods 254 7.7 Bayesian Filtering 256 7. 8 Converting Kalman Filter to a g-h Filter 258 7.9 References ..259 8 Designing Kalman Filters 261 8.1 Introduction 261 8.2 Tracking a Re 261 8.2.1 Choose the state Variables 262 8.2.2 Design State Transition Function 263 8.2.3 Design the Process Noise matrix 8.2.4 Design the Control Function 264 8.2.5 Design the measurement Function 264 8.2.6 Design the Measurement Noise Matrix 265 8.2.7 Initial Conditions 26 8.2.8 Implement the Filter 265 8.3 Filter Order 268 8.3.1 Zero Order Kalman filter 270 8.3.2 First Order Kalman filter 271 8.3.3 Second Order Kalman Filter ,,,272 8.4 Evaluating Filter Order 273 CONTENTS 8.5 Exercise: State Variable design 看 289 8.5.1 Solution 289 8.6 Detecting and Rejecting Bad Measurement 291 8.6.1 Gating and Data Association Strategies 296 8.7 Evaluating Filter Performance 298 8.7.1 Normalized Estimated Error Squared (NEES) 298 8.7.2 Likelihood Function 8.8 Control Inputs 301 8.9 Sensor Fusion 303 8.9.1 Exercise: Can you Filter GPS outputs? 308 8.9.2 Exercise: Prove that the position sensor improves the filter .313 8.10 Nonstationary Processes 314 8.10.1 Sensor fusion: Different Data rates 315 8.11 Tracking a Ball 8.11.1 Choose the State Variables 320 8.11.2 Design State Transition Function 321 8.11.3 Design the Control Input Function 321 8.11. 4 Design the Measurement Function 8.11.5 Design the Measurement noise matrix .323 8.11.6 Design the Process Noise matrix 323 8.11.7 Design the Initial Conditions .323 8.12 Tracking a Ball in air ......325 8.12.1 Implementing Air Drag 8.13 References 333 N onlinear Filtering 335 9.1 Introduction 335 9.2 The Problem with nonlinearity ..336 9.3 An Intuitive Look at the problem ...336 9.4 The Effect of Nonlinear Functions on Gaussians ,337 9.5 A 2D Example ...344 9.6 The Algorithms 347 97 Summary· 348 9.8 References 349 10 The Unscented Kalman filter 351 10.1 Sigma Points-Sampling from a Distribution 10.2 A Quick Example 355 10.3 Choosing Sigma Points ...357 10.4 The Unscented Transform .360 10.4.1 Accuracy of the Unscented Transform 361 10.5 The Unscented Kalman Filter 62 10.5.1 Predict Step .362 10.5.2 Update Step 363 10.6 Van der Merwe's Scaled Sigma Point Algorithm ,,,,,,.364 10.6.1 Sigma Point Computation .365 10.6.2 Weight Computation 365 10.6.3 Reasonable Choices for the parameters 10.7 Using the UKF 366 10.8 Tracking an Airplane .369 10.8.1 Tracking Maneuevering Aircraft 375 10.8.2 Sensor fusion 377 10.8.3 Multiple position Sensors 10.9 Effects of Sensor Error and Geometry 384 CONTENTS 10.10Exercise: Explain Filter Performance 385 10.10.1 Solution 385 10.11Implementation of the UKF 387 10.11.1 Weights 388 10.11.2 Sigma Points 388 10.11.3 Predict Step 390 10.11.4 Update Step 390 10.11.5 FilterPy's Implementation ..391 10.12 Batch Processing 39 10.13Smoothing the Results 394 10. 15Robot Localization- A Fully Worked Example 10. Choosing the sigma parameters 396 ,,397 10.15.1 Robot motion model 398 10. 15.2 Design the State variables .399 10.15.3 Design the System Model 399 10. 15.4 Design the Measurement Model 400 10.15.5 Design Measurement noise 400 10. 15.6 Implementation 400 10.15.7 Steering the Robot 405 10.16 Discussion 407 10.17 References 408 11 The Extended Kalman Filter 409 11.1 Linearizing the Kalman Filter 11.2 Example: Tracking a Airplane 411 11.2.1 Design the State Variables 412 11.2.2 Design the Process Model 412 11.2.3 Design the Measurement Model 413 11.2.4 Design Process and Measurement Noise 415 11.2.5 Implementation ,,,,,,,415 11.3 Using SymPy to compute Jacobians ...418 11.4 Robot localization .418 11.4.1 Robot motion mode 419 11.4.2 Design the State Variables 420 11.4.3 Design the System Model 420 11.4.4 Design the Measurement Model 422 11.4.5 Design Measurement noise ,,,,,,.423 11.4.6 Implementation 11. 4.7 Discussion .· 431 11.5 UKF VS EKF 431 12 Particle filters 435 12.1 Motivation 435 12.2 Monte Carlo Sampling 436 12.3 Generic Particle Filter Algorithm ...437 12.4 Probability distributions via Monte Carlo 438 12.5 The Particle Filter 12.5.1 Predict Step 442 12.5.2 Update Ste 43 12.5.3 Computing the State Estimate 444 12.5.4 Particle Resampling 444 12.6 SIR Filter-A Complete Exampl le 445 12.6.1 Effect of Sensor Errors on the Filter ,,,449 12.6.2 Filter Degeneracy From Inadequate Samples 450 CONTENTS 12.7 Importance Sampling 451 12.8 Resampling Methods 453 12.8. 1 Multinomial Resampling 453 12.8.2 Residual Resampling .454 12.8.3 Stratified Resampling .455 12.8.4 Systematic Resampling 456 12.8.5 Choosing a Resampling Algorithm 457 2.9 Summa ..458 12. 10References 459 13 Smoothin 461 13.1 Introduction 461 13.2 An Overview of How Smoothers work 464 13.3 Types of Smoothers 464 3.4 Choice of filters 垂着垂 .464 3.5 Fixed-Interval Smoothing 465 13.6 Fixed-Lag Smoothing 469 13.7 References 472 14 Adaptive Filtering 473 14.1 Introduction 473 14.2 Maneuvering targets 473 14.3 Detecting a Maneuver 481 14.4 Adjustable Process noise 483 14.4.1 Continuous Adjustment 483 14.4.2 Continuous Adjustment-Standard Deviation Version .486 14.5 Fading Memory Filter 着垂 493 14.6 Multiple model estimation 496 14.6.1 A Two Filter Adaptive Filter 49 147 MMAE 500 14.7.1 Limitations of the mmae filter 502 14.8 Interacting Multiple Models(IMM) 503 14.8.1 Mode probabilities ,..,...503 14.8.2 Mode Transitions 504 14.8.3 Computing the mode probabilities 505 14.9 Mixing Probabilities 506 14.9.1 IMM Estimate 507 14.9.2 Tracking Maneuvering Target with the IMM 507 14.10s 510 14.11 References ..,,,,,.511 A Installation 513 A 1 Installing the SciPy Stack 513 A2 Installin g Filter 514 A 3 Downloading and Running the Book 514 A4 Companion Software .515 A.5 Using Jupiter Notebook g 515 A6 SymP 515 A 7 Various Links 517 CONTENTS B Symbols and Notations 519 B. 1 Labbe 519 B 2 Wikipedia ...... ...519 B 3 Brookner .519 B 4 Gelb 520 B5 Brown .520 B 6 Zarchan 520 C H Infinity filter 521 D Ensemble Kalman Filters 523 D.1 The Algorithm 524 D 1.1 Initialize Step .525 D.1.2 Predict Step 525 D.1.3 Update Step 526 D 2 Implementation and Example .....527 D 3 Outstanding Questions .529 D,4 References 530 【实例截图】
【核心代码】

标签:

实例下载地址

Kalman and Bayesian Filters in Python

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警