Kalman filtering and friends: Inference in time series...
Transcript of Kalman filtering and friends: Inference in time series...
Kalmanfilteringandfriends:Inferenceintimeseriesmodels
HerkevanHoofslidesmostlybyMichaelRubinstein
Problemoverview• Goal– Estimatemostprobablestateattimekusingmeasurementuptotimek’
k’<k:predictionk’=k:filteringk’>k:smoothing
• Input– (Noisy)Sensormeasurements– Knownorlearnedsystemmodel(seelastlecture)
• Manyproblemsrequireestimationofthestateofsystemsthatchangeovertimeusingnoisymeasurementsonthesystem
Applications• Ballistics• Robotics– Robotlocalization
• Trackinghands/cars/…• Econometrics– Stockprediction
• Navigation
• Manymore…
Example:noisylocalization
https://img.clipartfest.com
Positionatt=0
Measurementatt=1
t=2
t=3t=4
t=5
t=6
Example:noisylocalization
https://img.clipartfest.com
Positionatt=0
Measurementatt=1
t=2
t=3t=4
t=5
Smoothing:wherewasIinthepast
t=6
Example:noisylocalization
https://img.clipartfest.com
Positionatt=0
Measurementatt=1
t=2
t=3t=4
t=5
t=6
Smoothing:wherewasIinthepast
Filtering:whereamInow
Example:noisylocalization
https://img.clipartfest.com
Positionatt=0
Measurementatt=1
t=2
t=3t=4
t=5
t=6
Smoothing:wherewasIinthepast
Filtering:whereamInow
Prediction:wherewillIbeinthefuture
Today’slecture• Fundamentals• Formalizingtimeseriesmodels• Recursivefiltering
• Twocaseswithoptimalsolutions• LinearGaussianmodels• Discretesystems
• Suboptimalsolutions
StochasticProcesses
• Stochasticprocess– Collectionofrandomvariablesindexedbysomeset– Ie.R.V.𝑥" foreveryelement𝑖 inindexset
• Timeseriesmodeling– Sequenceofrandomstates/variables– Measurementsavailableatdiscretetimes– Modeledasstochasticprocessindexedbyℕ
StochasticProcesses
• Stochasticprocess– Collectionofrandomvariablesindexedbysomeset– Ie.R.V.𝑥" foreveryelement𝑖 inindexset
• Timeseriesmodeling– Sequenceofrandomstates/variables– Measurementsavailableatdiscretetimes– Modeledasstochasticprocessindexedbyℕ
𝑥$ (locationatt=1)
𝑝(𝑥$)
StochasticProcesses
• Stochasticprocess– Collectionofrandomvariablesindexedbysomeset– Ie.R.V.𝑥" foreveryelement𝑖 inindexset
• Timeseriesmodeling– Sequenceofrandomstates/variables– Measurementsavailableatdiscretetimes– Modeledasstochasticprocessindexedbyℕ
𝑝(𝑥$)
𝑝(𝑥()
𝑝(𝑥))
(First-order)Markovprocess
• TheMarkovproperty– thelikelihoodofafuturestatedependsonpresentstateonly
• Markovchain– AstochasticprocesswithMarkovproperty
k-1 k k+1 timexk-1 xk xk+1 States
HiddenMarkovModel(HMM)
• thestateisnotdirectlyvisible,butoutputdependentonthestateisvisible
k-1 k k+1 timexk-1 xk xk+1 States
(hidden)
zk-1 zk zk+1 Measurements(observed)
Statespace
• Thestatevectorcontainsallavailableinformationtodescribetheinvestigatedsystem– usuallymultidimensional:
• Themeasurementvectorrepresentsobservationsrelatedtothestatevector– Generally(butnotnecessarily)oflowerdimensionthanthestatevector
Statespace
• Tracking: Econometrics:• Monetaryflow• Interestrates• Inflation• …
HiddenMarkovModel(HMM)
• thestateisnotdirectlyvisible,butoutputdependentonthestateisvisible
k-1 k k+1 timexk-1 xk xk+1 States
(hidden)
zk-1 zk zk+1 Measurements(observed)
DynamicSystem
Stateequation:statevectorattimeinstantkstatetransitionfunction,i.i.dprocessnoise
Observationequation:observationsattimeinstantkobservationfunction,i.i.dmeasurementnoise
k-1 k k+1xk-1 xk xk+1
zk-1 zk zk+1Stochasticdiffusion
Asimpledynamicsystem• (4-dimensionalstatespace)• Constantvelocitymotion:
• Onlypositionisobserved:
Gaussiandistribution
μ
YacovHel-Or
Today’slecture• Fundamentals• Formalizingtimeseriesmodels• Recursivefiltering
• Twocaseswithoptimalsolutions• LinearGaussianmodels• Discretesystems
• Suboptimalsolutions
Recursivefilters• Formanyproblems,estimateisrequiredeachtimeanewmeasurementarrives
• Batch processing– Requiresall availabledata
• Sequential processing– Newdataisprocesseduponarrival– Neednotstorethecompletedataset– Neednotreprocessalldataforeachnewmeasurement
– Assumenoout-of-sequencemeasurements(solutionsforthisexistaswell…)
Bayesianfilter• Constructtheposteriorprobabilitydensityfunctionofthestatebasedonallavailableinformation
• Byknowingtheposteriormanykindsofestimatesfor canbederived– mean(expectation),mode,median,…– Canalsogiveestimationoftheaccuracy(e.g.covariance)
ThomasBayes
Samplespace
Posterior
RecursiveBayesfilters
• Given:– Systemmodelsinprobabilisticforms
(knownstatisticsofvk,wk)– Initialstate alsoknownastheprior–Measurements
Markovianprocess
Measurementsconditionallyindependentgivenstate
𝑧$, … , 𝑧-
RecursiveBayesfilters• Predictionstep(a-priori)
– Usesthesystemmodeltopredictforward– Deforms/translates/spreadsstatepdfduetorandomnoise
• Updatestep(a-posteriori)
– Updatethepredictioninlightofnewdata– Tightensthestatepdf
Priorvsposterior?
• Itcanseemoddtoregard𝑝 𝑥- 𝑧$:-/$ asprior• Compare
to
• Inupdatewith𝑧-,itisaworkingprior
𝑃(𝑥-|𝑧-, 𝑧$:-/$ ) =𝑝 𝑧- 𝑥-, 𝑧$:-/$ 𝑃(𝑥-|𝑧$:-/$)
𝑝(𝑧-|𝑧$:-/$)
posteriorlikelihood prior
evidence
𝑃(𝑥-|𝑧-, 𝑧$:-/$) =𝑝 𝑧- 𝑥-, 𝑧$:-/$ 𝑃(𝑥-|𝑧$:-/$)
𝑝(𝑧-|𝑧$:-/$)
Generalprediction-updateframework
• Assume isgivenattimek-1• Prediction:
• UsingChapman-Kolmogorovidentity+Markovproperty
(1)
PreviousposteriorSystemmodel
Generalprediction-updateframework
• Updatestep
Where
(2)
Measurementmodel
Currentprior
Normalizationconstant
Generatingestimates
• Knowledgeof enablestocomputeoptimalestimatewithrespecttoanycriterion.e.g.–Minimummean-squareerror(MMSE)
–Maximuma-posteriori
Generalprediction-updateframework
➔So(1)and(2)giveoptimalsolutionfortherecursiveestimationproblem!
• Unfortunately…onlyconceptualsolution– integralsareintractable…– Cannotrepresentarbitrarypdfs!
• However,optimalsolutiondoes existforseveralrestrictivecases
Today’slecture• Fundamentals• Formalizingtimeseriesmodels• Recursivefiltering
• Twocaseswithoptimalsolutions• LinearGaussianmodels• Discretesystems
• Suboptimalsolutions
Restrictivecase#1
• PosteriorateachtimestepisGaussian– Completelydescribedbymeanandcovariance
• If isGaussianitcanbeshownthatisalsoGaussianprovidedthat:
– areGaussian– arelinear
Restrictivecase#1
• WhyLinear?
YacovHel-Or
Restrictivecase#1
• WhyLinear?
YacovHel-Or
Restrictivecase#1
• Linearsystemwithadditivenoise
• Simpleexampleagain
/$
/$
TheKalmanfilter
• Substitutinginto(1)and(2)yieldsthepredictandupdateequations
RudolfE.Kalman
TheKalmanfilter
Predict:
Update:
Intuitionvia1Dexample
• Lostatsea– Night– Noideaoflocation– Forsimplicity– let’sassume1D
– Notmoving
*ExampleandplotsbyMaybeck,“Stochasticmodels,estimationandcontrol,volume1”
Example– cont’d
• Timet1:StarSighting– Denotez(t1)=z1
• Uncertainty(inaccuracies,humanerror,etc)– Denoteσ1(normal)
• Canestablishtheconditionalprobabilityofx(t1)givenmeasurementz1
Example– cont’d
• Probabilityforanylocation,basedonmeasurement• ForGaussiandensity– 68.3%within±σ1• Bestestimateofposition:Mean/Mode/Median
Example– cont’d
• Timet2:friend(moretrained)– x(t2)=z2,σ(t2)=σ2– Sinceshehashigherskill:σ2<σ1
Example– cont’d
• f(x(t2)|z1,z2)alsoGaussian
Example– cont’d
• σ lessthanbothσ1andσ2• σ1=σ2:average• σ1>σ2:moreweighttoz2• Rewrite:
Example– cont’d
• TheKalmanupdaterule:
BestPredictionpriortoz2(apriori)
OptimalWeighting(KalmanGain)
Residual
BestestimateGivenz2
(aposteriori)
TheKalmanfilter
Predict:
Update:Generallyincreases
variance
Generallydecreasesvariance
Kalmangain
• Smallmeasurementerror,𝐻 invertible:
• Smallpredictionerror:
TheKalmanfilter• Pros (comparedtoe.g.particlefilter)– Optimalclosed-formsolutiontothetrackingproblem(undertheassumptions)• Noalgorithmcandobetterinalinear-Gaussianenvironment!
– All‘logical’estimationscollapsetoauniquesolution– Simpletoimplement– Fasttoexecute
• Cons– Ifeitherthesystemormeasurementmodelisnon-linearà theposteriorwillbenon-Gaussian
Smoothingpossiblewithabackwardmessage
(cf HMMs,lecture10)
Restrictivecase#2
• Thestatespace(domain)isdiscreteandfinite• Assumethestatespaceattimek-1consistsofstates
• Let betheconditionalprobabilityofthestateattimek-1,givenmeasurementsuptok-1
TheGrid-basedfilter
• Theposteriorpdfatk-1canbeexpressedassumofdeltafunctions
• Again,substitutioninto(1)and(2)yieldsthepredictandupdateequations
EquivalenttobeliefmonitoringinHMMs
(Lecture10)
TheGrid-basedfilter• Prediction
• Newpriorisalsoweightedsumofdeltafunctions• Newpriorweightsarereweightingofoldposteriorweightsusingstatetransition
probabilities
(1)
TheGrid-basedfilter• Update
• Posteriorweightsarereweightingofpriorweightsusinglikelihoods(+normalization)
(2)
TheGrid-basedfilter
• Pros:– assumedknown,butnoconstraintontheir(discrete)shapes
– Easyextensiontovaryingnumberofstates– Optimalsolutionforthediscrete-finiteenvironment!
• Cons:– Curseofdimensionality
• Inefficientifthestatespaceislarge– Staticallyconsidersall possiblehypotheses
Smoothingpossiblewithabackwardmessage
(cf HMMs,lecture10)
Today’slecture• Fundamentals• Formalizingtimeseriesmodels• Recursivefiltering
• Twocaseswithoptimalsolutions• LinearGaussianmodels• Discretesystems
• Suboptimalsolutions
Suboptimalsolutions• Inmanycasestheseassumptionsdonothold– Practicalenvironmentsarenonlinear,non-Gaussian,continuous
➔Approximationsarenecessary…
– ExtendedKalmanfilter(EKF)– Approximategrid-basedmethods– Multiple-modelestimators– UnscentedKalmanfilter(UKF)– Particlefilters(PF)– …
Analyticapproximations
Samplingapproaches
Numericalmethods
Gaussian-sumfilters
TheextendedKalmanfilter
• Theidea:locallinearizationofthedynamicsystemmightbesufficientdescriptionofthenonlinearity
• Themodel:nonlinearsystemwithadditivenoise
TheextendedKalmanfilter
• f,hareapproximatedusingafirst-orderTaylorseriesexpansion(evalatstateestimations)
Predict:
Update:
TheextendedKalmanfilter
TheextendedKalmanfilter• Pros– Goodapproximationwhenmodelsarenear-linear– Efficienttocalculate(defactomethodfornavigationsystemsandGPS)
• Cons– Onlyapproximation(optimalitynotproven)– StillasingleGaussianapproximations
• Nonlinearityà non-Gaussianity(e.g.bimodal)– Ifwehavemultimodalhypothesis,andchooseincorrectly– canbedifficulttorecover
– Inapplicablewhenf,h discontinuous
TheunscentedKalman filter
• CangivemoreaccuratelyapproximatesposteriorYacovHel-Or
Challenges• Detectionspecific– Full/partialocclusions– Falsepositives/falsenegatives– Entering/leavingthescene
• Efficiency• Multiplemodelsandswitchingdynamics• Multipletargets• …
Conclusion• Inferenceintimeseriesmodels:• Past:smoothing• Present:filtering• Future:prediction
• RecursiveBayesfilteroptimal• Computableintwocases• LinearGaussiansystems:Kalman filter• Discretesystems:Gridfilter
• Approximatesolutionsforothersystems