Ensemble Filter and Smoother Quantifying Uncertainty Sai Ravela M. I. T 2012 1 Quantifying Uncertainty Ensemble Filter and Smoother Uncertainty Propagates in Time-Depdendent Processes X0f X1f X2f Xnf M ≡ M(x n ; αn ) x n+1 = M(x n ; αn ) + ω n M: -Physical or Statistical Model 2 Quantifying Uncertainty Ensemble Filter and Smoother Uncertainty Propagates in Bayesian Networks L T P R F Q Found in Hierarchical Bayes, Graphical Models. 3 Quantifying Uncertainty Ensemble Filter and Smoother Uncertainty Propagates in Spatial Processes Grid nodes Interactions ? 4 Quantifying Uncertainty Ensemble Filter and Smoother Inference Problems 1. Two-point boundary value problems, incl. uncertainty estimation propagation. Fixed Point Smoother. 2. Recursive Bayesian Estimation for Sequential Filtering and Smoothing. 3. Nonlinearity and Dimensionality and Uncertainty: Ensemble Filter & Smoother. 5 Quantifying Uncertainty Ensemble Filter and Smoother Inference Problems 1. Two-point boundary value problems, incl. uncertainty estimation propagation. Fixed Point Smoother. 2. Recursive Bayesian Estimation for Sequential Filtering and Smoothing. 3. Nonlinearity and Dimensionality and Uncertainty: Ensemble Filter & Smoother. Propagating Uncertainty, a first step. 6 Quantifying Uncertainty Ensemble Filter and Smoother Variational Inference 1 −1 (x − x b )T C00 (x 0 − x b )+ 2 0 � � m � 1 T T −1 (y − Hx i ) R (y i − Hx i ) + λi [x i − M(xi−1 ; α)] 2 i J(x 0 ) := i=1 Cannot deal with stochastic model (i.e. model error). Needs a Bayesian formalism. 7 Quantifying Uncertainty Ensemble Filter and Smoother Filters and Smoothers Sequential Filtering: P(x n |y 1 . . . y n ) ∝ P(y n |x n ) � P(x n |x n−1 )P(x n−1 |y 1 . . . y n−1 )(1) xn−1 = P(y n |x n )P(x n |y 1 . . . y n−1 ) (2) = P(y n |x n )P(x nf ) (3) The recursive form is simple when a perfect model is assumed, but the Kolmogorov-Chapman equation has to be used in the presence of model error. P(x n |y 1 . . . y n−1 ) is the forecast distribution or prior distribution also seen as P(x fn ) 8 Quantifying Uncertainty Ensemble Filter and Smoother Write the Objective Sequential Filtering: J(x n ) := 1 (x − x fn )T Pf−1 (x n − x fn ) + 2 n 1 (y − Hx n )T R −1 (y n − Hx n ) 2 n (4) We have assumed a linear observation operator y n = Hx n + η, with η ∼ N(0, R). 9 Quantifying Uncertainty Ensemble Filter and Smoother Find the Stationary Point Sequential Filtering: x̂ n = x fn + Pf H T (HPf H T + R)−1 (y n − Hx fn ) a Pa = x = (H T R −1 H + Pf−1 )−1 = Pf − Pf H T (HPf H T + R)−1 HPf (5) (6) (7) (8) Then, launch a new prediction x fn+1 = M(x n ) and the new uncertainty ∂M (predicted) is Pf = LPa LT , where L = ∂x when the model is n nonlinear. Propagating produces the moments of P(x n+1 |y 1 . . . y n ). 10 Quantifying Uncertainty Ensemble Filter and Smoother Smoother We are interested in the state estimates at all points in an interval, that is: (9) P(x 1 . . . x n |y 1 . . . y n ) The joint distribution can account for model errors, state and parameter errors within its framework. We break it down via Bayes Rule, Conditional Independence and Markov assumption, and marginalization and perfect modelassumption, leading to a coupled set of equations that are recursively solved. 11 Quantifying Uncertainty Ensemble Filter and Smoother Uncertainty Propagation is Expensive Forward(you’ll need this in the end) Cii = ∂M ∂M T Ci−1i−1 0<i ≤m ∂xi−1 ∂xi−1 Backward via information form: ˆImm = H T R −1 H ∂M T ∂M Ii+1i+1 + H T R −1 H ∂xi ∂xi � �−1 ∂M T ˆ ∂M −1 = C00 + I11 ∂x0 ∂x0 Îii = ˆ 00 C 12 Quantifying Uncertainty Ensemble Filter and Smoother The Dimensionality and Nonlinearity Challenges Monte-Carlo � Reduced-rank approximation � Particle Filter Domain Decomposition � Localization, Localized Filters � Scale-recursive Spatial Inference Model Reduction & Interpolation � Snapshots & POD Krylov Subspace Response Surface Models � � Deterministic Equivalent Modeling Method � Stochastic Response Surface Methodology Polynomial Chaos Expansions 13 � Generalized Polynomial Chaos Quantifying Uncertainty Ensemble Filter and Smoother Monte-Carlo • • • • • • • • •• • • • • • • • • • Leading Lyapunov vectors Isotropic Initial Perturbation 14 Quantifying Uncertainty time Ensemble Filter and Smoother Filter-Updating Af = [x f1 . . . x fs ] ⇒ All at time T f f Ãf = [x˜ 1 . . . x˜ s ] NOTE THAT Pf = 1 Ãf ÃfT ⇐ Uncertainty s−1 So, propagate uncertainty through Samples “Integrated” forward. Model is not linearized. 15 Quantifying Uncertainty Ensemble Filter and Smoother No Linearization y = h(x) + η, η ∼ N(0, R) Z = [y + η 1 , . . . , y + η s ] ← Perturbed Observations R≈ 1 ˜ Z · Z̃ T s−1 Also, let Ωf = h(Af ) = [h(x f1 ) . . . h(x fs )] Ω̃f defined similarly 16 Quantifying Uncertainty Ensemble Filter and Smoother Uncorrelated Noise Note ˜ fT + Z̃ T ) = (Ω ˜ f Ω̃fT + Z̃ Z̃ T ) (Ω̃f + Z̃ )(Ω When observation noise is uncorrelated with state ≡ an assumption Let x a be the estimate, analysis, ‘posterior’ rv. Aa and Ãa similarly, defined. 17 Quantifying Uncertainty Ensemble Filter and Smoother Easy Formulation Aa = Af + Ãf Ω̃fT Ω̃f Ω̃fT + Z̃ Z̃ T −1 Z − Ωf Identical to KF/EKF in linear/linearized case ⇒ No linearization of the model ⇒ No explicit uncertainty (covariance) propagation ˜f Ω ˜ fT + Z̃ Z̃ T Ω −1 ˜ fT + Z̃ T ] = [Ω̃f + Z̃ ][Ω = (CC T )−1 18 Quantifying Uncertainty −1 Ensemble Filter and Smoother Solution Let C = [U S VT] [CC T ]−1 = US −2 U T = (US −1 )(US −1 )T √ √ T = D D =D 19 Quantifying Uncertainty Ensemble Filter and Smoother Fast Calculation Aa = Af + Ãf Ω̃fT [US −2 U T ][Z − Ωf ] (n, s) (n, s) (n, s)(s, n)(n, s)(s, s)(s, n)(n, s) (n, s) Return by right to left, multiply; FAST, low-dimensional Aa =Af + Ãf X5 =Af (Is + X4 ) =Af X5 A “weakly” nonlinear transformation (X5 ≡ X5 (Af )) 20 Quantifying Uncertainty Ensemble Filter and Smoother Time Dependent Example Lorentz ẋ = −xi−2 xi−1 + xi−1 xi+1 − xi + u + uU = xi−1 [xi+1 − xi−2 ] − xi U U Dissipative Advective Chaotic Filter 21 Quantifying Uncertainty Forcing Ensemble Filter and Smoother Need to Get multimedia WORKING Play ENKFLP.wmv! Chalk Talk: Method 2. Demo: Matlab. Demo: PI Bottle. 22 Quantifying Uncertainty Ensemble Filter and Smoother Plug and Play So, • •• • x0 • • •• • x1 y1 Aa0 = Af0 Is ← No measurement Aa1 = Af1 X 51 ← Filter, same as X5 As1 = Aa1 Is ← No future measurement −2 T ˜ fT As = Aa + Ãa Ω U1 ][Z1 − Ωf1 ] 1 [U1 S 0 0 0 1 = Aa0 X 51 Note: X 5 here is same as X5 in earlier slide. 23 Quantifying Uncertainty Ensemble Filter and Smoother Send me a message On the graph y1 x0 x1 X 51 Message sent from x 1 to x 0 (X 51 ) x 0 smoothed by y 1 i.e As0 ∼ Pr (x 0 |y 1 ) 24 Quantifying Uncertainty Ensemble Filter and Smoother Fixed Interval & Fixed Lag Fixed Interval Y1 x0 x1 x2 x3 Yn−1 Yn xn−1 xn P(x 0 |y 1 · · · y n ) P(x 1 |y 1 · · · Yn ) .. . ⎫ ⎪ ⎬ Smoother ⎪ ⎭ P(x n |y 1 · · · y n ) ← Filter 25 Quantifying Uncertainty Ensemble Filter and Smoother Fixed Interval & Fixed Lag Fixed Lag Y1 x0 x1 x2 x3 Y1 x0 x1 x2 x3 Yn−1 Yn xn−1 xn Yn−1 Yn xn−1 xn ∼ P(x |y . . . y ), P(x 0 |y 1 . . . y n ) = 0 1 L P(x i |Y0 . . . y i+L ) Smothed up to a “window” 26 Quantifying Uncertainty (L < n) Ensemble Filter and Smoother Fixed Interval: The Dumb Way Fixed Interval: The Dumb Way 27 Quantifying Uncertainty Ensemble Filter and Smoother Backward Recursion Key Assumption: Jointly Gaussian Distributions. Aks = N N a Ak X 5j j=k +1 Ck = N N X 5j = X 5k +1 Ck +1 j=k +1 28 Quantifying Uncertainty Ensemble Filter and Smoother Interval: New Normal FixedFixed Interval: TheThe New Normal 29 Quantifying Uncertainty and T=[0, Ensemble 1, 2,..., Filter and99]. SmootherLorenz and Emanuel (1998) associate the dimensionless time step 0.01 with a real time ofInterval 1.2 h, implying that our measurement interval Fixed Lorenz Fixed Interval onOn Lorenz corresponds to 6 h and our fixed-interval smoothing window is 120 h. Figure 1 compares the estimation error (over all states) obtained from an ensemble Kalman filter algorithms s tional time smoothing p (N/n) is ty efficient very expected as Fig. 1 Comparison of V1 and FBF with ensemble Kalman filter (EnKF). The error is computed between the analysis ensemble mean and truth. Observations are spaced every five model steps, the 30 interval length is 100 and smoothed analyses are sought at every model time step. As expected, V1 and FBF give identical estimates; they only differ in computational requirements Quantifying Uncertainty Fig. 2 Comp smoothing est parameters are give identical Short fixed la while longer smoother (com Ensemble Filter and Smoother CostsCosts of130Inference, ToyToy Problem of Inference, Problem 35 Computational Time (s) 30 25 20 15 10 5 0 90 50 100 FB Fig. 4 Comp throughout fix interval smoot option (which lag option is sh faster than V1 31 Quantifying Uncertainty that V1 will require more computauel (1998) algorithms suggests Ensemble Filter and Smoother tional time when R>1+2N/sn. In practical intervala real time Fixed Lag smoothing problems the ratio of ensemble to state size nt Fixed interval Lag smoothing (N/n) is typically very small so FBF becomes more mation error efficient very rapidly. The superior performance of FBF is alman filter expected as V1 computation time grows quadratically with Fixed Lag Smoother Fixed Lag Smoother Kalman filter semble mean el steps, the ght at every cal estimates; Fig. 2 Comparison of V1-lag and FIFO-lag fixed-lag ensemble smoothing estimates for different lag window lengths. The other parameters are identical to those used in Fig. 1. V1-lag and FIFO-lag give identical estimates although there can be numerical differences. 32 Short fixed lags give results closer to the ensemble Kalman filter, while longer fixed lags give results closer to the fixed interval smoother (compare to Fig. 1) Quantifying Uncertainty Ensemble Filter and Smoother FixedFixed Lag:Lag: The The Dumb Way Dumb Way 35 Computational Time (s) 30 25 20 15 10 5 0 90 50 100 FBF 1 2 3 4 5 6 7 8 V1-lag---> 9 10 11 12 13 Fig. 4 Computational times required to estimate model states 33 500, and 900 for FBF (fixedthroughout fixed intervals of 100, interval smoothing) and V1-lag (fixed-lag smoothing). The FBF option (which does not depend on lag value) is shown at far left. V1Quantifying Uncertainty lag option is shown for a range of lags from one through 13. FBF is Ensemble Filter and Smoother Fixed Lag is FIFO Ask = Aka kN +w X 5j j=k +1 = Aak Ck Ck = X 5k−1 Ck −1 X 5k +w 34 Quantifying Uncertainty han V1-lag, ween FIFOe expensive dent of the lengths are ur conservahe threshold shows. othing as an s computan the two is ive than V1 mparison of g is more FBF is faster h and it is or an intermputational n=100 and Computational Time (s) Ensemble Filter and Smoother nly a modest observed time, i.e. s<1, these bounds can worsen, but not g, with the in Lag: most practical situations the ratio N/sn can still be Fixed The New Normal FixedatLag: Theto New length expected remain Normal much smaller than 1. . 12 10 8 6 4 2 0 900 900 500 500 100 FBF 100 1 2 3 4 5 6 7 8 FIFO-Lag 9 10 11 12 13 Fig. 5 Computational times required to estimate model states throughout fixed intervals of 100, 500, and 900 for FBF (fixedinterval smoothing) and FIFO-lag (fixed-lag smoothing). The FBF option (which does not depend on lag value) is shown at far left. The FIFO-lag option is shown for a range of lags from one through 13. FBF is faster than FIFO-lag by 35 a fixed factor. FIFO-lag computational time is nearly independent of lag (small fluctuations are related to random differences in time required to perform singular Quantifying Uncertainty value decompositions at different lags) Ensemble Filter and Smoother We need to fix the multimedia! Watch FLKSO.wmv! Reading: Ravela and McLaughlin, Fast Ensemble Smoothing, Ocean Dynamics, 2007 Schneider 2001: Analysis of incomplete climate data: Estimation of mean values and covariance matrices and imputation of missing values, Journal of Climate 36 Quantifying Uncertainty Ensemble Filter and Smoother Where does ensemble come from? singular vectors • • •• • P1f • •• • P0f Low dimensional Subspace Span {u (0) . . . u (N) } (0) u 0 → L0 ≈ ∂M ∂x (0) → u1 x=x0 37 Quantifying Uncertainty Ensemble Filter and Smoother Things get tough... the Tough linearize Thus x 1 = M(x 0 ) = M(x̄ 0 + x̃ 0 ) ∂M = M(x̄ 0 ) + x̃ ∂x X =x̄ 0 0 x̃1 = Lx̃0 (k ) (k ) u 1 = Lu 0 38 Quantifying Uncertainty Ensemble Filter and Smoother Eigenvalue Problem Now,let C1 be a metric on vector u 1 and let C0 be a metric on u 0 λ= < Lu 0 , C1 Lu 0 > < u 0 , L# C1 Lu 0 > = < u 0 , C0 u 0 > < u 0 , C0 u 0 > Maximize ratio for the k th perturbation: λk : (k ) (k ) ⇒ L# C1 Lu 0 = λk C0 u 0 Which is a generalized eigenvalue problem. Note that when C1 = I, (k ) and C0 = P0f then u 1 are leading directions of P1f 39 Quantifying Uncertainty Ensemble Filter and Smoother SV aproach Notes � Adjoint & TLM not easy to calculate but robust. I I � L may be really large too! How can we reduce L? I � Sensitivity to norm. 40 Quantifying Uncertainty Ensemble Filter and Smoother Breeding • •• • • • •• • Initial Perturbation Align with leading directions of error growth (Lyapunov vectors) Q R | i+1{z i+1} Q R decomposition Q0 ≡ I = |{z} L Qi TLM Q0 → Qi · · · Qk |{z} forgetsQ0 41 Quantifying Uncertainty Ensemble Filter and Smoother It’s easy to breed 1. Generate “random” initial perturbation 2. Let it grow; renormalize. (i.e propagate it) 3. Repeat ⇒ Breeding vectors How many bred vectors ? ⇒ Size of L? 42 Quantifying Uncertainty Ensemble Filter and Smoother Ways to simplify Models for Uncertainty Propagation 1. Spectral Truncation: Find a few leading directions of Covariance or Model and propagate them. Breed Vectors. Calculate a reduced local linear model from ensemble. 2. Localization: Localize filtering and smoothing, use scale-recursive decomposition. 3. Model Reduction: Reduce order of linearized model, construct a reduced model from snapshots. 4. Sample Input-Output pairs to create a simple auxiliary model. 43 Quantifying Uncertainty Ensemble Filter and Smoother Model Reduction Model Reduction Structure Krylov SVD Nonlinear POD Empirical Grammian Linear Balanced Truncation Hankel approx. SVD Krylov 44 Quantifying Uncertainty Lanczos Arnoldi etc. Ensemble Filter and Smoother Model Bypass – Non-Intrusive Approaches X0 M X1 −1 C10 C00 Response Surface Modeling, Polyno­ mial Chaos. 45 Quantifying Uncertainty Ensemble Filter and Smoother Extra-Special on Covariance Representations If we have a large covariance matrix C nonetheless representable by computer and if we know it is a block-circulant matrix, then the Fourier Transform can be used to diagonalize it: D = UCU T (10) For the unitary transform U, and D is diagonal. So, subsequent processing with covariance is simplified, provided the model and state can be also expressed in fourier domain. Uδxn+1 = δξn+1 T −1 δxn Cn δxn = = ∂M T U Uxn ∂x LF δξn δξ T Dn−1 δξ U Spectral truncation to a few wave numbers in U also leads to a reduced order model. Incidentally, similar process for wavelet 46 decomposition. DO MATLAB EXAMPLE Quantifying Uncertainty (11) (12) (13) Ensemble Filter and Smoother Iterative calculation If a covariance C has eigen vectors U and eigenvalues λ, i.e. CU = UΛ, then we may recursively calucate the leading modes in U because: N � X C= u k λkk u Tk (14) k =1 Where U = [u 1 . . . u N ] and Λ = diag(λ11 , . . . , λNN ), in decreasing order. Let C11 = C, and iteratively calculate: for k = 1 . . . N {u k , λkk } = LeadingEig(Ckk ) Ck +1k +1 = Ckk − u k λkk u Tk We need a procedure to calculate the leading Eigenvector and Eigenvalue. 47 Quantifying Uncertainty (15) (16) (17) (18) Ensemble Filter and Smoother Basic approach: Power Iteration WARNING: There are many advanced methods for calculating eigen vectors and eigen values iteratively and one should use them (e.g. from ARPACK). Here, we provide an intuition for the process. To calculate the leading vector of C, let us consider a vector in the basis z, which we may expand as: z= N X � ck u k (19) k =1 Now, we can write for the nth power of C: n C z = N X � ck C n u k (20) ck λnkk u k (21) k =1 = N X � k =1 HOW? 48 Quantifying Uncertainty Ensemble Filter and Smoother Power Iteration Continued Cnz = c1 λn11 (u 1 + N � X ck λnkk u ) c1 λn11 k (22) k =2 Defining z n = C n z, we note that zn → u1 ||z n || n→∞⇒ Algorithm PowerIteration(C): Initialize z; z ← z ||z|| Iterate: t ← Cz, z ← t ||t|| 49 Quantifying Uncertainty (23) Ensemble Filter and Smoother LeadingEig(C) u = PowerIteration(C) λ = u T Cu return(u, λ) end 50 Quantifying Uncertainty (24) (25) (26) Ensemble Filter and Smoother But the Covariance is too LARGE! � I I � The preceding discussion is all fine, but often the dimensionality is such that we have a really large covariance that cannot be represented. Fortunately, many physical problems have only a few modes of interest which we represent through data, e.g. an ensemble. So we begin with a skinny matrix X , and assume the covariance is C = XX T . We would like a representation without explicitly calculating C and exploiting the rank-deficiency due to a skinny X. 51 Quantifying Uncertainty Ensemble Filter and Smoother Alternate form � I � I � I � I � I Let X = USV T be the singular value decomposition and here Sii ≥ Si+1i+1 . Then C = UΛU T where Λ = S 2 We will calculate only a few top left and right singular vectors and singular values iteratively for a reduced order representation Cd = Ud Λd UdT . Note that because X is skinny, i.e. it is of size n × N with N << n. We may further only pick d modes, d ≤ N. We would like a representation of Cd without explicitly calculating it. Notice that D = X T X is a small matrix when X is skinny. 52 Quantifying Uncertainty Ensemble Filter and Smoother Alternate form � I � I Let X = USV T be the singular value decomposition and here Sii ≥ Si+1i+1 . Then D = X T X = V ΛV T where Λ = S 2 , a small matrix. We calculate the eigen vectors and eigen values of D recursively. Let D1 = D; and for k = 1 . . . d vk λkk = = = PowerIteration(Dk ) v Tk Dk v k Dk − v k λkk v Tk Dk +1 √ Noting that Sd = Λd , we obtain Ud as a skinny nxd matrix: Ud = XVd Sd−1 Store Ud and Λd and use them to calculate the norm in an application. DEMO IN MATLAB 53 Quantifying Uncertainty (27) (28) (29) (30) Ensemble Filter and Smoother Applicable to Processes ∂θ (x, t) = F θ(x, t) → System ∂t ∂θ R(θ) = − F θ → Residual ∂t θ = uη(t) → KLT (POD or Krylov) u T R = 0 → Galerkin Projection ∂η = u T Fuη → ROM ∂t 54 Quantifying Uncertainty MIT OpenCourseWare http://ocw.mit.edu 12.S990 Quantifying Uncertainty Fall 2012 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.