Bayesian analysis toolkit: 1.0 and beyond...BAYESIAN ANALYSIS TOOLKIT: 1.0 AND BEYOND...

22
BAYESIAN ANALYSIS TOOLKIT: 1.0 AND BEYOND [email protected] Excellence cluster universe, LMU Munich CHEP 2015, Okinawa BAT men: F.B., A. Caldwell, D. Greenwald, D. Kollár, K. Kröninger, O. Schulz, S. Kluth

Transcript of Bayesian analysis toolkit: 1.0 and beyond...BAYESIAN ANALYSIS TOOLKIT: 1.0 AND BEYOND...

Page 1: Bayesian analysis toolkit: 1.0 and beyond...BAYESIAN ANALYSIS TOOLKIT: 1.0 AND BEYOND Frederik.Beaujean@lmu.de Excellence cluster universe, LMU Munich CHEP 2015, Okinawa BAT men: F.B.,

BAYESIAN ANALYSIS TOOLKIT: 1.0 AND BEYOND

[email protected] cluster universe, LMU Munich

CHEP 2015, Okinawa

BAT men: F.B., A. Caldwell, D. Greenwald, D. Kollár, K. Kröninger, O. Schulz, S. Kluth

Page 2: Bayesian analysis toolkit: 1.0 and beyond...BAYESIAN ANALYSIS TOOLKIT: 1.0 AND BEYOND Frederik.Beaujean@lmu.de Excellence cluster universe, LMU Munich CHEP 2015, Okinawa BAT men: F.B.,

QUESTION

Given data from LHC, what are likely values of masses, crosssections. . . ?Limits including systematic uncertainties?

Frederik Beaujean Apr 2015 2 / 14

Page 3: Bayesian analysis toolkit: 1.0 and beyond...BAYESIAN ANALYSIS TOOLKIT: 1.0 AND BEYOND Frederik.Beaujean@lmu.de Excellence cluster universe, LMU Munich CHEP 2015, Okinawa BAT men: F.B.,

BAYES’ THEOREM

LEARNING RULE

P(θ|D,M) ∝ P(D|θ,M)P0(θ|M)

posterior ∝ likelihood× prior

Frederik Beaujean Apr 2015 3 / 14

Page 4: Bayesian analysis toolkit: 1.0 and beyond...BAYESIAN ANALYSIS TOOLKIT: 1.0 AND BEYOND Frederik.Beaujean@lmu.de Excellence cluster universe, LMU Munich CHEP 2015, Okinawa BAT men: F.B.,

APPLYING BAYES’ THEOREM

INTEGRATION

• marginalization P(θi |D,M) =

∫ ∏j 6=i

dθj P(θ|D,M)

• evidence P(D|M) =

∫dθ P(D|θ,M)P0(θ|M)

• quadrature→ curse of dimensionality

⇒ need samples from posterior

Frederik Beaujean Apr 2015 4 / 14

Page 5: Bayesian analysis toolkit: 1.0 and beyond...BAYESIAN ANALYSIS TOOLKIT: 1.0 AND BEYOND Frederik.Beaujean@lmu.de Excellence cluster universe, LMU Munich CHEP 2015, Okinawa BAT men: F.B.,

APPLYING BAYES’ THEOREM

INTEGRATION

• marginalization P(θi |D,M) =

∫ ∏j 6=i

dθj P(θ|D,M)

• evidence P(D|M) =

∫dθ P(D|θ,M)P0(θ|M)

• quadrature→ curse of dimensionality

⇒ need samples from posterior

Frederik Beaujean Apr 2015 4 / 14

Page 6: Bayesian analysis toolkit: 1.0 and beyond...BAYESIAN ANALYSIS TOOLKIT: 1.0 AND BEYOND Frederik.Beaujean@lmu.de Excellence cluster universe, LMU Munich CHEP 2015, Okinawa BAT men: F.B.,

MARKOV CHAIN MONTE CARLO

3

3

1

1

1

1

1

2

2

2

METROPOLIS HASTINGSALGORITHM

one sample per step1 propose move2 accept or stay

• marginals• sample near mode⇒

seed for optimization• uncertainty propagation

f (θ)→ P(f |D,M)

Frederik Beaujean Apr 2015 5 / 14

Page 7: Bayesian analysis toolkit: 1.0 and beyond...BAYESIAN ANALYSIS TOOLKIT: 1.0 AND BEYOND Frederik.Beaujean@lmu.de Excellence cluster universe, LMU Munich CHEP 2015, Okinawa BAT men: F.B.,

MARKOV CHAIN MONTE CARLO

3

3

1

1

1

1

1

2

2

2

METROPOLIS HASTINGSALGORITHM

one sample per step1 propose move2 accept or stay

• marginals• sample near mode⇒

seed for optimization• uncertainty propagation

f (θ)→ P(f |D,M)

Frederik Beaujean Apr 2015 5 / 14

Page 8: Bayesian analysis toolkit: 1.0 and beyond...BAYESIAN ANALYSIS TOOLKIT: 1.0 AND BEYOND Frederik.Beaujean@lmu.de Excellence cluster universe, LMU Munich CHEP 2015, Okinawa BAT men: F.B.,

BAYESIAN ANALYSIS TOOLKIT

• home page http://mpp.mpg.de/bat

• fork me on https://github.com/bat/bat

MOTIVATION

• reinventing the wheel time waster, error prone

• C++ toolkit to supply algorithms/models ⇒ user can focus on problem

Frederik Beaujean Apr 2015 6 / 14

Page 9: Bayesian analysis toolkit: 1.0 and beyond...BAYESIAN ANALYSIS TOOLKIT: 1.0 AND BEYOND Frederik.Beaujean@lmu.de Excellence cluster universe, LMU Munich CHEP 2015, Okinawa BAT men: F.B.,

BAYESIAN ANALYSIS TOOLKIT

• home page http://mpp.mpg.de/bat

• fork me on https://github.com/bat/bat

FEATURES

• implemented: MCMC (multithreaded), simulated annealing . . .

• depends on ROOT: I/O, plots, optimization (Minuit) . . .

• optional: roostats, CUBA (integration)

• docs, tutorials, examples . . . on web page

Frederik Beaujean Apr 2015 6 / 14

Page 10: Bayesian analysis toolkit: 1.0 and beyond...BAYESIAN ANALYSIS TOOLKIT: 1.0 AND BEYOND Frederik.Beaujean@lmu.de Excellence cluster universe, LMU Munich CHEP 2015, Okinawa BAT men: F.B.,

COMPONENTS

P(θ|D,M) ∝ P(D|θ,M)P0(θ|M)

USER DEFINED

• create model• read data

COMMON TOOLS

• Normalize()

• FindMode()

• MarginalizeAll()

• PrintAllMarginalized()

• PrintKnowledgeUpdatePlots()

DEFINE MYMODEL : BCMODEL

• AddParameter(“mu”, 0, 1)

• LogLikelihood()

• LogAPrioriProbability()

Frederik Beaujean Apr 2015 7 / 14

Page 11: Bayesian analysis toolkit: 1.0 and beyond...BAYESIAN ANALYSIS TOOLKIT: 1.0 AND BEYOND Frederik.Beaujean@lmu.de Excellence cluster universe, LMU Munich CHEP 2015, Okinawa BAT men: F.B.,

COMPONENTS

P(θ|D,M) ∝ P(D|θ,M)P0(θ|M)

USER DEFINED

• create model• read data

COMMON TOOLS

• Normalize()

• FindMode()

• MarginalizeAll()

• PrintAllMarginalized()

• PrintKnowledgeUpdatePlots()

DEFINE MYMODEL : BCMODEL

• AddParameter(“mu”, 0, 1)

• LogLikelihood()

• LogAPrioriProbability()

Frederik Beaujean Apr 2015 7 / 14

Page 12: Bayesian analysis toolkit: 1.0 and beyond...BAYESIAN ANALYSIS TOOLKIT: 1.0 AND BEYOND Frederik.Beaujean@lmu.de Excellence cluster universe, LMU Munich CHEP 2015, Okinawa BAT men: F.B.,

COMPONENTS

P(θ|D,M) ∝ P(D|θ,M)P0(θ|M)

USER DEFINED

• create model• read data

COMMON TOOLS

• Normalize()

• FindMode()

• MarginalizeAll()

• PrintAllMarginalized()

• PrintKnowledgeUpdatePlots()

DEFINE MYMODEL : BCMODEL

• AddParameter(“mu”, 0, 1)

• LogLikelihood()

• LogAPrioriProbability()

Frederik Beaujean Apr 2015 7 / 14

Page 13: Bayesian analysis toolkit: 1.0 and beyond...BAYESIAN ANALYSIS TOOLKIT: 1.0 AND BEYOND Frederik.Beaujean@lmu.de Excellence cluster universe, LMU Munich CHEP 2015, Okinawa BAT men: F.B.,

PREDEFINED MODEL

template fit: signal + bkg

// define the modelBCMTF m("SingleChannelMTF");m.AddChannel("channel1");m.SetData("channel1", hist_data);m.AddProcess("background", 200., 400.);m.SetTemplate("channel1", "background",

hist_background, 1.0);m.SetPriorGauss("background", 300., 10.);m.AddProcess("signal", 0., 200.);m.SetTemplate("channel1", "signal", hist_signal, 1.0);m.SetPriorConstant("signal"); E [a.u.]

960 980 1000 1020 1040

p(E

)

0

5

10

15

20

25

Page 14: Bayesian analysis toolkit: 1.0 and beyond...BAYESIAN ANALYSIS TOOLKIT: 1.0 AND BEYOND Frederik.Beaujean@lmu.de Excellence cluster universe, LMU Munich CHEP 2015, Okinawa BAT men: F.B.,

OUTPUT [

MeV

]0x

[M

eV]

1x [

MeV

]2x

[M

eV]

4x

[MeV]0x [MeV]1x [MeV]2x [MeV]4x

// run MCMC, find mode, then plotm.MarginalizeAll();m.FindMode(m.GetBestFitParameters());m.PrintKnowledgeUpdatePlots("upd.pdf");m.PrintCorrelationPlot("corr.pdf");

[MeV]1x4− 2− 0 2 4

|Dat

a)1

P(x

0.0

0.1

0.2

0.3

0.4

0.5

0.6prior posterior

[MeV]0x4− 2− 0 2 4

[M

eV]

1x

5−

4−

3−

2−

1−

0

1

2

3

4

5

priorsmallest 68.2 % interval(s)local mode

posteriorsmallest 68.2 % interval(s)local mode

Frederik Beaujean Apr 2015 9 / 14

Page 15: Bayesian analysis toolkit: 1.0 and beyond...BAYESIAN ANALYSIS TOOLKIT: 1.0 AND BEYOND Frederik.Beaujean@lmu.de Excellence cluster universe, LMU Munich CHEP 2015, Okinawa BAT men: F.B.,

[GeV]Z’m

500 1000 1500

) [p

b]

ττ→

Z’

(BR

×)

Z’

→pp

­310

­210

­110

1

ATLAS­1

L dt = 4.6 fb∫ = 7 TeVs

(a)

µτeτ

hadτeτ / hadτµτ

hadτhadτ

comb.Observed limits

Expected limits

SSMZ’

th. uncert.SSMZ’

ATLAS: Z ′

Phys. Lett. B 719 (2013)

CMS: quantum black holearXiv:1501.04198v2

Belle: dark photonarXiv:1502.00084

]­1[ps12M

0 0.002 0.004 0.006 0.008 0.01 0.012 0.014

]o [

12

­30

­20

­10

0

10

20

30

UTFIT: D meson mixingarXiv:1402.1664

110 citations@inspire, ∼ 100 downloads of v0.9.4.1 since Jan 20, 2015

Page 16: Bayesian analysis toolkit: 1.0 and beyond...BAYESIAN ANALYSIS TOOLKIT: 1.0 AND BEYOND Frederik.Beaujean@lmu.de Excellence cluster universe, LMU Munich CHEP 2015, Okinawa BAT men: F.B.,

LESSONS IN SOFTWARE ENGINEERING

HISTORY

• first release 2008• subversion

• one of two main developersleft physics

PRESENT

1 better code with git: distributed, code review2 benefit from github: discuss issues, fork, pull requests. . .3 write unit tests: refactor code, add features w/o worrying,

automatic tests on different platforms

⇒time investments pay off

Frederik Beaujean Apr 2015 11 / 14

Page 17: Bayesian analysis toolkit: 1.0 and beyond...BAYESIAN ANALYSIS TOOLKIT: 1.0 AND BEYOND Frederik.Beaujean@lmu.de Excellence cluster universe, LMU Munich CHEP 2015, Okinawa BAT men: F.B.,

LESSONS IN SOFTWARE ENGINEERING

HISTORY

• first release 2008• subversion

• one of two main developersleft physics

PRESENT

1 better code with git: distributed, code review

2 benefit from github: discuss issues, fork, pull requests. . .3 write unit tests: refactor code, add features w/o worrying,

automatic tests on different platforms

⇒time investments pay off

Frederik Beaujean Apr 2015 11 / 14

Page 18: Bayesian analysis toolkit: 1.0 and beyond...BAYESIAN ANALYSIS TOOLKIT: 1.0 AND BEYOND Frederik.Beaujean@lmu.de Excellence cluster universe, LMU Munich CHEP 2015, Okinawa BAT men: F.B.,

LESSONS IN SOFTWARE ENGINEERING

HISTORY

• first release 2008• subversion

• one of two main developersleft physics

PRESENT

1 better code with git: distributed, code review2 benefit from github: discuss issues, fork, pull requests. . .

3 write unit tests: refactor code, add features w/o worrying,automatic tests on different platforms

⇒time investments pay off

Frederik Beaujean Apr 2015 11 / 14

Page 19: Bayesian analysis toolkit: 1.0 and beyond...BAYESIAN ANALYSIS TOOLKIT: 1.0 AND BEYOND Frederik.Beaujean@lmu.de Excellence cluster universe, LMU Munich CHEP 2015, Okinawa BAT men: F.B.,

LESSONS IN SOFTWARE ENGINEERING

HISTORY

• first release 2008• subversion

• one of two main developersleft physics

PRESENT

1 better code with git: distributed, code review2 benefit from github: discuss issues, fork, pull requests. . .3 write unit tests: refactor code, add features w/o worrying,

automatic tests on different platforms

⇒time investments pay off

Frederik Beaujean Apr 2015 11 / 14

Page 20: Bayesian analysis toolkit: 1.0 and beyond...BAYESIAN ANALYSIS TOOLKIT: 1.0 AND BEYOND Frederik.Beaujean@lmu.de Excellence cluster universe, LMU Munich CHEP 2015, Okinawa BAT men: F.B.,

BAT 1.0

IMPROVEMENTS UNDER DEVELOPMENT

• ease of use: streamline option setting, building . . .

• factorized priors P(θ|M) =∏

i

P(θi |M)

⇒ community extensible• sharing samples as ROOT files (even w/o the model)⇒ uncertainty propagation, replotting

• multivariate proposal⇒ big speed-up in high dimensions• evidence from MCMC arXiv:1410.7149

⇒ release in summer 2015

Frederik Beaujean Apr 2015 12 / 14

Page 21: Bayesian analysis toolkit: 1.0 and beyond...BAYESIAN ANALYSIS TOOLKIT: 1.0 AND BEYOND Frederik.Beaujean@lmu.de Excellence cluster universe, LMU Munich CHEP 2015, Okinawa BAT men: F.B.,

BAT 2.0

WISHLIST FOR THE FUTURE

• threads + MPI for tough problems⇒rewrite• interface to script languages: python, mathematica, R . . .• sampling algorithms: MCMC, Hamiltonian MC, nested sampling,

variational Bayes + importance sampling . . .

Frederik Beaujean Apr 2015 13 / 14

Page 22: Bayesian analysis toolkit: 1.0 and beyond...BAYESIAN ANALYSIS TOOLKIT: 1.0 AND BEYOND Frederik.Beaujean@lmu.de Excellence cluster universe, LMU Munich CHEP 2015, Okinawa BAT men: F.B.,

SUMMARY

1 Bayes: random numbers2 BAT well established3 more powerful sampling algorithms in BAT 2.0

Frederik Beaujean Apr 2015 14 / 14