SlideShare a Scribd company logo
1 of 30
Download to read offline
Kalman Filter
for Beginners
Winfred LU
What is a Kalman Filter
β€’ A Kalman filter is an optimal recursive
estimator
– If all noise is Gaussian, the Kalman filter minimizes
the mean square error of the estimated
parameters.
β€’ Versatile
– Estimation
– Filtering
– Prediction
– Fusion
Predict Correct
Why Kalman Filtering
β€’ Efficient β€œleast-squares” implementation
β€’ Past, present and future estimation
β€’ Estimation of missing states
β€’ Measure of estimation quality (variance)
β€’ Robust
– Forgiving in many ways
– Stable given common conditions
β€’ Convenient form for online real time processing.
– Easy to formulate and implement given a basic
understanding.
The Process Model
β€’ Process Dynamics
𝒙 π’Œ = 𝑨𝒙 π’Œβˆ’πŸ + π’˜ π’Œβˆ’πŸ
β€’ Measurement
𝒛 π’Œ = 𝑯𝒙 π’Œ + 𝒗 π’Œ
next state
measurement
previous state
measurement
noise
process
noise
state
dynamic model
measurement model
Simple Example: Airplane Altitude
β€’ Model
𝒙 π’Œ = 𝑨𝒙 π’Œβˆ’πŸ + π’˜ π’Œβˆ’πŸ
π‘Žπ‘™π‘‘π‘–π‘‘π‘’π‘‘π‘’ π‘π‘’π‘Ÿπ‘Ÿπ‘’π‘›π‘‘_π‘‘π‘–π‘šπ‘’
= 0.98 βˆ— π‘Žπ‘™π‘‘π‘–π‘‘π‘’π‘‘π‘’ π‘π‘Ÿπ‘’π‘£π‘–π‘œπ‘’π‘ _π‘‘π‘–π‘šπ‘’ + π‘‘π‘’π‘Ÿπ‘π‘’π‘™π‘’π‘›π‘π‘’ π‘π‘Ÿπ‘’π‘£π‘–π‘œπ‘’π‘ π‘‘π‘–π‘šπ‘’
𝒛 π’Œ = 𝒙 π’Œ + 𝒗 π’Œ
π‘šπ‘’π‘Žπ‘ π‘’π‘Ÿπ‘’π‘‘_π‘Žπ‘™π‘‘π‘–π‘‘π‘’π‘‘π‘’ π‘π‘’π‘Ÿπ‘Ÿπ‘’π‘›π‘‘_π‘‘π‘–π‘šπ‘’
= π‘Žπ‘™π‘‘π‘–π‘‘π‘’π‘‘π‘’ π‘π‘’π‘Ÿπ‘Ÿπ‘’π‘›π‘‘_π‘‘π‘–π‘šπ‘’ + π‘›π‘œπ‘–π‘ π‘’ π‘π‘’π‘Ÿπ‘Ÿπ‘’π‘›π‘‘_π‘‘π‘–π‘šπ‘’
State Estimation (Predict)
β€’ Rewrite the measurement equation into
π‘₯ π‘˜ = 𝑧 π‘˜ βˆ’ 𝑣 π‘˜
– Problem: the current noise is unpredictable
β€’ Estimate the state by taking into account both
the current measurement and the previous
estimated state
οΏ½Μ‚ π‘˜ = οΏ½Μ‚ π‘˜βˆ’1 + πΎπ‘˜(𝑧 π‘˜ βˆ’ οΏ½Μ‚ π‘˜βˆ’1)
– οΏ½Μ‚ : the hat means it is estimated
– πΎπ‘˜ is a gain expressing the tradeoff
οΏ½Μ‚ π‘˜ = πΎπ‘˜ 𝑧 π‘˜ + (1 βˆ’ πΎπ‘˜)οΏ½Μ‚ π‘˜βˆ’1
Computing the Gain
β€’ Recall the measurement associated with a noise
π‘₯ π‘˜ = 𝑧 π‘˜ βˆ’ 𝑣 π‘˜
– we don’t know the individual noise for an
measurement, but we typically know the average
noise, call it π‘Ÿ
πΎπ‘˜ = 𝑝 π‘˜βˆ’1/(𝑝 π‘˜βˆ’1 + π‘Ÿ)
β€’ π‘Ÿ has no subscript; it doesn’t depend on time
β€’ where 𝑝 π‘˜ is a prediction error that is computed recursively
π‘ƒπ‘˜ = (1 βˆ’ πΎπ‘˜) 𝑝 π‘˜βˆ’1
β€’ think about the cases:
– π‘ƒπ‘˜βˆ’1 previous prediction error was 0
– if there is very little noise, π‘Ÿ is 0
– when the system is noisy, π‘Ÿ becomes large
The Prediction and Correction
β€’ Consider the state equation
π‘₯ π‘˜ = 𝐴π‘₯ π‘˜βˆ’1
– It seems to have vanished in the equation
οΏ½Μ‚ π‘˜ = οΏ½Μ‚ π‘˜βˆ’1 + πΎπ‘˜(𝑧 π‘˜ βˆ’ οΏ½Μ‚ π‘˜βˆ’1)
β€’ we need both
β€’ first equation represents a prediction about what the state should
be, and the second equation represents an correction to this
prediction, based on an observation
β€’ Rewrite it
οΏ½Μ‚ π‘˜ = 𝐴�̂ π‘˜βˆ’1
β€’ We use the constant in 𝐴 a prediction of the error too
𝑝 π‘˜ = 𝐴𝑝 π‘˜βˆ’1 𝐴
– we multiply twice by 𝐴 because the prediction error 𝑝 π‘˜ is
itself a squared error; hence, it is scaled by the square of
the coefficient associated with the state value π‘₯ π‘˜
Kalman Filter Equations
β€’ Time Update (Predict)
οΏ½Μ‚ π‘˜ = 𝐴�̂ π‘˜βˆ’1
𝑝 π‘˜ = 𝐴𝑝 π‘˜βˆ’1 𝐴
β€’ Measurement Update (Correct)
πΎπ‘˜ = 𝑝 π‘˜βˆ’1/(𝑝 π‘˜βˆ’1 + π‘Ÿ)
οΏ½Μ‚ π‘˜ = οΏ½Μ‚ π‘˜βˆ’1 + πΎπ‘˜(𝑧 π‘˜ βˆ’ οΏ½Μ‚ π‘˜βˆ’1)
π‘ƒπ‘˜ = (1 βˆ’ πΎπ‘˜) 𝑝 π‘˜βˆ’1
Predict Correct
Simple Run
π’Œ 0 1 2 3 4 5 6 7 8 9
π‘₯ π‘˜ 1000 800 640 512 409.6 327.7 262.1 209.7 167.8 134.2
𝑧 π‘˜ 908.3 689.7 833 338.8 596.5 350 340.3 152.5 363.9 236.1
𝑝 π‘˜ 1
οΏ½Μ‚ π‘˜ 908.3
𝑔 π‘˜
π‘₯0 = 1000
r = 200
a = 0.8
𝑧 π‘˜ = [1000*0.8**i + x
for i,x in enumerate(rnd_u(-200,200,10))]
Predict:
οΏ½Μ‚ π‘˜ = π‘ŽοΏ½Μ‚ π‘˜βˆ’1
𝑝 π‘˜ = π‘Žπ‘ π‘˜βˆ’1 π‘Ž
Update:
οΏ½Μ‚ π‘˜ = 𝑝 π‘˜/(𝑝 π‘˜ + π‘Ÿ)
οΏ½Μ‚ π‘˜ = οΏ½Μ‚ π‘˜ + 𝑔 π‘˜(𝑧 π‘˜ βˆ’ οΏ½Μ‚ π‘˜)
𝑝 π‘˜ = (1 βˆ’ 𝑔 π‘˜)𝑝 π‘˜
Simple Run
π’Œ 0 1 2 3 4 5 6 7 8 9
π‘₯ π‘˜ 1000 800 640 512 409.6 327.7 262.1 209.7 167.8 134.2
𝑧 π‘˜ 908.3 689.7 833 338.8 596.5 350 340.3 152.5 363.9 236.1
𝑝 π‘˜ 1 0.63 0.41 0.26 0.17 0.11 0.07 0.04 0.02 0.01
οΏ½Μ‚ π‘˜ 908.3 726.5 581.7 465.2 372.4 297.9 238.4 190.7 152.6 122.1
𝑔 π‘˜ 0.003 0.002 0.001 0.001 0.000 0.000 0.000 0.000 0.000
A More Realistic Model
β€’ Account for the time-varying control that the
pilot exercises over the airplane
– for example, moving the control column forward and
back
οΏ½Μ‚ π‘˜+1 = 𝐴�̂ π‘˜ + 𝐡𝑒 π‘˜
– 𝑒 π‘˜ represents the current value of the control signal
that the pilot is sending to the airplane
– this control signal can be scaled by a constant amount
B
β€’ Measurement
𝑧 π‘˜ = 𝐻π‘₯ π‘˜ + 𝑣 π‘˜
Kalman Filter Equations
β€’ Time Update (Predict)
οΏ½Μ‚ π‘˜ = 𝐴�̂ π‘˜βˆ’1 + 𝐡𝑒 π‘˜
𝑝 π‘˜ = 𝐴𝑝 π‘˜βˆ’1 𝐴
β€’ Measurement Update (Correct)
πΎπ‘˜ = 𝑝 π‘˜βˆ’1 𝐻/(𝐻𝑝 π‘˜βˆ’1 𝐻 + π‘Ÿ)
οΏ½Μ‚ π‘˜ = οΏ½Μ‚ π‘˜βˆ’1 + πΎπ‘˜(𝑧 π‘˜ βˆ’ 𝐻�̂ π‘˜βˆ’1)
π‘ƒπ‘˜ = (1 βˆ’ πΎπ‘˜ 𝐻) 𝑝 π‘˜βˆ’1
Predict Correct
Adding Velocity to the System
β€’ For the state equation
οΏ½Μ‚ π‘˜ = 𝐴�̂ π‘˜βˆ’1
– Considering equation expressing distance in terms
of velocity and time
π‘‘π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’ π‘π‘’π‘Ÿπ‘Ÿπ‘’π‘›π‘‘
= π‘‘π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’ π‘π‘Ÿπ‘’π‘£π‘–π‘œπ‘’π‘  + π‘£π‘’π‘™π‘œπ‘π‘–π‘‘π‘¦ π‘π‘Ÿπ‘’π‘£π‘–π‘œπ‘’π‘  βˆ— π‘‘π‘–π‘šπ‘’π‘ π‘‘π‘’π‘
– vectors are used
π‘₯ π‘˜ ≑
π‘‘π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’ π‘˜
π‘£π‘’π‘™π‘œπ‘π‘–π‘‘π‘¦ π‘˜
𝐴 =
1 π‘‘π‘–π‘šπ‘’π‘ π‘‘π‘’π‘
0 1
β€’ So
π‘‘π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’ π‘˜
π‘£π‘’π‘™π‘œπ‘π‘–π‘‘π‘¦ π‘˜
=
1 π‘‘π‘–π‘šπ‘’π‘ π‘‘π‘’π‘
0 1
π‘‘π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’ π‘˜βˆ’1
π‘£π‘’π‘™π‘œπ‘π‘–π‘‘π‘¦ π‘˜βˆ’1
Discrete Kalman Filter
β€’ Trying to estimate the state π‘₯ ∈ β„› 𝑛
of a discrete-
time controlled process that is governed by the
linear stochastic difference equation
π‘₯ π‘˜ = 𝐴π‘₯ π‘˜βˆ’1 + 𝐡𝑒 π‘˜ + 𝑀 π‘˜βˆ’1
β€’ with a measurement 𝑧 ∈ β„› π‘š
that is
𝑧 π‘˜ = 𝐻π‘₯ π‘˜ + 𝑣 π‘˜
β€’ Random variables w and v represent process and
measurement noise, which normal probability
distributions
𝑝 𝑀 ~ 𝑁 0, 𝑄
𝑝 𝑣 ~ 𝑁(0, 𝑅)
Process Dynamics
𝒙 π’Œ+𝟏 = 𝑨𝒙 π’Œ + π’˜ π’Œ
state vector
π‘₯ π‘˜ ∈ β„› 𝑛
contains the states of the process
Process Dynamics
𝒙 π’Œ+𝟏 = 𝑨𝒙 π’Œ + π’˜ π’Œ
state transition matrix
𝑛π‘₯𝑛 matrix 𝐴 relates state at time step π‘˜ to time
step π‘˜ + 1
Process Dynamics
𝒙 π’Œ+𝟏 = 𝑨𝒙 π’Œ + π’˜ π’Œ
process noise
𝑀 π‘˜ ∈ β„› 𝑛
models the uncertainty of the process
𝑝 𝑀 π‘˜ ~ 𝑁 0, 𝑄
Measurement
𝒛 π’Œ = 𝑯𝒙 π’Œ + 𝒗 π’Œ
measurement vector
𝑧 π‘˜ ∈ β„› π‘š
is the process measurement
Measurement
𝒛 π’Œ = 𝑯𝒙 π’Œ + 𝒗 π’Œ
state vector
π‘₯ π‘˜ ∈ β„› 𝑛
contains the states of the process
Measurement
𝒛 π’Œ = 𝑯𝒙 π’Œ + 𝒗 π’Œ
measurement matrix
π‘šπ‘₯𝑛 matrix 𝐻 relates state to measurement
Measurement
𝒛 π’Œ = 𝑯𝒙 π’Œ + 𝒗 π’Œ
measurement noise
𝑣 π‘˜ ∈ β„› π‘š
models the uncertainty of the process
𝑝 𝑣 π‘˜ ~ 𝑁 0, 𝑅
Estimate Covariances
a priori estimate error covariance
π‘ƒπ‘˜
βˆ’
= 𝐸[(π‘₯ π‘˜ βˆ’ οΏ½Μ‚ π‘˜
βˆ’
)(π‘₯ π‘˜ βˆ’ οΏ½Μ‚ π‘˜
βˆ’
) 𝑇
]
a posteriori estimate error covariance
π‘ƒπ‘˜ = 𝐸[(π‘₯ π‘˜ βˆ’ οΏ½Μ‚ π‘˜)(π‘₯ π‘˜ βˆ’ οΏ½Μ‚ π‘˜) 𝑇
]
– define a priori estimate errors as
β€’ 𝑒 π‘˜
βˆ’ ≑ π‘₯ π‘˜ βˆ’ π‘₯ π‘˜
βˆ’
β€’ 𝑒 π‘˜ ≑ π‘₯ π‘˜ βˆ’ οΏ½Μ‚ π‘˜
– error covariance is then
β€’ π‘ƒπ‘˜
βˆ’
≑ 𝐸[𝑒 π‘˜
βˆ’ 𝑒 π‘˜
βˆ’π‘‡]
β€’ π‘ƒπ‘˜ ≑ 𝐸[𝑒 π‘˜ 𝑒 𝑇
π‘˜]
Chosen Kalman Gain
π‘ƒπ‘˜ = 𝐸 π‘₯ π‘˜ βˆ’ ොπ‘₯ π‘˜ π‘₯ π‘˜ βˆ’ ොπ‘₯ π‘˜
𝑇
(1)
οΏ½Μ‚ π‘˜ = οΏ½Μ‚ π‘˜
βˆ’
+ πΎπ‘˜ 𝑧 π‘˜ βˆ’ 𝐻 ොπ‘₯ π‘˜
βˆ’
(2)
β€’ The nxm matrix K in equation (2) is chosen to be
the factor that minimizes the a posteriori error
covariance equation (1)
– It can be accomplished by first substituting equation
(2) into the above definition for 𝑒 π‘˜, substituting that
into equation (1), performing the indicated
expectations, taking the derivative of the trace of the
result with respect to K, setting that result equal to
zero, and then solving for K.
– Maybeck 1979; Jacobs 1993; Brown and Hwang 1996
πΎπ‘˜ = π‘ƒπ‘˜
βˆ’
𝐻 𝑇
(π»π‘ƒπ‘˜
βˆ’
𝐻 𝑇
+ 𝑅)βˆ’1
The Update iterations
β€’ Time Update (Predict)
1. state and covariance prediction
β€’ Measurement Update (Correct)
2. Kalman gain correction and state correction
3. covariance correction
Predict Correct
Kalman Filter Equations
β€’ Time Update (Predict)
1. state and covariance prediction
οΏ½Μ‚ π‘˜
βˆ’
= 𝐴π‘₯ π‘˜βˆ’1
π‘ƒπ‘˜
βˆ’
= π΄π‘ƒπ‘˜βˆ’1 𝐴 𝑇
+ 𝑄
β€’ Measurement Update (Correct)
2. Kalman gain correction and state correction
πΎπ‘˜ = π‘ƒπ‘˜
βˆ’
𝐻 𝑇
(π»π‘ƒπ‘˜
βˆ’
𝐻 𝑇
+ 𝑅)βˆ’1
οΏ½Μ‚ π‘˜ = οΏ½Μ‚ π‘˜
βˆ’
+ πΎπ‘˜ 𝑧 π‘˜ βˆ’ 𝐻ොπ‘₯ π‘˜
βˆ’
3. covariance correction
π‘ƒπ‘˜ = (𝐼 βˆ’ πΎπ‘˜ 𝐻)π‘ƒπ‘˜
βˆ’
Source Code
β€’ C#
– KalmanDemo
β€’ Python
– pykalman: the dead-simple Kalman Filter, Kalman
Smotther, and EM library
β€’ ANSI C
– recovery of motion and 3D structure from a
sequence of images
DEMO
Variations of the Filter
β€’ Discrete-Discrete
β€’ Continuous-Discrete
β€’ Extended Kalman Filter
β€’ TBC
References
β€’ Kalman, R. E. 1960. β€œA New Approach to Linear Filtering
and Prediction Problems”, Transaction of the ASME –
Journal of Basic Engineering, March 1960
β€’ Greg Welch, Gary Bishop, "An Introduction to the
Kalman Filter", University of North Carolina at Chapel
Hill Department of Computer Science, 2001
β€’ Lindsay Kleeman, "Understanding and Applying Kalman
Filtering", Department of Electrical and Computer
Systems Engineering
β€’ Simon D. Levy, β€œKalman Filter Interactive Tutorial”
β€’ M.S.Grewal, A.P. Andrews, "Kalman Filtering - Theory
and Practice Using MATLAB", Wiley, 2001
β€’ MIT Video Lecture on the Kalman filter, YouTube
β€’ Kalman filter, Wikipedia

More Related Content

What's hot

The extended kalman filter
The extended kalman filterThe extended kalman filter
The extended kalman filterMudit Parnami
Β 
Kalman Filtering
Kalman FilteringKalman Filtering
Kalman FilteringEngin Gul
Β 
Seminar On Kalman Filter And Its Applications
Seminar On  Kalman  Filter And Its ApplicationsSeminar On  Kalman  Filter And Its Applications
Seminar On Kalman Filter And Its ApplicationsBarnali Dey
Β 
Dcs lec03 - z-analysis of discrete time control systems
Dcs   lec03 - z-analysis of discrete time control systemsDcs   lec03 - z-analysis of discrete time control systems
Dcs lec03 - z-analysis of discrete time control systemsAmr E. Mohamed
Β 
Filter- IIR - Digital signal processing(DSP)
Filter- IIR - Digital signal processing(DSP)Filter- IIR - Digital signal processing(DSP)
Filter- IIR - Digital signal processing(DSP)tamil arasan
Β 
Kalman filtering and it's applications
Kalman filtering and it's applicationsKalman filtering and it's applications
Kalman filtering and it's applicationsMADHAVASAIYENDUVA
Β 
Application of adaptive linear equalizer
Application of adaptive linear equalizerApplication of adaptive linear equalizer
Application of adaptive linear equalizerSayahnarahul
Β 
State space analysis shortcut rules, control systems,
State space analysis shortcut rules, control systems, State space analysis shortcut rules, control systems,
State space analysis shortcut rules, control systems, Prajakta Pardeshi
Β 
Kalman Filter and its Application
Kalman Filter and its ApplicationKalman Filter and its Application
Kalman Filter and its ApplicationSaptarshi Mazumdar
Β 
Data fusion with kalman filtering
Data fusion with kalman filteringData fusion with kalman filtering
Data fusion with kalman filteringantoniomorancardenas
Β 
Lecture 23 24-time_response
Lecture 23 24-time_responseLecture 23 24-time_response
Lecture 23 24-time_responseSyed Ali Raza Rizvi
Β 
Lecture Notes on Adaptive Signal Processing-1.pdf
Lecture Notes on Adaptive Signal Processing-1.pdfLecture Notes on Adaptive Signal Processing-1.pdf
Lecture Notes on Adaptive Signal Processing-1.pdfVishalPusadkar1
Β 
Report kalman filtering
Report kalman filteringReport kalman filtering
Report kalman filteringIrfan Anjum
Β 
Production system in ai
Production system in aiProduction system in ai
Production system in aisabin kafle
Β 

What's hot (20)

kalman filtering "From Basics to unscented Kaman filter"
 kalman filtering "From Basics to unscented Kaman filter" kalman filtering "From Basics to unscented Kaman filter"
kalman filtering "From Basics to unscented Kaman filter"
Β 
Kalman filters
Kalman filtersKalman filters
Kalman filters
Β 
The extended kalman filter
The extended kalman filterThe extended kalman filter
The extended kalman filter
Β 
Kalman filter
Kalman filterKalman filter
Kalman filter
Β 
Kalman Filtering
Kalman FilteringKalman Filtering
Kalman Filtering
Β 
Kalmanfilter
Kalmanfilter Kalmanfilter
Kalmanfilter
Β 
Seminar On Kalman Filter And Its Applications
Seminar On  Kalman  Filter And Its ApplicationsSeminar On  Kalman  Filter And Its Applications
Seminar On Kalman Filter And Its Applications
Β 
Dcs lec03 - z-analysis of discrete time control systems
Dcs   lec03 - z-analysis of discrete time control systemsDcs   lec03 - z-analysis of discrete time control systems
Dcs lec03 - z-analysis of discrete time control systems
Β 
Filter- IIR - Digital signal processing(DSP)
Filter- IIR - Digital signal processing(DSP)Filter- IIR - Digital signal processing(DSP)
Filter- IIR - Digital signal processing(DSP)
Β 
Kalman filtering and it's applications
Kalman filtering and it's applicationsKalman filtering and it's applications
Kalman filtering and it's applications
Β 
Impulse Response ppt
Impulse Response pptImpulse Response ppt
Impulse Response ppt
Β 
Digital Communication - Stochastic Process
Digital Communication - Stochastic ProcessDigital Communication - Stochastic Process
Digital Communication - Stochastic Process
Β 
Application of adaptive linear equalizer
Application of adaptive linear equalizerApplication of adaptive linear equalizer
Application of adaptive linear equalizer
Β 
State space analysis shortcut rules, control systems,
State space analysis shortcut rules, control systems, State space analysis shortcut rules, control systems,
State space analysis shortcut rules, control systems,
Β 
Kalman Filter and its Application
Kalman Filter and its ApplicationKalman Filter and its Application
Kalman Filter and its Application
Β 
Data fusion with kalman filtering
Data fusion with kalman filteringData fusion with kalman filtering
Data fusion with kalman filtering
Β 
Lecture 23 24-time_response
Lecture 23 24-time_responseLecture 23 24-time_response
Lecture 23 24-time_response
Β 
Lecture Notes on Adaptive Signal Processing-1.pdf
Lecture Notes on Adaptive Signal Processing-1.pdfLecture Notes on Adaptive Signal Processing-1.pdf
Lecture Notes on Adaptive Signal Processing-1.pdf
Β 
Report kalman filtering
Report kalman filteringReport kalman filtering
Report kalman filtering
Β 
Production system in ai
Production system in aiProduction system in ai
Production system in ai
Β 

Similar to KF Guide for Beginners

lecture_18-19_state_observer_design.pptx
lecture_18-19_state_observer_design.pptxlecture_18-19_state_observer_design.pptx
lecture_18-19_state_observer_design.pptxAnshulShekhar3
Β 
Reinforcement Learning basics part1
Reinforcement Learning basics part1Reinforcement Learning basics part1
Reinforcement Learning basics part1Euijin Jeong
Β 
Intro to Quant Trading Strategies (Lecture 6 of 10)
Intro to Quant Trading Strategies (Lecture 6 of 10)Intro to Quant Trading Strategies (Lecture 6 of 10)
Intro to Quant Trading Strategies (Lecture 6 of 10)Adrian Aley
Β 
Kalman filter demonstration
Kalman filter demonstrationKalman filter demonstration
Kalman filter demonstrationAhmed Yahia Kallel
Β 
Time series Modelling Basics
Time series Modelling BasicsTime series Modelling Basics
Time series Modelling BasicsAshutosh Kumar
Β 
Stochastic optimal control & rl
Stochastic optimal control & rlStochastic optimal control & rl
Stochastic optimal control & rlChoiJinwon3
Β 
Vehicle Routing Problem using PSO (Particle Swarm Optimization)
Vehicle Routing Problem using PSO (Particle Swarm Optimization)Vehicle Routing Problem using PSO (Particle Swarm Optimization)
Vehicle Routing Problem using PSO (Particle Swarm Optimization)Niharika Varshney
Β 
Solving Poisson Equation using Conjugate Gradient Method and its implementation
Solving Poisson Equation using Conjugate Gradient Methodand its implementationSolving Poisson Equation using Conjugate Gradient Methodand its implementation
Solving Poisson Equation using Conjugate Gradient Method and its implementationJongsu "Liam" Kim
Β 
Time Response in Control System
Time Response in Control SystemTime Response in Control System
Time Response in Control SystemAnshulShekhar3
Β 
EEE 411 power system stability analysis .pptx
EEE 411 power system stability analysis .pptxEEE 411 power system stability analysis .pptx
EEE 411 power system stability analysis .pptxShoilieChakma
Β 
lecture 1 courseII (2).pptx
lecture 1 courseII (2).pptxlecture 1 courseII (2).pptx
lecture 1 courseII (2).pptxAYMENGOODKid
Β 
Slideshare
SlideshareSlideshare
SlideshareMohit Yadav
Β 
Machine Learning - Reinforcement Learning
Machine Learning - Reinforcement LearningMachine Learning - Reinforcement Learning
Machine Learning - Reinforcement LearningJY Chun
Β 
Passivity-based control of rigid-body manipulator
Passivity-based control of rigid-body manipulatorPassivity-based control of rigid-body manipulator
Passivity-based control of rigid-body manipulatorHancheol Choi
Β 
control_5.pptx
control_5.pptxcontrol_5.pptx
control_5.pptxewnetukassa2
Β 
Lecture 5 backpropagation
Lecture 5 backpropagationLecture 5 backpropagation
Lecture 5 backpropagationParveenMalik18
Β 

Similar to KF Guide for Beginners (20)

lecture_18-19_state_observer_design.pptx
lecture_18-19_state_observer_design.pptxlecture_18-19_state_observer_design.pptx
lecture_18-19_state_observer_design.pptx
Β 
Reinforcement Learning basics part1
Reinforcement Learning basics part1Reinforcement Learning basics part1
Reinforcement Learning basics part1
Β 
Intro to Quant Trading Strategies (Lecture 6 of 10)
Intro to Quant Trading Strategies (Lecture 6 of 10)Intro to Quant Trading Strategies (Lecture 6 of 10)
Intro to Quant Trading Strategies (Lecture 6 of 10)
Β 
Av 738-Adaptive Filters - Extended Kalman Filter
Av 738-Adaptive Filters - Extended Kalman FilterAv 738-Adaptive Filters - Extended Kalman Filter
Av 738-Adaptive Filters - Extended Kalman Filter
Β 
Kalman filter demonstration
Kalman filter demonstrationKalman filter demonstration
Kalman filter demonstration
Β 
Time series Modelling Basics
Time series Modelling BasicsTime series Modelling Basics
Time series Modelling Basics
Β 
Stochastic optimal control & rl
Stochastic optimal control & rlStochastic optimal control & rl
Stochastic optimal control & rl
Β 
Av 738- Adaptive Filtering - Background Material
Av 738- Adaptive Filtering - Background MaterialAv 738- Adaptive Filtering - Background Material
Av 738- Adaptive Filtering - Background Material
Β 
Av 738- Adaptive Filtering - Wiener Filters[wk 3]
Av 738- Adaptive Filtering - Wiener Filters[wk 3]Av 738- Adaptive Filtering - Wiener Filters[wk 3]
Av 738- Adaptive Filtering - Wiener Filters[wk 3]
Β 
Vehicle Routing Problem using PSO (Particle Swarm Optimization)
Vehicle Routing Problem using PSO (Particle Swarm Optimization)Vehicle Routing Problem using PSO (Particle Swarm Optimization)
Vehicle Routing Problem using PSO (Particle Swarm Optimization)
Β 
Solving Poisson Equation using Conjugate Gradient Method and its implementation
Solving Poisson Equation using Conjugate Gradient Methodand its implementationSolving Poisson Equation using Conjugate Gradient Methodand its implementation
Solving Poisson Equation using Conjugate Gradient Method and its implementation
Β 
Time Response in Control System
Time Response in Control SystemTime Response in Control System
Time Response in Control System
Β 
EEE 411 power system stability analysis .pptx
EEE 411 power system stability analysis .pptxEEE 411 power system stability analysis .pptx
EEE 411 power system stability analysis .pptx
Β 
lecture 1 courseII (2).pptx
lecture 1 courseII (2).pptxlecture 1 courseII (2).pptx
lecture 1 courseII (2).pptx
Β 
Slideshare
SlideshareSlideshare
Slideshare
Β 
Kalman Filter Basic
Kalman Filter BasicKalman Filter Basic
Kalman Filter Basic
Β 
Machine Learning - Reinforcement Learning
Machine Learning - Reinforcement LearningMachine Learning - Reinforcement Learning
Machine Learning - Reinforcement Learning
Β 
Passivity-based control of rigid-body manipulator
Passivity-based control of rigid-body manipulatorPassivity-based control of rigid-body manipulator
Passivity-based control of rigid-body manipulator
Β 
control_5.pptx
control_5.pptxcontrol_5.pptx
control_5.pptx
Β 
Lecture 5 backpropagation
Lecture 5 backpropagationLecture 5 backpropagation
Lecture 5 backpropagation
Β 

Recently uploaded

Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
Β 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
Β 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture designssuser87fa0c1
Β 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
Β 
πŸ”9953056974πŸ”!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
πŸ”9953056974πŸ”!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...πŸ”9953056974πŸ”!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
πŸ”9953056974πŸ”!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...9953056974 Low Rate Call Girls In Saket, Delhi NCR
Β 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
Β 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
Β 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
Β 
Gurgaon ✑️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✑️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✑️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✑️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
Β 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
Β 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
Β 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
Β 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
Β 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
Β 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
Β 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoΓ£o Esperancinha
Β 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
Β 

Recently uploaded (20)

young call girls in Green ParkπŸ” 9953056974 πŸ” escort Service
young call girls in Green ParkπŸ” 9953056974 πŸ” escort Serviceyoung call girls in Green ParkπŸ” 9953056974 πŸ” escort Service
young call girls in Green ParkπŸ” 9953056974 πŸ” escort Service
Β 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
Β 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
Β 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture design
Β 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Β 
πŸ”9953056974πŸ”!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
πŸ”9953056974πŸ”!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...πŸ”9953056974πŸ”!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
πŸ”9953056974πŸ”!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
Β 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
Β 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
Β 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
Β 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
Β 
Gurgaon ✑️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✑️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✑️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✑️9711147426✨Call In girls Gurgaon Sector 51 escort service
Β 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
Β 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
Β 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
Β 
young call girls in Rajiv ChowkπŸ” 9953056974 πŸ” Delhi escort Service
young call girls in Rajiv ChowkπŸ” 9953056974 πŸ” Delhi escort Serviceyoung call girls in Rajiv ChowkπŸ” 9953056974 πŸ” Delhi escort Service
young call girls in Rajiv ChowkπŸ” 9953056974 πŸ” Delhi escort Service
Β 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
Β 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
Β 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
Β 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Β 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
Β 

KF Guide for Beginners

  • 2. What is a Kalman Filter β€’ A Kalman filter is an optimal recursive estimator – If all noise is Gaussian, the Kalman filter minimizes the mean square error of the estimated parameters. β€’ Versatile – Estimation – Filtering – Prediction – Fusion Predict Correct
  • 3. Why Kalman Filtering β€’ Efficient β€œleast-squares” implementation β€’ Past, present and future estimation β€’ Estimation of missing states β€’ Measure of estimation quality (variance) β€’ Robust – Forgiving in many ways – Stable given common conditions β€’ Convenient form for online real time processing. – Easy to formulate and implement given a basic understanding.
  • 4. The Process Model β€’ Process Dynamics 𝒙 π’Œ = 𝑨𝒙 π’Œβˆ’πŸ + π’˜ π’Œβˆ’πŸ β€’ Measurement 𝒛 π’Œ = 𝑯𝒙 π’Œ + 𝒗 π’Œ next state measurement previous state measurement noise process noise state dynamic model measurement model
  • 5. Simple Example: Airplane Altitude β€’ Model 𝒙 π’Œ = 𝑨𝒙 π’Œβˆ’πŸ + π’˜ π’Œβˆ’πŸ π‘Žπ‘™π‘‘π‘–π‘‘π‘’π‘‘π‘’ π‘π‘’π‘Ÿπ‘Ÿπ‘’π‘›π‘‘_π‘‘π‘–π‘šπ‘’ = 0.98 βˆ— π‘Žπ‘™π‘‘π‘–π‘‘π‘’π‘‘π‘’ π‘π‘Ÿπ‘’π‘£π‘–π‘œπ‘’π‘ _π‘‘π‘–π‘šπ‘’ + π‘‘π‘’π‘Ÿπ‘π‘’π‘™π‘’π‘›π‘π‘’ π‘π‘Ÿπ‘’π‘£π‘–π‘œπ‘’π‘ π‘‘π‘–π‘šπ‘’ 𝒛 π’Œ = 𝒙 π’Œ + 𝒗 π’Œ π‘šπ‘’π‘Žπ‘ π‘’π‘Ÿπ‘’π‘‘_π‘Žπ‘™π‘‘π‘–π‘‘π‘’π‘‘π‘’ π‘π‘’π‘Ÿπ‘Ÿπ‘’π‘›π‘‘_π‘‘π‘–π‘šπ‘’ = π‘Žπ‘™π‘‘π‘–π‘‘π‘’π‘‘π‘’ π‘π‘’π‘Ÿπ‘Ÿπ‘’π‘›π‘‘_π‘‘π‘–π‘šπ‘’ + π‘›π‘œπ‘–π‘ π‘’ π‘π‘’π‘Ÿπ‘Ÿπ‘’π‘›π‘‘_π‘‘π‘–π‘šπ‘’
  • 6. State Estimation (Predict) β€’ Rewrite the measurement equation into π‘₯ π‘˜ = 𝑧 π‘˜ βˆ’ 𝑣 π‘˜ – Problem: the current noise is unpredictable β€’ Estimate the state by taking into account both the current measurement and the previous estimated state οΏ½Μ‚ π‘˜ = οΏ½Μ‚ π‘˜βˆ’1 + πΎπ‘˜(𝑧 π‘˜ βˆ’ οΏ½Μ‚ π‘˜βˆ’1) – οΏ½Μ‚ : the hat means it is estimated – πΎπ‘˜ is a gain expressing the tradeoff οΏ½Μ‚ π‘˜ = πΎπ‘˜ 𝑧 π‘˜ + (1 βˆ’ πΎπ‘˜)οΏ½Μ‚ π‘˜βˆ’1
  • 7. Computing the Gain β€’ Recall the measurement associated with a noise π‘₯ π‘˜ = 𝑧 π‘˜ βˆ’ 𝑣 π‘˜ – we don’t know the individual noise for an measurement, but we typically know the average noise, call it π‘Ÿ πΎπ‘˜ = 𝑝 π‘˜βˆ’1/(𝑝 π‘˜βˆ’1 + π‘Ÿ) β€’ π‘Ÿ has no subscript; it doesn’t depend on time β€’ where 𝑝 π‘˜ is a prediction error that is computed recursively π‘ƒπ‘˜ = (1 βˆ’ πΎπ‘˜) 𝑝 π‘˜βˆ’1 β€’ think about the cases: – π‘ƒπ‘˜βˆ’1 previous prediction error was 0 – if there is very little noise, π‘Ÿ is 0 – when the system is noisy, π‘Ÿ becomes large
  • 8. The Prediction and Correction β€’ Consider the state equation π‘₯ π‘˜ = 𝐴π‘₯ π‘˜βˆ’1 – It seems to have vanished in the equation οΏ½Μ‚ π‘˜ = οΏ½Μ‚ π‘˜βˆ’1 + πΎπ‘˜(𝑧 π‘˜ βˆ’ οΏ½Μ‚ π‘˜βˆ’1) β€’ we need both β€’ first equation represents a prediction about what the state should be, and the second equation represents an correction to this prediction, based on an observation β€’ Rewrite it οΏ½Μ‚ π‘˜ = 𝐴�̂ π‘˜βˆ’1 β€’ We use the constant in 𝐴 a prediction of the error too 𝑝 π‘˜ = 𝐴𝑝 π‘˜βˆ’1 𝐴 – we multiply twice by 𝐴 because the prediction error 𝑝 π‘˜ is itself a squared error; hence, it is scaled by the square of the coefficient associated with the state value π‘₯ π‘˜
  • 9. Kalman Filter Equations β€’ Time Update (Predict) οΏ½Μ‚ π‘˜ = 𝐴�̂ π‘˜βˆ’1 𝑝 π‘˜ = 𝐴𝑝 π‘˜βˆ’1 𝐴 β€’ Measurement Update (Correct) πΎπ‘˜ = 𝑝 π‘˜βˆ’1/(𝑝 π‘˜βˆ’1 + π‘Ÿ) οΏ½Μ‚ π‘˜ = οΏ½Μ‚ π‘˜βˆ’1 + πΎπ‘˜(𝑧 π‘˜ βˆ’ οΏ½Μ‚ π‘˜βˆ’1) π‘ƒπ‘˜ = (1 βˆ’ πΎπ‘˜) 𝑝 π‘˜βˆ’1 Predict Correct
  • 10. Simple Run π’Œ 0 1 2 3 4 5 6 7 8 9 π‘₯ π‘˜ 1000 800 640 512 409.6 327.7 262.1 209.7 167.8 134.2 𝑧 π‘˜ 908.3 689.7 833 338.8 596.5 350 340.3 152.5 363.9 236.1 𝑝 π‘˜ 1 οΏ½Μ‚ π‘˜ 908.3 𝑔 π‘˜ π‘₯0 = 1000 r = 200 a = 0.8 𝑧 π‘˜ = [1000*0.8**i + x for i,x in enumerate(rnd_u(-200,200,10))] Predict: οΏ½Μ‚ π‘˜ = π‘ŽοΏ½Μ‚ π‘˜βˆ’1 𝑝 π‘˜ = π‘Žπ‘ π‘˜βˆ’1 π‘Ž Update: οΏ½Μ‚ π‘˜ = 𝑝 π‘˜/(𝑝 π‘˜ + π‘Ÿ) οΏ½Μ‚ π‘˜ = οΏ½Μ‚ π‘˜ + 𝑔 π‘˜(𝑧 π‘˜ βˆ’ οΏ½Μ‚ π‘˜) 𝑝 π‘˜ = (1 βˆ’ 𝑔 π‘˜)𝑝 π‘˜
  • 11. Simple Run π’Œ 0 1 2 3 4 5 6 7 8 9 π‘₯ π‘˜ 1000 800 640 512 409.6 327.7 262.1 209.7 167.8 134.2 𝑧 π‘˜ 908.3 689.7 833 338.8 596.5 350 340.3 152.5 363.9 236.1 𝑝 π‘˜ 1 0.63 0.41 0.26 0.17 0.11 0.07 0.04 0.02 0.01 οΏ½Μ‚ π‘˜ 908.3 726.5 581.7 465.2 372.4 297.9 238.4 190.7 152.6 122.1 𝑔 π‘˜ 0.003 0.002 0.001 0.001 0.000 0.000 0.000 0.000 0.000
  • 12. A More Realistic Model β€’ Account for the time-varying control that the pilot exercises over the airplane – for example, moving the control column forward and back οΏ½Μ‚ π‘˜+1 = 𝐴�̂ π‘˜ + 𝐡𝑒 π‘˜ – 𝑒 π‘˜ represents the current value of the control signal that the pilot is sending to the airplane – this control signal can be scaled by a constant amount B β€’ Measurement 𝑧 π‘˜ = 𝐻π‘₯ π‘˜ + 𝑣 π‘˜
  • 13. Kalman Filter Equations β€’ Time Update (Predict) οΏ½Μ‚ π‘˜ = 𝐴�̂ π‘˜βˆ’1 + 𝐡𝑒 π‘˜ 𝑝 π‘˜ = 𝐴𝑝 π‘˜βˆ’1 𝐴 β€’ Measurement Update (Correct) πΎπ‘˜ = 𝑝 π‘˜βˆ’1 𝐻/(𝐻𝑝 π‘˜βˆ’1 𝐻 + π‘Ÿ) οΏ½Μ‚ π‘˜ = οΏ½Μ‚ π‘˜βˆ’1 + πΎπ‘˜(𝑧 π‘˜ βˆ’ 𝐻�̂ π‘˜βˆ’1) π‘ƒπ‘˜ = (1 βˆ’ πΎπ‘˜ 𝐻) 𝑝 π‘˜βˆ’1 Predict Correct
  • 14. Adding Velocity to the System β€’ For the state equation οΏ½Μ‚ π‘˜ = 𝐴�̂ π‘˜βˆ’1 – Considering equation expressing distance in terms of velocity and time π‘‘π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’ π‘π‘’π‘Ÿπ‘Ÿπ‘’π‘›π‘‘ = π‘‘π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’ π‘π‘Ÿπ‘’π‘£π‘–π‘œπ‘’π‘  + π‘£π‘’π‘™π‘œπ‘π‘–π‘‘π‘¦ π‘π‘Ÿπ‘’π‘£π‘–π‘œπ‘’π‘  βˆ— π‘‘π‘–π‘šπ‘’π‘ π‘‘π‘’π‘ – vectors are used π‘₯ π‘˜ ≑ π‘‘π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’ π‘˜ π‘£π‘’π‘™π‘œπ‘π‘–π‘‘π‘¦ π‘˜ 𝐴 = 1 π‘‘π‘–π‘šπ‘’π‘ π‘‘π‘’π‘ 0 1 β€’ So π‘‘π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’ π‘˜ π‘£π‘’π‘™π‘œπ‘π‘–π‘‘π‘¦ π‘˜ = 1 π‘‘π‘–π‘šπ‘’π‘ π‘‘π‘’π‘ 0 1 π‘‘π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’ π‘˜βˆ’1 π‘£π‘’π‘™π‘œπ‘π‘–π‘‘π‘¦ π‘˜βˆ’1
  • 15. Discrete Kalman Filter β€’ Trying to estimate the state π‘₯ ∈ β„› 𝑛 of a discrete- time controlled process that is governed by the linear stochastic difference equation π‘₯ π‘˜ = 𝐴π‘₯ π‘˜βˆ’1 + 𝐡𝑒 π‘˜ + 𝑀 π‘˜βˆ’1 β€’ with a measurement 𝑧 ∈ β„› π‘š that is 𝑧 π‘˜ = 𝐻π‘₯ π‘˜ + 𝑣 π‘˜ β€’ Random variables w and v represent process and measurement noise, which normal probability distributions 𝑝 𝑀 ~ 𝑁 0, 𝑄 𝑝 𝑣 ~ 𝑁(0, 𝑅)
  • 16. Process Dynamics 𝒙 π’Œ+𝟏 = 𝑨𝒙 π’Œ + π’˜ π’Œ state vector π‘₯ π‘˜ ∈ β„› 𝑛 contains the states of the process
  • 17. Process Dynamics 𝒙 π’Œ+𝟏 = 𝑨𝒙 π’Œ + π’˜ π’Œ state transition matrix 𝑛π‘₯𝑛 matrix 𝐴 relates state at time step π‘˜ to time step π‘˜ + 1
  • 18. Process Dynamics 𝒙 π’Œ+𝟏 = 𝑨𝒙 π’Œ + π’˜ π’Œ process noise 𝑀 π‘˜ ∈ β„› 𝑛 models the uncertainty of the process 𝑝 𝑀 π‘˜ ~ 𝑁 0, 𝑄
  • 19. Measurement 𝒛 π’Œ = 𝑯𝒙 π’Œ + 𝒗 π’Œ measurement vector 𝑧 π‘˜ ∈ β„› π‘š is the process measurement
  • 20. Measurement 𝒛 π’Œ = 𝑯𝒙 π’Œ + 𝒗 π’Œ state vector π‘₯ π‘˜ ∈ β„› 𝑛 contains the states of the process
  • 21. Measurement 𝒛 π’Œ = 𝑯𝒙 π’Œ + 𝒗 π’Œ measurement matrix π‘šπ‘₯𝑛 matrix 𝐻 relates state to measurement
  • 22. Measurement 𝒛 π’Œ = 𝑯𝒙 π’Œ + 𝒗 π’Œ measurement noise 𝑣 π‘˜ ∈ β„› π‘š models the uncertainty of the process 𝑝 𝑣 π‘˜ ~ 𝑁 0, 𝑅
  • 23. Estimate Covariances a priori estimate error covariance π‘ƒπ‘˜ βˆ’ = 𝐸[(π‘₯ π‘˜ βˆ’ οΏ½Μ‚ π‘˜ βˆ’ )(π‘₯ π‘˜ βˆ’ οΏ½Μ‚ π‘˜ βˆ’ ) 𝑇 ] a posteriori estimate error covariance π‘ƒπ‘˜ = 𝐸[(π‘₯ π‘˜ βˆ’ οΏ½Μ‚ π‘˜)(π‘₯ π‘˜ βˆ’ οΏ½Μ‚ π‘˜) 𝑇 ] – define a priori estimate errors as β€’ 𝑒 π‘˜ βˆ’ ≑ π‘₯ π‘˜ βˆ’ π‘₯ π‘˜ βˆ’ β€’ 𝑒 π‘˜ ≑ π‘₯ π‘˜ βˆ’ οΏ½Μ‚ π‘˜ – error covariance is then β€’ π‘ƒπ‘˜ βˆ’ ≑ 𝐸[𝑒 π‘˜ βˆ’ 𝑒 π‘˜ βˆ’π‘‡] β€’ π‘ƒπ‘˜ ≑ 𝐸[𝑒 π‘˜ 𝑒 𝑇 π‘˜]
  • 24. Chosen Kalman Gain π‘ƒπ‘˜ = 𝐸 π‘₯ π‘˜ βˆ’ ොπ‘₯ π‘˜ π‘₯ π‘˜ βˆ’ ොπ‘₯ π‘˜ 𝑇 (1) οΏ½Μ‚ π‘˜ = οΏ½Μ‚ π‘˜ βˆ’ + πΎπ‘˜ 𝑧 π‘˜ βˆ’ 𝐻 ොπ‘₯ π‘˜ βˆ’ (2) β€’ The nxm matrix K in equation (2) is chosen to be the factor that minimizes the a posteriori error covariance equation (1) – It can be accomplished by first substituting equation (2) into the above definition for 𝑒 π‘˜, substituting that into equation (1), performing the indicated expectations, taking the derivative of the trace of the result with respect to K, setting that result equal to zero, and then solving for K. – Maybeck 1979; Jacobs 1993; Brown and Hwang 1996 πΎπ‘˜ = π‘ƒπ‘˜ βˆ’ 𝐻 𝑇 (π»π‘ƒπ‘˜ βˆ’ 𝐻 𝑇 + 𝑅)βˆ’1
  • 25. The Update iterations β€’ Time Update (Predict) 1. state and covariance prediction β€’ Measurement Update (Correct) 2. Kalman gain correction and state correction 3. covariance correction Predict Correct
  • 26. Kalman Filter Equations β€’ Time Update (Predict) 1. state and covariance prediction οΏ½Μ‚ π‘˜ βˆ’ = 𝐴π‘₯ π‘˜βˆ’1 π‘ƒπ‘˜ βˆ’ = π΄π‘ƒπ‘˜βˆ’1 𝐴 𝑇 + 𝑄 β€’ Measurement Update (Correct) 2. Kalman gain correction and state correction πΎπ‘˜ = π‘ƒπ‘˜ βˆ’ 𝐻 𝑇 (π»π‘ƒπ‘˜ βˆ’ 𝐻 𝑇 + 𝑅)βˆ’1 οΏ½Μ‚ π‘˜ = οΏ½Μ‚ π‘˜ βˆ’ + πΎπ‘˜ 𝑧 π‘˜ βˆ’ 𝐻ොπ‘₯ π‘˜ βˆ’ 3. covariance correction π‘ƒπ‘˜ = (𝐼 βˆ’ πΎπ‘˜ 𝐻)π‘ƒπ‘˜ βˆ’
  • 27. Source Code β€’ C# – KalmanDemo β€’ Python – pykalman: the dead-simple Kalman Filter, Kalman Smotther, and EM library β€’ ANSI C – recovery of motion and 3D structure from a sequence of images
  • 28. DEMO
  • 29. Variations of the Filter β€’ Discrete-Discrete β€’ Continuous-Discrete β€’ Extended Kalman Filter β€’ TBC
  • 30. References β€’ Kalman, R. E. 1960. β€œA New Approach to Linear Filtering and Prediction Problems”, Transaction of the ASME – Journal of Basic Engineering, March 1960 β€’ Greg Welch, Gary Bishop, "An Introduction to the Kalman Filter", University of North Carolina at Chapel Hill Department of Computer Science, 2001 β€’ Lindsay Kleeman, "Understanding and Applying Kalman Filtering", Department of Electrical and Computer Systems Engineering β€’ Simon D. Levy, β€œKalman Filter Interactive Tutorial” β€’ M.S.Grewal, A.P. Andrews, "Kalman Filtering - Theory and Practice Using MATLAB", Wiley, 2001 β€’ MIT Video Lecture on the Kalman filter, YouTube β€’ Kalman filter, Wikipedia