Exact Approximation and Particle Filters Adam M. Johansen et al. Collaborators Include: Arnaud Doucet, Axel Finke, Anthony Lee, Nick Whiteley ERCIM 8th December 2014 Exact Approximation and Particle Filters Adam M. Johansen Introduction Approximating the RBPF Block Sampling Particle Filters References Context & Outline Filtering in State-Space Models: I SIR Particle Filters [GSS93] I Rao-Blackwellized Particle Filters [AD02, CL00] I Block-Sampling Particle Filters [DBS06] Exact Approximation of Monte Carlo Algorithms: I Particle MCMC [ADH10] and SMC2 [CJP13] Exact Approximation and Particle Filters: I Approximated RBPFs [CSOL11] Exactly [JWD12] I Hierarchical SMC [JD] I Pseudomarginal State Augmentation: More of the SAME? Exact Approximation and Particle Filters Adam M. Johansen Introduction Approximating the RBPF Block Sampling Particle Filters References Particle MCMC I I MCMC algorithms which employ SMC proposals [ADH10] SMC algorithm as a collection of RVs I I I I Construct MCMC algorithms: I I I I I Values Weights Ancestral Lines With many auxiliary variables Exactly invariant for distribution on extended space Standard MCMC arguments justify strategy SMC2 employs the same approach within an SMC setting. What else does this allow us to do with SMC? Exact Approximation and Particle Filters Adam M. Johansen Introduction Approximating the RBPF Block Sampling Particle Filters References Ancestral Trees t=1 t=2 t=3 a13 =1 a43 =3 a12 =1 a42 =3 b23,1:3 =(1, 1, 2) b43,1:3 =(3, 3, 4) b63,1:3 =(4, 5, 6) Exact Approximation and Particle Filters Adam M. Johansen Introduction Approximating the RBPF Block Sampling Particle Filters References SMC Distributions Formally gives rise to the SMC Distribution: M an−L+2:n , xn−L+1:n , k; xn−L ψn,L " "M # # n M Y Y Y i i i ap = q( xn−L+1 xn−L ) r(ap |wp−1 ) q xp |xp−1 r(k|wn ) i=1 p=n−L+2 i=1 and the conditional SMC Distribution: ek M ek ek ψen,L a ekn−L+1:n n−L+2:n , x n−L+1:n ; xn−L bn−L+1:n−1 , k, x M en−L+1:n , k; xn−L ) ψn,L (e an−L+2:n , x " = # ebk n e e Q bk bn n,n−L+1 n,p n,p−1 k e p−1 q x e n) r ebn,p |w ep |e xp−1 q x en−L+1 |xn−L r(k|w p=n−L+2 Exact Approximation and Particle Filters Adam M. Johansen Introduction Approximating the RBPF Block Sampling Particle Filters References A (Rather Broad) Class of Hidden Markov Models y1 x1 z1 x2 z2 y2 x3 z3 y3 I I I Unobserved Markov chain {(Xn , Zn )} transition f . Observed process {Yn } conditional density g. Density: p(x1:n , z1:n , y1:n ) = f1 (x1 , z1 )g(y1 |x1 , z1 ) n Y f (xi , zi |xi−1 , zi−1 )g(yi |xi , zi ). i=2 Exact Approximation and Particle Filters Adam M. Johansen Introduction Approximating the RBPF Block Sampling Particle Filters References Formal Solutions I Filtering and Prediction Recursions: p(xn , zn |y1:n−1 )g(yn |xn , zn ) p(xn , zn |y1:n ) = R p(x0n , zn0 |y1:n−1 )g(yn |x0n , zn0 )d(x0n , zn0 ) Z p(xn+1 , zn+1 |y1:n ) = p(xn , zn |y1:n )f (xn+1 , zn+1 |xn , zn )d(xn , zn ) I Smoothing: p((x, z)1:n |y1:n ) ∝ p((x, z)1:n−1 |y1:n−1 )f ((x, z)n |(x, z)n−1 )g(yn |(x, z)n ) Exact Approximation and Particle Filters Adam M. Johansen Introduction Approximating the RBPF Block Sampling Particle Filters References A Simple SIR Filter Algorithmically, at iteration n: I I i Given {Wn−1 , (X, Z)i1:n−1 } for i = 1, . . . , N : e Z) e i }. Resample, obtaining { 1 , (X, 1:n−1 N I Sample (X, Z)in I Weight Wni ∝ e Z) e i ) ∼ qn (·|(X, n−1 e Z) e i )g(yn |(X,Z)i ) f ((X,Z)in |(X, n n−1 e Z) e i ) qn ((X,Z)i |(X, n n−1 Actually: I Resample efficiently. I Only resample when necessary. I ... Exact Approximation and Particle Filters Adam M. Johansen Introduction Approximating the RBPF Block Sampling Particle Filters References A Rao-Blackwellized SIR Filter Algorithmically, at iteration n: I X,i i i Given {Wn−1 , (X1:n−1 , p(z1:n−1 |X1:n−1 , y1:n−1 )} 1 ei ei , p(z1:n−1 |X Resample, obtaining { , (X I For i = 1, . . . , N : I 1:n−1 N I I 1:n−1 , y1:n−1 ))}. ei ) Sample Xni ∼ qn (·|X n−1 i i i e , Set X1:n ← (X 1:n−1 Xn ). i ei p(Xn ,yn |X n−1 ) i e qn (X |X i ) I Weight WnX,i ∝ I i Compute p(z1:n |y1:n , X1:n ). n n−1 Requires analytically tractable substructure. Exact Approximation and Particle Filters Adam M. Johansen Introduction Approximating the RBPF Block Sampling Particle Filters References An Approximate Rao-Blackwellized SIR Filter Algorithmically, at iteration n: I I I X,i i i Given {Wn−1 , (X1:n−1 , pb(z1:n−1 |X1:n−1 , y1:n−1 )} 1 ei ei , pb(z1:n−1 |X Resample, obtaining { , (X 1:n−1 N 1:n−1 , y1:n−1 ))}. For i = 1, . . . , N : I I ei ) Sample Xni ∼ qn (·|X n−1 i i i e , Set X1:n ← (X 1:n−1 Xn ). i ei p b(Xn ,yn |X n−1 ) i e qn (X |X i ) I Weight WnX,i ∝ I i Compute pb(z1:n |y1:n , X1:n ). n n−1 Is approximate; how does error accumulate? Exact Approximation and Particle Filters Adam M. Johansen Introduction Approximating the RBPF Block Sampling Particle Filters References Exactly Approximated Rao-Blackwellized SIR Filter At time n = 1 I Sample, X i ∼ q x ( ·| y1 ). 1 i,j z ·| X i , y . I Sample, Z 1 1 1 ∼q I Compute and normalise the local weights w1z X1i , Z1i,j p(X i , y1 , Z i,j ) := 1 1 , W1z,i,j q z Z1i,j X1i , y1 pb(X1i , y1 ) define := w1z X1i , Z1i,j PM z X i , Z i,k w 1 1 k=1 1 M 1 X z i i,j := w1 X1 , Z1 . M j=1 I Compute and normalise the top-level weights w1x X1i w1x X1i pb(X1i , y1 ) x,i , W1 := PN := x . x Xk q X1i |y1 w 1 k=1 1 At times n ≥ 2, resample and do essentially the same again. . . Exact Approximation and Particle Filters Adam M. Johansen Introduction Approximating the RBPF Block Sampling Particle Filters References Toy Example: Model We use a simulated sequence of 100 defined by the densities: x1 µ(x1 , z1 ) =N z1 xn f (xn , zn |xn−1 , zn−1 ) =N zn g(yn |xn , zn ) =N yn ; observations from the model 0 1 0 ; 0 0 1 xn−1 1 0 ; , zn−1 0 1 2 xn σx 0 , zn 0 σz2 Consider IMSE (relative to optimal filter) of filtering estimate of first coordinate marginals. Exact Approximation and Particle Filters Adam M. Johansen Introduction Approximating the RBPF Block Sampling Particle Filters References Mean Squared Filtering Error Approximation of the RBPF N = 10 −1 10 N = 20 N = 40 N = 80 −2 10 N = 160 0 10 1 10 Number of Lower−Level Particles, M 2 10 For σx2 = σz2 = 1. Exact Approximation and Particle Filters Adam M. Johansen Introduction Approximating the RBPF Block Sampling Particle Filters References Computational Performance 0 Mean Squared Filtering Error 10 N = 10 N = 20 N = 40 N = 80 N = 160 −1 10 −2 10 −3 10 1 10 2 10 3 10 Computational Cost, N(M+1) 4 10 5 10 For σx2 = σz2 = 1. Exact Approximation and Particle Filters Adam M. Johansen Introduction Approximating the RBPF Block Sampling Particle Filters References Computational Performance N = 10 N = 20 N = 40 N = 80 N = 160 1.9 Mean Squared Filtering Error 10 1.8 10 1.7 10 1.6 10 1 10 2 10 3 10 Computational Cost, N(M+1) 4 10 5 10 For σx2 = 102 and σz2 = 0.12 . Exact Approximation and Particle Filters Adam M. Johansen Introduction Approximating the RBPF Block Sampling Particle Filters References What About Other HMMs / Algorithms? Returning to: x1 x2 x3 x4 x5 x6 y1 y2 y3 y4 y5 y6 I Unobserved Markov chain {Xn } transition f . I Observed process {Yn } conditional density g. Density: I p(x1:n , y1:n ) = f1 (x1 )g(y1 |x1 ) n Y f (xi |xi−1 )g(yi |xi ). i=2 Exact Approximation and Particle Filters Adam M. Johansen Introduction Approximating the RBPF Block Sampling Particle Filters References Block Sampling: An Idealised Approach At time n, given x1:n−1 ; discard xn−L+1:n−1 : I Sample from q(xn−L+1:n |xn−L , yn−L+1:n ). I Weight with W (x1:n ) = I p(x1:n |y1:n ) p(x1:n−L |y1:n−1 )q(xn−L+1:n |xn−L , y1:n−L+1:n ) Optimally, q(xn−L+1:n |xn−L , yn−L+1:n ) =p(xn−L+1:n |xn−L , yn−L+1:n ) p(x1:n−L |y1:n ) W (x1:n ) ∝ =p(yn |x1:n−L , yn−L+1:n−1 ) p(x1:n−L |y1:n−1 ) I Typically intractable; auxiliary variable approach in [DBS06]. Exact Approximation and Particle Filters Adam M. Johansen Introduction Approximating the RBPF Block Sampling Particle Filters References Local Particle Filtering: Current Trajectories Starting Point 4 2 0 −2 −4 0 2 4 Exact Approximation and Particle Filters Adam M. Johansen 6 8 n 10 12 14 16 Introduction Approximating the RBPF Block Sampling Particle Filters References Local Particle Filtering: PF Proposal PF Step 4 2 0 −2 −4 0 2 4 Exact Approximation and Particle Filters Adam M. Johansen 6 8 n 10 12 14 16 Introduction Approximating the RBPF Block Sampling Particle Filters References Local Particle Filtering: CPF Auxiliary Proposal CPF Step 4 2 0 −2 −4 0 2 4 Exact Approximation and Particle Filters Adam M. Johansen 6 8 n 10 12 14 16 Introduction Approximating the RBPF Block Sampling Particle Filters References Local SMC I I Not just a Random Weight Particle Filter. Propose from: ⊗n−1 M U1:M (b1:n−2 , k)p(x1:n−1 |y1:n−1 )ψn,L (an−L+2:n , xn−L+1:n , k; xn−L ) k k M en−L+2:n−1 , x en−L+1:n−1 ; xn−L ||bn−L+2:n−1 , xn−L+1:n−1 ψen−1,L−1 a I Target: k̄ b n,n−L+1:n ⊗n U1:M (b1:n−L , b̄k̄n,n−L+1:n−1 , k̄)p(x1:n−L , xn−L+1:n |y1:n ) k̄ bn,n−L+1:n k M k̄ ψen,L an−L+2:n , xk ; x b̄ , x n−L n,n−L+1:n n−L+1:n n−L+1:n M en−L+1:n−1 , k; xn−L ) . ψn−1,L−1 (e an−L+2:n−1 , x I Weight: Z̄n−L+1:n /Zen−L+1:n−1 . Exact Approximation and Particle Filters Adam M. Johansen Introduction Approximating the RBPF Block Sampling Particle Filters References Stochastic Volatility Bootstrap Local SMC I Model: f (xi |xi−1 ) =N φxi−1 , σ 2 g(yi |xi ) =N 0, β 2 exp(xi ) I Top Level: I I I Local SMC proposal. Stratified resampling when ESS< N/2. Local SMC Proposal: I Proposal: q(xt |xt−1 , yt ) = f (xt |xt−1 ) I Weighting: W (xt−1 , xt ) ∝ I f (xt |xt−1 )g(yt |xt ) = g(yt |xt ) f (xt |xt−1 ) Resample residually every iteration. Exact Approximation and Particle Filters Adam M. Johansen Introduction Approximating the RBPF Block Sampling Particle Filters References SV Exchange Rata Data Exchange Rate Data 5 4 Observed Values 3 2 1 0 −1 −2 −3 −4 0 100 200 300 400 500 600 700 800 900 n Exact Approximation and Particle Filters Adam M. Johansen Introduction Approximating the RBPF Block Sampling Particle Filters References SV Bootstrap Local SMC: M=100 N = 100, M = 100 100 Average Number of Unique Values 90 80 70 L=2 L=4 L=6 L = 10 60 50 40 30 20 10 0 0 100 200 300 400 500 600 700 800 900 n Exact Approximation and Particle Filters Adam M. Johansen Introduction Approximating the RBPF Block Sampling Particle Filters References SV Bootstrap Local SMC: M=1000 N = 100, M = 1000 100 Average Number of Unique Values 90 80 70 60 L=2 L=4 L=6 L = 10 L = 14 L = 18 50 40 30 20 10 0 0 100 200 300 400 500 600 700 800 900 n Exact Approximation and Particle Filters Adam M. Johansen Introduction Approximating the RBPF Block Sampling Particle Filters References SV Bootstrap Local SMC: M=10000 N=100, M=10,000 100 Average Number of Unique Values 90 80 70 60 50 L=2 L=4 L=6 L = 10 L = 14 L = 18 L = 22 L = 26 40 30 20 10 0 0 100 200 300 400 500 600 700 800 900 n Exact Approximation and Particle Filters Adam M. Johansen Introduction Approximating the RBPF Block Sampling Particle Filters References Some Heuristics Recent calculations suggest that, under appropriate assumptions, at fixed cost (2L − 1) · M · N : I Optimal L is determined solely by the mixing of the HMM. I Optimal M is a linear function of L. I N can then be obtained from M, L and available budget. In practice: I L can be chosen using pilot runs, I and M fine-tuned once L is chosen. Exact Approximation and Particle Filters Adam M. Johansen Introduction Approximating the RBPF Block Sampling Particle Filters References In Conclusion I SMC can be used hierarchically. I Software implementation is not difficult [Joh09, Zho13]. I The Rao-Blackwellized particle filter can be approximated exactly I The optimal block-sampling particle filter can be approximated exactly I Many other things are possible. . . going beyond unbiased random weighting. Exact Approximation and Particle Filters Adam M. Johansen Introduction Approximating the RBPF Block Sampling Particle Filters References References I [AD02] C. Andrieu and A. Doucet. Particle filtering for partially observed Gaussian state space models. Journal of the Royal Statistical Society B, 64(4):827–836, 2002. [ADH10] C. Andrieu, A. Doucet, and R. Holenstein. Particle Markov chain Monte Carlo. Journal of the Royal Statistical Society B, 72(3):269–342, 2010. [CJP13] N. Chopin, P. Jacob, and O. Papaspiliopoulos. SMC2 : an efficient algorithm for sequential analysis of state space models. Journal of the Royal Statistical Society B, 75(3):397–426, 2013. [CL00] R. Chen and J. S. Liu. Mixture Kalman filters. Journal of the Royal Statistical Society B, 62(3):493–508, 2000. [CSOL11] T. Chen, T. Schön, H. Ohlsson, and L. Ljung. Decentralized particle filter with arbitrary state decomposition. IEEE Transactions on Signal Processing, 59(2):465–478, February 2011. [DBS06] A. Doucet, M. Briers, and S. Sénécal. Efficient block sampling strategies for sequential Monte Carlo methods. Journal of Computational and Graphical Statistics, 15(3):693–711, 2006. [GSS93] N. J. Gordon, S. J. Salmond, and A. F. M. Smith. Novel approach to nonlinear/non-Gaussian Bayesian state estimation. IEE Proceedings-F, 140(2):107–113, April 1993. [JD] A. M. Johansen and A. Doucet. The hierarchical particle filter. Unpublished Manuscript. [Joh09] A. M. Johansen. SMCTC: Sequential Monte Carlo in C++. Journal of Statistical Software, 30(6):1–41, April 2009. [JWD12] A. M. Johansen, N. Whiteley, and A. Doucet. Exact approximation of Rao-Blackwellised particle filters. In Proceedings of 16th IFAC Symposium on Systems Identification, Brussels, Belgium, July 2012. IFAC, IFAC. [Zho13] Y. Zhou. vSMC: Parallel sequential Monte Carlo in C++. Mathematics e-print 1306.5583, ArXiv, 2013. Exact Approximation and Particle Filters Adam M. Johansen Introduction Approximating the RBPF Block Sampling Particle Filters References Key Identity M ψn,L (an−L+2:n , xn−L+1:n , k; xn−L ) k M (ak p(xn−L+1:n |xn−L , yn−L+1:n )ψen,L n−L+2:n , xn−L+1:n , k; xn−L ||. . . ) " # k k n n Q bn,n−L+1 b b n,p−1 r(k|wn ) q xn−L+1 |xn−L r bkn,p |wp−1 q xpn,p |xp−1 = p=n−L+2 p(xn−L+1:n |xn−L , yn−L+1:n ) =Zbn−L+1:n /p(yn−L+1:n |xn−L ) Exact Approximation and Particle Filters Adam M. Johansen Introduction Approximating the RBPF Block Sampling Particle Filters References