Presentation is loading. Please wait.

Presentation is loading. Please wait.

Al Parker January 18, 2009 Accelerating Gibbs sampling of Gaussians using matrix decompositions.

Similar presentations


Presentation on theme: "Al Parker January 18, 2009 Accelerating Gibbs sampling of Gaussians using matrix decompositions."— Presentation transcript:

1 Al Parker January 18, 2009 Accelerating Gibbs sampling of Gaussians using matrix decompositions

2 Colin Fox, Physics, University of Otago New Zealand Institute of Mathematics, University of Auckland Center for Biofilm Engineering,, Bozeman Acknowledgements

3 The multivariate Gaussian distribution

4 y = Σ 1/2 z+ µ ~ N(µ,Σ) How to sample from a Gaussian N(µ,Σ)? Sample z ~ N(0, I ) (eg y = WΛ 1/2 z + µ)

5 Example: From 64 faces, modeling “face space” with a Gaussian Process N(μ,Σ) Pixel intensity at the ith row and jth column is y(s(i,j)), y(s) є R 112 x R 112 μ(s) є R 112 x R 112 Σ(s,s) є R 12544 x R 12544

6 ~N(,Σ)

7 A bigger example: data = SPHERE + ε, Sample from π(SPHERE|data) ε ~ N(0,σ 2 I)

8 The problem To generate a sample y = Σ 1/2 z+ µ ~ N(µ,Σ), how to calculate the factorization Σ =Σ 1/2 (Σ 1/2 ) T ? Σ 1/2 = WΛ 1/2 by eigen-decomposition, 10/3n 3 flops Σ 1/2 = C by Cholesky factorization, 1/3n 3 flops For LARGE Gaussians (n>10 5, eg in image analysis and global data sets), these approaches are not possible n 3 is computationally TOO EXPENSIVE storing an n x n matrix requires TOO MUCH MEMORY

9 Some solutions Work with sparse precision matrix Σ -1 models (Rue, 2001) Circulant embeddings (Gneiting et al, 2005) Iterative methods: Advantages: – COST: n 2 flops per iteration – MEMORY: Only vectors of size n x 1 need be stored Disadvantages: – If the method runs for n iterations, then there is no cost savings over a direct method

10 Gibbs: an iterative sampler of N(0,A) and N(0, A -1 ) Let A=Σ or A= Σ -1 1.Split A into D=diag(A), L=lower(A), L T =upper(A) 2.Sample z ~ N(0, I ) 3.Take conditional samples in each coordinate direction, so that a full sweep of all n coordinates is y k =-D -1 L y k - D -1 L T y k-1 + D -1/2 z y k converges in distribution geometrically to N(0,A -1 ) Ay k converges in distribution geometrically to N(0,A)

11 Gibbs: an iterative sampler Gibbs sampling from N(µ,Σ) starting from (0,0)

12 Gibbs: an iterative sampler Gibbs sampling from N(µ,Σ) starting from (0,0)

13 What’s the link to Ax=b? Solving Ax=b is equivalent to minimizing an n- dimensional quadratic (when A is spd) A Gaussian is sufficiently specified by the same quadratic (with A= Σ -1 and b=Aμ):

14 Gauss-Siedel Linear Solve of Ax=b 1.Split A into D=diag(A), L=lower (A), L T =upper(A) 2.Minimize the quadratic f(x) in each coordinate direction, so that a full sweep of all n coordinates is x k =-D -1 L x k - D -1 L T x k-1 + D -1 b x k converges geometrically A -1 b

15 Gauss-Siedel Linear Solve of Ax=b

16 x k converges geometrically A -1 b, (x k - A -1 b) = G k ( x 0 - A -1 b) where ρ(G) < 1

17 Theorem: A Gibbs sampler is a Gauss Siedel linear solver Proof: A Gibbs sampler is y k =-D -1 L y k - D -1 L T y k-1 + D -1/2 z A Gauss-Siedel linear solve of Ax=b is x k =-D -1 L x k - D -1 L T x k-1 + D -1 b

18 Gauss Siedel is a Stationary Linear Solver A Gauss-Siedel linear solve of Ax=b is x k =-D -1 L x k - D -1 L T x k-1 + D -1 b Gauss Siedel can be written as M x k = N x k-1 + b where M = D + L and N = D - L T, A = M – N, the general form of a stationary linear solver

19 Stationary linear solvers of Ax=b 1.Split A=M-N 2.Iterate Mx k = N x k-1 + b 1.Split A=M-N 2.Iterate x k = M -1 Nx k-1 + M -1 b = Gx k-1 + M -1 b x k converges geometrically A -1 b, (x k - A -1 b) = G k ( x 0 - A -1 b) when ρ(G) = ρ(M -1 N)< 1

20 Stationary Samplers from Stationary Solvers Solving Ax=b: 1.Split A=M-N 2.Iterate Mx k = N x k-1 + b x k  A -1 b if ρ(M -1 N)< 1 Sampling from N(0,A) and N(0,A -1 ): 1.Split A=M-N 2.Iterate My k = N y k-1 + c k-1 where c k-1 ~ N(0, M T + N) y k  N(0,A -1 ) if ρ(M -1 N)< 1 Ay k  N(0,A) if ρ(M -1 N)< 1

21 How to sample c k-1 ~ N(0, M T + N) ? Gauss Siedel M = D + L, c k-1 ~ N(0, D) SOR (successive over-relaxation) M = 1/wD + L, c k-1 ~ N(0, (2-w)/w D) Richardson M = I, c k-1 ~ N(0, 2I-A ) Jacobi M = D, c k-1 ~ N(0, 2D-A )

22 Theorem: Stat Linear Solver converges iff Stat Sampler converges and the convergence is geometric Proof: They have the same iteration operator: For linear solves: x k = Gx k-1 + M -1 b so that (x k - A -1 b) = G k ( x 0 - A -1 b) For sampling: y k = Gy k-1 + M -1 c k-1 E(y k )= G k E(y 0 ) Var(y k ) = A -1 - G k A -1 G kT Proof for Gaussians given by Barone and Frigessi, 1990. For arbitrary distributions by Duflo, 1997

23 Acceleration schemes for stationary linear solvers can be used to accelerate stationary samplers Polynomial acceleration of a stationary solver of Ax=b is 1. Split A = M - N 2. x k+1 = (1- v k ) x k-1 + v k x k + v k u k M -1 (b-A x k ) which replaces (x k - A -1 b) = G k ( x 0 - A -1 b) with a k th order polynomial (x k - A -1 b) = p(G)( x 0 - A -1 b)

24 Chebyshev acceleration x k+1 = (1- v k ) x k-1 + v k x k + v k u k M -1 (b-A x k ) where v k, u k are functions of the 2 extreme eigenvalues of G (not very expensive to get estimates of these eigenvalues) Gauss-Siedel converged like this …

25 x k+1 = (1- v k ) x k-1 + v k x k + v k u k M -1 (b-A x k ) where v k, u k are functions of the 2 extreme eigenvalues of G (not very expensive to get estimates of these eigenvalues) … convergence (geometric-like) with Chebyshev acceleration

26 x k+1 = (1- v k ) x k-1 + v k x k + v k u k M -1 (b-A x k ) where v k, u k are functions of the residuals b-Ax k … convergence guaranteed in n finite steps with CG acceleration Conjugate Gradient (CG) acceleration

27 Polynomial accelerated sampler of N(0,A -1 ) if v k, u k are independent of the iterates y k,c k 1. Split A = M - N 2. y k+1 = (1- v k ) y k-1 + v k y k + v k u k M -1 (c k -A y k ) where c k ~ N(0, (2-v k )/v k ( (2 – u k )/ u k M + N)

28 Gibbs sampler Chebyshev accelerated Gibbs Chebyshev accelerated Gibbs sampler in 2D

29 Chebyshev accelerated Gibbs sampler in 100D Covariance matrix convergence ||A -1 – S k || 2

30 Chebyshev accelerated Gibbs sample in 10 6 D ~N(0,Laplacian -1 )

31 The polynomial accelerated sampler presented here does not apply since the parameters v k, u k are functions of the residuals c k - A y k Colin devised an approach called the conjugate direction sampler Conjugate Gradient (CG) acceleration

32 Lanczos sampler Iterative eigen-solvers can also be hijacked to produce samples as well as eignenvalues.

33 One extremely effective sampler for LARGE Gaussians Use a combination of the ideas presented: Use the Lanczos or CD sampler to generate samples and estimates of the extreme eigenvalues of G. Seed these samples and extreme eigenvalues into a Chebyshev accelerated SOR sampler

34 Conclusions Common techniques from numerical linear algebra can be used to sample from Gaussians Cholesky factorization (precise but expensive) Any stationary linear solver can be used as a stationary sampler (inexpensive but with geometric convergence) Polynomial accelerated Samplers – Chebyshev – Conjugate Gradients Lanczos Sampler

35

36 Estimation of Σ(θ,r) from the data using a a Markov Chain

37 Marginal Posteriors

38 Simulating the process: samples from N(μ,Σ|data) x = Σ 1/2 z + µ ~N(μ, ) TOO COURSE OF A GRID

39 Why is CG so fast? Gauss Siedel’s Coordinate directions CG’s conjugate directions

40 Simulating the process: samples from N(μ,Σ) y = Σ 1/2 z + µ ~N(μ, )

41 Chebyshev accelerated Gibbs sampler in 10 6 D b = SPHERE + ε, ε ~ N(0,σ 2 I), SNR=.5

42

43 Chebyshev accelerated Gibbs sampler in 10 6 D

44

45 A GOOD THING: The CG algorithm is a great linear solver! If the eigenvalues of A are in c clusters, then a solution to Ax=b is found in c << n steps. A PROBLEM: When the CG residuals get small, the CD sampler is forced to stop after only c << n steps. Thus, covariances with well separated eigenvalues work well. The covariance of the CD samples y k ~ N(0,A -1 ) and Ay k ~ N(0,A) have the correct covariances if A’s eigenvectors in the Krylov space spanned by the residuals have small/large eigenvalues. CD sampler (CG accelerated Gibbs)

46 Another example: Interpolation

47 One can assume a covariance function which has some parameters θ

48 I used a Bayesian posterior for θ|data to construct μ|data

49 Simulating the process: samples from N(μ,Σ|data) y = Σ 1/2 z + µ ~N(μ, )

50 Gaussian Processes modeling global ozone Cressie and Johannesson, Fixed rank kriging for very large spatial datasets, 2006

51 Gaussian Processes modeling global ozone

52 Chebyshev accelerated Gibbs sampler in 10 6 D data = SPHERE + ε Sample from π(SPHERE|data)


Download ppt "Al Parker January 18, 2009 Accelerating Gibbs sampling of Gaussians using matrix decompositions."

Similar presentations


Ads by Google