[width=2cm]biipslogosmooth biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...smc...

72
Biips software: Bayesian inference with interacting particle systems Rencontres AppliBUGS Adrien Todeschini , Franc ¸ois Caron * , Pierrick Legrand , Pierre Del Moral and Marc Fuentes Inria Bordeaux, * Univ. Oxford, UNSW Sydney Montpellier, Novembre 2014 A. Todeschini 1 / 39

Upload: others

Post on 13-Jun-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Biips software: Bayesian inference with interactingparticle systems

Rencontres AppliBUGS

Adrien Todeschini†, Francois Caron∗, Pierrick Legrand†, Pierre DelMoral‡ and Marc Fuentes†

†Inria Bordeaux, ∗Univ. Oxford, ‡UNSW Sydney

Montpellier, Novembre 2014

A. Todeschini 1 / 39

Page 2: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Outline

Context

Graphical models and BUGS language

SMC

Biips software

Particle MCMC

A. Todeschini 2 / 39

Page 3: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Summary

Context

Graphical models and BUGS language

SMC

Biips software

Particle MCMC

A. Todeschini 3 / 39

Page 4: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Context

Biips = Bayesian inference with interacting particle systems

Bayesian inferenceI Sample from a posterior distribution p(X|Y ) = p(X,Y )

p(Y )I High dimensional, arbitrary complexityI Simulation methods: MCMC, SMC...

MotivationI Last 20 years: success of SMC in many applicationsI No general and easy-to-use software for SMC

A. Todeschini 4 / 39

Page 5: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Context

Biips = Bayesian inference with interacting particle systems

Bayesian inferenceI Sample from a posterior distribution p(X|Y ) = p(X,Y )

p(Y )I High dimensional, arbitrary complexityI Simulation methods: MCMC, SMC...

MotivationI Last 20 years: success of SMC in many applicationsI No general and easy-to-use software for SMC

A. Todeschini 4 / 39

Page 6: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Context

Biips = Bayesian inference with interacting particle systems

ObjectivesI BUGS language compatibleI Extensibility: custom functions/samplersI Black-box SMC inference engineI Interfaces with popular software: Matlab/Octave, RI Post-processing tools

A. Todeschini 5 / 39

Page 7: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Summary

Context

Graphical models and BUGS language

SMC

Biips software

Particle MCMC

A. Todeschini 6 / 39

Page 8: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Graphical models

X1

X2 X3

Y1 Y2

Directed acyclic graph

The graph displays a factorization of thejoint distribution:

p(x1:3, y1:2)

A. Todeschini 7 / 39

Page 9: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Graphical models

X1

X2 X3

Y1 Y2

Directed acyclic graph

The graph displays a factorization of thejoint distribution:

p(x1:3, y1:2) = p(x1) p(x2|x1) p(y1|x2)p(x3|x1, x2) p(y2|x2, x3)

A. Todeschini 7 / 39

Page 10: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Graphical models

X1

X2 X3

Y1 Y2

Directed acyclic graph

The graph displays a factorization of thejoint distribution:

p(x1:3, y1:2) = p(x1) p(x2|x1) p(y1|x2)p(x3|x1, x2) p(y2|x2, x3)

A. Todeschini 7 / 39

Page 11: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Graphical models

X1

X2 X3

Y1 Y2

Directed acyclic graph

The graph displays a factorization of thejoint distribution:

p(x1:3, y1:2) = p(x1) p(x2|x1) p(y1|x2)p(x3|x1, x2) p(y2|x2, x3)

A. Todeschini 7 / 39

Page 12: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Graphical models

X1

X2 X3

Y1 Y2

Directed acyclic graph

The graph displays a factorization of thejoint distribution:

p(x1:3, y1:2) = p(x1) p(x2|x1) p(y1|x2)p(x3|x1, x2) p(y2|x2, x3)

A. Todeschini 7 / 39

Page 13: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Graphical models

X1

X2 X3

Y1 Y2

Directed acyclic graph

The graph displays a factorization of thejoint distribution:

p(x1:3, y1:2) = p(x1) p(x2|x1) p(y1|x2)p(x3|x1, x2) p(y2|x2, x3)

A. Todeschini 7 / 39

Page 14: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

BUGS languageI S-like declarative language for describing graphical modelsI Stochastic relationsI Deterministic relations

Linear regression:model {

Y ∼ dnorm(mu, tau)

tau ∼ dgamma(0.01, 0.01)mu <- beta * X + alphaalpha ∼ dnorm(0, 1E-6)beta ∼ dnorm(0, 1E-6)

}

Goal:Estimate p(α, β, τ |X,Y )

Y

µ τ

0.01αβX

βX

0 1E-6

A. Todeschini 8 / 39

Page 15: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

BUGS languageI S-like declarative language for describing graphical modelsI Stochastic relationsI Deterministic relations

Linear regression:model {

Y ∼ dnorm(mu, tau)

tau ∼ dgamma(0.01, 0.01)mu <- beta * X + alphaalpha ∼ dnorm(0, 1E-6)beta ∼ dnorm(0, 1E-6)

}

Goal:Estimate p(α, β, τ |X,Y )

Y

µ τ

0.01αβX

βX

0 1E-6

A. Todeschini 8 / 39

Page 16: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

BUGS languageI S-like declarative language for describing graphical modelsI Stochastic relationsI Deterministic relations

Linear regression:model {

Y ∼ dnorm(mu, tau)tau ∼ dgamma(0.01, 0.01)

mu <- beta * X + alphaalpha ∼ dnorm(0, 1E-6)beta ∼ dnorm(0, 1E-6)

}

Goal:Estimate p(α, β, τ |X,Y )

Y

µ τ

0.01αβX

βX

0 1E-6

A. Todeschini 8 / 39

Page 17: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

BUGS languageI S-like declarative language for describing graphical modelsI Stochastic relationsI Deterministic relations

Linear regression:model {

Y ∼ dnorm(mu, tau)tau ∼ dgamma(0.01, 0.01)mu <- beta * X + alpha

alpha ∼ dnorm(0, 1E-6)beta ∼ dnorm(0, 1E-6)

}

Goal:Estimate p(α, β, τ |X,Y )

Y

µ τ

0.01αβX

βX

0 1E-6

A. Todeschini 8 / 39

Page 18: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

BUGS languageI S-like declarative language for describing graphical modelsI Stochastic relationsI Deterministic relations

Linear regression:model {

Y ∼ dnorm(mu, tau)tau ∼ dgamma(0.01, 0.01)mu <- beta * X + alphaalpha ∼ dnorm(0, 1E-6)beta ∼ dnorm(0, 1E-6)

}

Goal:Estimate p(α, β, τ |X,Y )

Y

µ τ

0.01αβX

βX

0 1E-6

A. Todeschini 8 / 39

Page 19: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

BUGS languageI S-like declarative language for describing graphical modelsI Stochastic relationsI Deterministic relations

Linear regression:model {

Y ∼ dnorm(mu, tau)tau ∼ dgamma(0.01, 0.01)mu <- beta * X + alphaalpha ∼ dnorm(0, 1E-6)beta ∼ dnorm(0, 1E-6)

}

Goal:Estimate p(α, β, τ |X,Y ) Y

µ τ

0.01αβX

βX

0 1E-6

A. Todeschini 8 / 39

Page 20: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

BUGS software using MCMC

BUGS = Bayesian inference Using Gibbs Sampling

I WinBUGS, OpenBUGS, JAGS [Plummer, 2012]I Expert system automatically derives MCMC methods (Gibbs, Slice,

Metropolis, ...) in a ‘black-box’ fashionI Very popular among practitioners, applying MCMC methods to a

wide range of applications [Lunn et al., 2012]

A. Todeschini 9 / 39

Page 21: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Summary

Context

Graphical models and BUGS language

SMC

Biips software

Particle MCMC

A. Todeschini 10 / 39

Page 22: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Ordering of the graph

X1 Y1 X2 Y4

Y3

X3

Y4

Y2

X1 Y1 X2 Y4

Y3

X3

Y4

Y2

1 2 5

3

4

6

7

Topological sort (with priority tomeasurement nodes):( X1︸︷︷︸

X′1

, Y1, Y3︸ ︷︷ ︸Y′

1

, X3, X2︸ ︷︷ ︸X′

2

, Y4, Y2︸ ︷︷ ︸Y′

2

)

Rearrangement of thedirected acyclic graph:

X′1

Y′1

X′2

Y′2

The statistical modeldecomposes asp(x′1, x

′2, y′1, y′2) =

p(x′1)p(y′1|x′1)

p(x′2|x′1, y′1)p(y′2|x

′2)

A. Todeschini 11 / 39

Page 23: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Ordering of the graph

X1 Y1 X2 Y4

Y3

X3

Y4

Y2

1 2 5

3

4

6

7

Topological sort (with priority tomeasurement nodes):(X1, Y1, Y3, X3, X2, Y4, Y2)

X1 Y1 X2 Y4

Y3

X3

Y4

Y2

1 2 5

3

4

6

7

Topological sort (with priority tomeasurement nodes):( X1︸︷︷︸

X′1

, Y1, Y3︸ ︷︷ ︸Y′

1

, X3, X2︸ ︷︷ ︸X′

2

, Y4, Y2︸ ︷︷ ︸Y′

2

)

Rearrangement of thedirected acyclic graph:

X′1

Y′1

X′2

Y′2

The statistical modeldecomposes asp(x′1, x

′2, y′1, y′2) =

p(x′1)p(y′1|x′1)

p(x′2|x′1, y′1)p(y′2|x

′2)

A. Todeschini 11 / 39

Page 24: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Ordering of the graph

X1 Y1 X2 Y4

Y3

X3

Y4

Y2

1 2 5

3

4

6

7

Topological sort (with priority tomeasurement nodes):( X1︸︷︷︸

X′1

, Y1, Y3︸ ︷︷ ︸Y′

1

, X3, X2︸ ︷︷ ︸X′

2

, Y4, Y2︸ ︷︷ ︸Y′

2

)

Rearrangement of thedirected acyclic graph:

X′1

Y′1

X′2

Y′2

The statistical modeldecomposes asp(x′1, x

′2, y′1, y′2) =

p(x′1)p(y′1|x′1)

p(x′2|x′1, y′1)p(y′2|x

′2)

A. Todeschini 11 / 39

Page 25: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Ordering of the graph

X1 Y1 X2 Y4

Y3

X3

Y4

Y2

1 2 5

3

4

6

7

Topological sort (with priority tomeasurement nodes):( X1︸︷︷︸

X′1

, Y1, Y3︸ ︷︷ ︸Y′

1

, X3, X2︸ ︷︷ ︸X′

2

, Y4, Y2︸ ︷︷ ︸Y′

2

)

Rearrangement of thedirected acyclic graph:

X′1

Y′1

X′2

Y′2

The statistical modeldecomposes asp(x′1, x

′2, y′1, y′2) =

p(x′1)p(y′1|x′1)

p(x′2|x′1, y′1)p(y′2|x

′2)

A. Todeschini 11 / 39

Page 26: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

SMC algorithm

More generally, assume that we have sorted variables(X1,Y1, . . . ,Xn,Yn).The statistical model decomposes as

p(x1:n, y1:n) = p(x1)p(y1|x1)n∏

t=2p(xt|pa(xt))p(yt|pa(yt))

where pa(x) denotes the set of parents of variable x.

A. Todeschini 12 / 39

Page 27: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

SMC algorithmI A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

methods (SMC)

[Doucet et al., 2001, Del Moral, 2004, Doucet and Johansen, 2010]

...I Sequentially sample from conditional distributions of increasing

dimension

π1(x1|y1)→ π2(x1:2|y1:2)→ ...→ πn(x1:n|y1:n)

where, for t = 1, ...,n

πt(x1:t|y1:t) =p(x1:t, y1:t)

p(y1:t)

= πt−1(x1:t−1|y1:t−1)p(xt|pa(xt))p(yt|pa(yt))

p(yt|y1:t−1)

Two stochastic mechanisms:I Mutation/ExplorationI Selection

A. Todeschini 13 / 39

Page 28: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Standard SMC Algorithm

For t = 1, . . . ,nI For i = 1, . . . ,N

I Sample: X(i)t,t ∼ qt and let X(i)

t,1:t = (X(i)t−1,1:t−1,X

(i)t,t )

I Weight: w(i)t = π(yt |pa(yt))π(x(i)

t,t |pa(x(i)t,t ))

qt(x(i)t,t )

I Normalize: W (i)t = w(i)

t∑Nj=1

w(j)t

I Resample: {X(i)t,1:t,W

(i)t }i=1,...,N → {X

(i)t,1:t,

1N }i=1,...,N

OutputsI Weighted particles (W (i)

t ,X(i)t,1:t)i=1,...,N for t = 1, . . . ,n

I Estimate of the marginal likelihood Z =∏n

t=1

(1N∑N

i=1 w(i)t

)

A. Todeschini 14 / 39

Page 29: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

SMC algorithm

Marginal distributions

π1(x1|y1) → π2(x1:2|y1:2) → ...→ πn(x1:n|y1:n)

Filtering: π1(x1|y1) → π2(x2|y1:2) → ...→ πn(xn|y1:n)Smoothing: π1(x1|y1:n) → π2(x2|y1:n) → ...→ πn(xn|y1:n)

A. Todeschini 15 / 39

Page 30: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Example: hidden Markov/state space model

0 1 2 3 4 5 6 7 8 9 10

−4

−3

−2

−1

0

1

2

3

4

t

x

t=0, N=50 Particles generation

Particle weights ESS

0=50.00

A. Todeschini 16 / 39

Page 31: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Example: hidden Markov/state space model

0 1 2 3 4 5 6 7 8 9 10

−4

−3

−2

−1

0

1

2

3

4

t

x

t=1, N=50 Particles mutation

Particle weights ESS

1=22.27

A. Todeschini 16 / 39

Page 32: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Example: hidden Markov/state space model

0 1 2 3 4 5 6 7 8 9 10

−4

−3

−2

−1

0

1

2

3

4

t

x

t=1, N=50 Particles resampling

Particle weights ESS

1=22.27

A. Todeschini 16 / 39

Page 33: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Example: hidden Markov/state space model

0 1 2 3 4 5 6 7 8 9 10

−4

−3

−2

−1

0

1

2

3

4

t

x

t=2, N=50 Particles mutation

Particle weights ESS

2=28.78

A. Todeschini 16 / 39

Page 34: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Example: hidden Markov/state space model

0 1 2 3 4 5 6 7 8 9 10

−4

−3

−2

−1

0

1

2

3

4

t

x

t=2, N=50 Particles resampling

Particle weights ESS

2=28.78

A. Todeschini 16 / 39

Page 35: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Example: hidden Markov/state space model

0 1 2 3 4 5 6 7 8 9 10

−4

−3

−2

−1

0

1

2

3

4

t

x

t=3, N=50 Particles mutation

Particle weights ESS

3=25.50

A. Todeschini 16 / 39

Page 36: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Example: hidden Markov/state space model

0 1 2 3 4 5 6 7 8 9 10

−4

−3

−2

−1

0

1

2

3

4

t

x

t=3, N=50 Particles resampling

Particle weights ESS

3=25.50

A. Todeschini 16 / 39

Page 37: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Example: hidden Markov/state space model

0 1 2 3 4 5 6 7 8 9 10

−4

−3

−2

−1

0

1

2

3

4

t

x

t=4, N=50 Particles mutation

Particle weights ESS

4=3.39

A. Todeschini 16 / 39

Page 38: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Example: hidden Markov/state space model

0 1 2 3 4 5 6 7 8 9 10

−4

−3

−2

−1

0

1

2

3

4

t

x

t=4, N=50 Particles resampling

Particle weights ESS

4=3.39

A. Todeschini 16 / 39

Page 39: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Example: hidden Markov/state space model

0 1 2 3 4 5 6 7 8 9 10

−4

−3

−2

−1

0

1

2

3

4

t

x

t=5, N=50 Particles mutation

Particle weights ESS

5=30.92

A. Todeschini 16 / 39

Page 40: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Example: hidden Markov/state space model

0 1 2 3 4 5 6 7 8 9 10

−4

−3

−2

−1

0

1

2

3

4

t

x

t=5, N=50 Particles resampling

Particle weights ESS

5=30.92

A. Todeschini 16 / 39

Page 41: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Example: hidden Markov/state space model

0 1 2 3 4 5 6 7 8 9 10

−4

−3

−2

−1

0

1

2

3

4

t

x

t=6, N=50 Particles mutation

Particle weights ESS

6=33.01

A. Todeschini 16 / 39

Page 42: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Example: hidden Markov/state space model

0 1 2 3 4 5 6 7 8 9 10

−4

−3

−2

−1

0

1

2

3

4

t

x

t=6, N=50 Particles resampling

Particle weights ESS

6=33.01

A. Todeschini 16 / 39

Page 43: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Example: hidden Markov/state space model

0 1 2 3 4 5 6 7 8 9 10

−4

−3

−2

−1

0

1

2

3

4

t

x

t=7, N=50 Particles mutation

Particle weights ESS

7=31.77

A. Todeschini 16 / 39

Page 44: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Example: hidden Markov/state space model

0 1 2 3 4 5 6 7 8 9 10

−4

−3

−2

−1

0

1

2

3

4

t

x

t=7, N=50 Particles resampling

Particle weights ESS

7=31.77

A. Todeschini 16 / 39

Page 45: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Example: hidden Markov/state space model

0 1 2 3 4 5 6 7 8 9 10

−4

−3

−2

−1

0

1

2

3

4

t

x

t=8, N=50 Particles mutation

Particle weights ESS

8=33.86

A. Todeschini 16 / 39

Page 46: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Example: hidden Markov/state space model

0 1 2 3 4 5 6 7 8 9 10

−4

−3

−2

−1

0

1

2

3

4

t

x

t=8, N=50 Particles resampling

Particle weights ESS

8=33.86

A. Todeschini 16 / 39

Page 47: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Example: hidden Markov/state space model

0 1 2 3 4 5 6 7 8 9 10

−4

−3

−2

−1

0

1

2

3

4

t

x

t=9, N=50 Particles mutation

Particle weights ESS

9=35.66

A. Todeschini 16 / 39

Page 48: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Example: hidden Markov/state space model

0 1 2 3 4 5 6 7 8 9 10

−4

−3

−2

−1

0

1

2

3

4

t

x

t=9, N=50 Particles resampling

Particle weights ESS

9=35.66

A. Todeschini 16 / 39

Page 49: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Example: hidden Markov/state space model

0 1 2 3 4 5 6 7 8 9 10

−4

−3

−2

−1

0

1

2

3

4

t

x

t=10, N=50 Particles mutation

Particle weights ESS

10=18.93

A. Todeschini 16 / 39

Page 50: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Limitations and diagnosis of SMC algorithms

For a given t ≤ n, for each unique value X ′(k)n,t , k = 1, . . . ,Kn,t , let

W ′(k)n,t =

∑i|X(i)

t =X ′(k)t

W (i)n be its associated total weight. A measure of

the quality of the approximation of the posterior distribution p(xt:n|y1:n)is given by the smoothing effective sample size (SESS):

SESSt =1∑Kn,t

k=1

(W ′(k)

n,t

)2 (1)

with 1 ≤ SESSt ≤ N .A. Todeschini 17 / 39

Page 51: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Summary

Context

Graphical models and BUGS language

SMC

Biips software

Particle MCMC

A. Todeschini 18 / 39

Page 52: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Technical implementation

Core

Base

Compiler

Rbiips MatbiipsR+Rcpp Matlab+MEX

C++

I Interfaces: Matlab/Octave, RI Multi-platform: Windows, Linux, Mac OSXI Free and open source (GPL)

A. Todeschini 19 / 39

Page 53: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Example: Stochastic kinetic Lotka-Volterra model

[Boys et al., 2008]

I Evolution of two species X1(t) (prey) and X2(t) (predator) at time tI Continuous-time Markov jump process described by three reaction

equations:

X1c1−→ 2X1 prey reproduction,

X1 + X2c2−→ 2X2 predator reproduction,

X2c3−→ ∅ predator death

where c1 = 0.5, c2 = 0.0025 and c3 = 0.3.

Pr(X1(t + dt) = x1(t) + 1,X2(t + dt) = x2(t)|x1(t), x2(t))= c1x1(t)dt + o(dt)

Pr(X1(t + dt) = x1(t)− 1,X2(t + dt) = x2(t) + 1|x1(t), x2(t))= c2x1(t)x2(t)dt + o(dt)

Pr(X1(t + dt) = x1(t),X2(t + dt) = x2(t)− 1|x1(t), x2(t))= c3x2(t)dt + o(dt)

A. Todeschini 20 / 39

Page 54: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Gillespie algorithm

[Gillespie, 1977, Golightly and Gillespie, 2013]

R function to forward simulate from the LV model with Gillespie algorithmlotka_ volterra _ gillespie <- function (x, c1 , c2 , c3 , dt) {

z <- matrix (c(1, -1, 0, 0, 1, -1), nrow =2, byrow=TRUE)t <- 0while (TRUE) {

rate <- c(c1*x[1], c2*x[1]*x[2], c3*x[2])sum_rate <- sum(rate);# Sample the next event from an exponential distributiont <- t - log(runif (1))/sum_rateif (t>dt)

break# Sample the type of eventind <- which (( sum_rate*runif (1)) <= cumsum (rate))[1]x <- x + z[,ind]

}return (x)

}

A. Todeschini 21 / 39

Page 55: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Add a custom sampler

Rbiipsbiips_add_distribution (name = ’LV’,

n_param = 5,fun_dim = lotka_ volterra _dim ,fun_ sample = lotka_ volterra _ gillespie)

A. Todeschini 22 / 39

Page 56: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Example: Stochastic kinetic Lotka-Volterra model

I We observe at some time t = 1, 2, . . . , tmax the number of preyswith some additive noise

Y (t) = X1(t) + ε(t), ε(t) ∼ N (0, σ2)

I Objective: approximate Pr(X1(t),X2(t)|Y (1), . . . ,Y (tmax)) att = 1, . . . , tmax.

A. Todeschini 23 / 39

Page 57: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Example: Stochastic kinetic Lotka-Volterra model

stoch kinetic gill.bug

model{

x[,1] ˜ LV(x_init , c[1], c[2], c[3], 1)y[1] ˜ dnorm(x[1,1], 1/ sigma ˆ2)for (t in 2: t_max){

x[,t] ˜ LV(x[,t-1], c[1], c[2], c[3], 1)y[t] ˜ dnorm(x[1,t], 1/ sigma ˆ2)

}}

. . . Xt−1 Xt Xt+1 . . .

YtYt−1 Yt+1

A. Todeschini 24 / 39

Page 58: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Model compilationRbiips

data <- list(t_max =40, c=c(.5, .0025 , .3) ,x_init=c(100 , 100) , sigma =10)

model <- biips_model (model_file = ’stoch_ kinetic _gill.bug ’,data = data ,sample _data = TRUE)

data <- model$data ()

Ground truth and dataA. Todeschini 25 / 39

Page 59: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

SMC samplesRbiips

out_smc <- biips_smc_samples (model , variable _names = ’x’,n_part =10000 , type= ’fs’)

diag_smc <- biips_diagnosis (out_smc)summ_smc <- biips_summary (out_smc , probs=c(.025 , .975))x_s_mean <- summ_smc$x$s$meanx_s_quant <- summ_smc$x$s$quant

(a) Estimates (b) Smoothing effective sample sizeA. Todeschini 26 / 39

Page 60: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Kernel density estimates

Rbiipskde_smc <- biips_density (out_smc)

A. Todeschini 27 / 39

Page 61: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Probability mass estimates

Rbiipstab_smc <- biips_table(out_smc)

A. Todeschini 28 / 39

Page 62: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Summary

Context

Graphical models and BUGS language

SMC

Biips software

Particle MCMC

A. Todeschini 29 / 39

Page 63: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Particle MCMC

Recent algorithms that use SMC algorithms within a MCMC algorithm

[Andrieu et al., 2010]

I Particle Independant Metropolis-Hastings (PIMH)I Particle Marginal Metropolis-Hastings (PMMH)

A. Todeschini 30 / 39

Page 64: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Static parameter estimation

. . . Xt−1 Xt Xt+1 . . .

YtYt−1 Yt+1

θ

Due to the successive resamplings, SMC estimations of p(θ|y1:n) mightbe poor.

The PMMH splits the variables in the graphical model into two sets:I a set of variables X that will be sampled using a SMC algorithmI a set θ = (θ1, . . . , θp) sampled with a MH proposal

A. Todeschini 31 / 39

Page 65: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Standard PMMH algorithmSet Z(0) = 0 and initialize θ(0)For k = 1, . . . ,niter,

I Sample θ? ∼ ν(.|θ(k−1))I Run a SMC to approximate p(x1:n|y1:n, θ

?) with output(X?(i)

1:n ,W ?(i)n )i=1,...,N and Z? ≈ p(y1:n|θ?)

I With probability

min(

1,ν(θ?|θ(k − 1))p(θ?)Z?

ν(θ(k − 1)|θ?)p(θ(k − 1))Z(k − 1)

)

set X1:n(k) = X?(`)1:n , θ(k) = θ? and Z(k − 1) = Z?, where

` ∼ Discrete(W ?(1)n , . . . ,W ?(N)

n )I otherwise, keep previous iteration values

OutputsI MCMC samples (X1:n(k), θ(k))k=1,...,niter

A. Todeschini 32 / 39

Page 66: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Example: Stochastic kinetic Lotka-Volterra model

stoch kinetic gill.bug

model{

logc [1] ˜ dunif (-7,2)logc [2] ˜ dunif (-7,2)logc [3] ˜ dunif (-7,2)c[1] <- exp(logc [1])c[2] <- exp(logc [2])c[3] <- exp(logc [3])...

}

A. Todeschini 33 / 39

Page 67: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Run a PMMH algorithm

Rbiips# create a pmmh objectobj_pmmh = biips_pmmh_init (model ,

param_names = c(’logc [1] ’,’logc [2] ’,’logc [3] ’),

inits = list (-1, -5, -1),latent _names = ’x’)

# adaptation and burn -in iterationsbiips_pmmh_update (obj_pmmh , n_iter = 2000 , n_part = 100)

# samplesout_pmmh = biips_pmmh_samples (obj_pmmh , n_iter = 20000 ,

n_part = 100, thin = 10)

summ_pmmh = biips_summary (out_pmmh , probs = c(.025 , .975))kde_pmmh = biips_density (out_pmmh)

A. Todeschini 34 / 39

Page 68: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Posterior samples

A. Todeschini 35 / 39

Page 69: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Conclusion

I BUGS language compatibleI Extensibility: custom functions/samplersI Black-box SMC inference engineI Interfaces with popular software: Matlab/Octave, RI Post-processing toolsI And more: backward smoothing algorithm, particle independent

Metropolis-Hastings algorithm, sensitivity analysis, someoptimal/conditional samplers (Gaussian-Gaussian, beta-Bernoulli,finite discrete)

A. Todeschini 36 / 39

Page 70: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Bibliography IAndrieu, C., Doucet, A., and Holenstein, R. (2010).Particle markov chain monte carlo methods.Journal of the Royal Statistical Society B, 72:269–342.

Boys, R. J., Wilkinson, D. J., and Kirkwood, T. B. L. (2008).Bayesian inference for a discretely observed stochastic kinetic model.Statistics and Computing, 18(2):125–135.

Del Moral, P. (2004).Feynman-Kac Formulae. Genealogical and Interacting Particle Systems with Application.Springer.

Doucet, A., de Freitas, N., and Gordon, N., editors (2001).Sequential Monte Carlo Methods in Practice.Springer-Verlag.

Doucet, A. and Johansen, A. (2010).A tutorial on particle filtering and smoothing: Fifteen years later.In Crisan, D. and Rozovsky, B., editors, Oxford Handbook of Nonlinear Filtering. OxfordUniversity Press.

Gillespie, D. T. (1977).Exact stochastic simulation of coupled chemical reactions.The journal of physical chemistry, 81(25):2340–2361.

A. Todeschini 37 / 39

Page 71: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

Bibliography II

Golightly, A. and Gillespie, C. S. (2013).Simulation of stochastic kinetic models.In In Silico Systems Biology, pages 169–187. Springer.

Lunn, D., Jackson, C., Best, N., Thomas, A., and Spiegelhalter, D. (2012).The BUGS Book: A Practical Introduction to Bayesian Analysis.CRC Press/ Chapman and Hall.

Plummer, M. (2012).JAGS Version 3.3.0 user manual.

A. Todeschini 38 / 39

Page 72: [width=2cm]biipslogosmooth Biips software: …genome.jouy.inra.fr/applibugs/applibugs.14_11_28...SMC algorithm I A.k.a. interacting MCMC, particle filtering, sequential Monte Carlo

THANK YOU

http://alea.bordeaux.inria.fr/biips

A. Todeschini 39 / 39