Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
emcee
Search
Dan Foreman-Mackey
July 20, 2012
Science
2
620
emcee
Some intro slides for Python lunch at MPIA.
Dan Foreman-Mackey
July 20, 2012
Tweet
Share
More Decks by Dan Foreman-Mackey
See All by Dan Foreman-Mackey
Open software for Astronomical Data Analysis
dfm
0
120
Open Software for Astrophysics, AAS241
dfm
2
490
My research talk for CCA promotion
dfm
1
750
Astronomical software
dfm
1
700
emcee-odi
dfm
1
620
Exoplanet population inference: a tutorial
dfm
3
430
Data-driven discovery in the astronomical time domain
dfm
6
690
TensorFlow for astronomers
dfm
6
760
How to find a transiting exoplanets
dfm
1
450
Other Decks in Science
See All in Science
生成AI による論文執筆サポートの手引き(ワークショップ) / A guide to supporting dissertation writing with generative AI (workshop)
ks91
PRO
0
380
Celebrate UTIG: Staff and Student Awards 2024
utig
0
550
白金鉱業Meetup Vol.16_【初学者向け発表】 数理最適化のはじめの一歩 〜身近な問題で学ぶ最適化の面白さ〜
brainpadpr
10
1.9k
いまAI組織が求める企画開発エンジニアとは?
roadroller
2
1.4k
2024-06-16-pydata_london
sofievl
0
590
はじめての「相関と因果とエビデンス」入門:“動機づけられた推論” に抗うために
takehikoihayashi
17
7.2k
JSol'Ex : traitement d'images solaires en Java
melix
0
140
ウェーブレットおきもち講座
aikiriao
1
820
FOGBoston2024
lcolladotor
0
140
位相的データ解析とその応用例
brainpadpr
1
880
LIMEを用いた判断根拠の可視化
kentaitakura
0
420
構造設計のための3D生成AI-最新の取り組みと今後の展開-
kojinishiguchi
0
730
Featured
See All Featured
Designing for Performance
lara
604
68k
Typedesign – Prime Four
hannesfritz
40
2.5k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
19k
The World Runs on Bad Software
bkeepers
PRO
67
11k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
30
2.1k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Unsuck your backbone
ammeep
669
57k
Designing for humans not robots
tammielis
250
25k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.5k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
BBQ
matthewcrist
85
9.4k
Transcript
emcee danfm.ca/emcee p(⇥) I have a function
emcee danfm.ca/emcee p(⇥) I have a function I can Evaluate
it
emcee danfm.ca/emcee p(⇥) I have a function I can Evaluate
it I can't Calculate the functional form
emcee danfm.ca/emcee p(⇥) I have a function I can Evaluate
it I can't Calculate the functional form Markov chain Monte Carlo (MCMC)
emcee danfm.ca/emcee Metropolis-Hastings
emcee danfm.ca/emcee min ✓ 1 , p ( x 0)
p ( x ) Q ( x ; x 0) Q ( x 0; x ) ◆ Metropolis-Hastings
emcee danfm.ca/emcee min ✓ 1 , p ( x 0)
p ( x ) Q ( x ; x 0) Q ( x 0; x ) ◆ Metropolis-Hastings Proposal D (D-1) parameters
emcee danfm.ca/emcee Metropolis-Hastings x y
emcee danfm.ca/emcee Metropolis-Hastings x y (in an ideal world)
emcee danfm.ca/emcee Metropolis-Hastings x y (in an ideal world)
emcee danfm.ca/emcee Metropolis-Hastings x y (in an ideal world)
emcee danfm.ca/emcee Metropolis-Hastings x y (in an ideal world) min
✓ 1, p (x 0 ) p (x ) Q (x ;x 0 ) Q (x 0 ;x ) ◆ ?
emcee danfm.ca/emcee Metropolis-Hastings x y (in an ideal world)
emcee danfm.ca/emcee Metropolis-Hastings x y (in an ideal world)
emcee danfm.ca/emcee Metropolis-Hastings x y (in an ideal world)
emcee danfm.ca/emcee Metropolis-Hastings x y (in an ideal world) min
✓ 1 , p( x 0 ) p( x) Q( x; x 0 ) Q( x 0; x) ◆ ?
emcee danfm.ca/emcee Metropolis-Hastings x y (in an ideal world)
emcee danfm.ca/emcee Metropolis-Hastings x y (in an ideal world)
emcee danfm.ca/emcee Metropolis-Hastings x y (in an ideal world)
emcee danfm.ca/emcee Metropolis-Hastings x y (in an ideal world)
emcee danfm.ca/emcee Metropolis-Hastings (in the REAL world) x y
emcee danfm.ca/emcee Metropolis-Hastings (in the REAL world) x y
emcee danfm.ca/emcee Metropolis-Hastings (in the REAL world) x y
emcee danfm.ca/emcee Metropolis-Hastings (in the REAL world) x y
emcee danfm.ca/emcee Metropolis-Hastings (in the REAL world) x y
emcee danfm.ca/emcee Metropolis-Hastings (in the REAL world) x y SMALL
ACCEPTANCE FRACTION the problem
emcee danfm.ca/emcee Metropolis-Hastings (in the REAL world) x y LARGE
ACCEPTANCE FRACTION the problem
x y emcee danfm.ca/emcee Metropolis-Hastings (in the REAL world)
x y emcee danfm.ca/emcee Metropolis-Hastings (in the REAL world)
x y emcee danfm.ca/emcee Metropolis-Hastings (in the REAL world)
x y emcee danfm.ca/emcee Metropolis-Hastings (in the REAL world) positive-definite
symmetric Proposal D (D-1) parameters
x y emcee danfm.ca/emcee Metropolis-Hastings (in the REAL world) positive-definite
symmetric Proposal D (D-1) parameters This is the Dimension of your parameter space!
emcee danfm.ca/emcee Metropolis-Hastings (in the REAL world) Scientific Awesomeness how
hard is MCMC Metropolis Hastings how things Should be (~number of parameters)
emcee danfm.ca/emcee Why does all this matter?
emcee danfm.ca/emcee How do you calculate the optimal proposal?
emcee danfm.ca/emcee Temperature
emcee danfm.ca/emcee Temperature
emcee danfm.ca/emcee Temperature
emcee danfm.ca/emcee Temperature
emcee danfm.ca/emcee Temperature
emcee danfm.ca/emcee Temperature
emcee danfm.ca/emcee Temperature
emcee danfm.ca/emcee Temperature
emcee danfm.ca/emcee Temperature
emcee danfm.ca/emcee Temperature time
emcee danfm.ca/emcee Temperature that should be spent interpreting your results
writing papers finding bugs in your code time
emcee danfm.ca/emcee Luckily I have a solution!
emcee danfm.ca/emcee Luckily I have a solution! HINT: it's up
here...
emcee danfm.ca/emcee bit.ly/mcmc-gw10 "Ensemble samplers with affine invariance" Jonathan Goodman
Jonathan Weare Mustaches courtesy: mustachify.me
emcee danfm.ca/emcee bit.ly/mcmc-gw10 "Ensemble samplers with affine invariance" Jonathan Goodman
Jonathan Weare Mustaches courtesy: mustachify.me
emcee danfm.ca/emcee bit.ly/mcmc-gw10 "Ensemble samplers with affine invariance" Jonathan Goodman
Jonathan Weare Mustaches courtesy: mustachify.me
emcee danfm.ca/emcee affine invariance
emcee danfm.ca/emcee affine invariance y A x + b Affine
Transformation
emcee danfm.ca/emcee affine invariance The sampler performs Equally well on
X and Y y A x + b Affine Transformation
emcee danfm.ca/emcee Easy to sample Hard to sample
emcee danfm.ca/emcee Easy to sample Hard to sample y A
x + b Affine Transformation
emcee danfm.ca/emcee Easy to sample Hard to sample y A
x + b Affine Transformation easy!
emcee danfm.ca/emcee Ensemble Samplers (in the REAL world) x y
with affine invariance
emcee danfm.ca/emcee Ensemble Samplers (in the REAL world) x y
with affine invariance
emcee danfm.ca/emcee Ensemble Samplers (in the REAL world) x y
with affine invariance
emcee danfm.ca/emcee Ensemble Samplers (in the REAL world) x y
with affine invariance this is a walker
emcee danfm.ca/emcee Ensemble Samplers (in the REAL world) x y
with affine invariance this is a walker
emcee danfm.ca/emcee Ensemble Samplers (in the REAL world) x y
with affine invariance
emcee danfm.ca/emcee Ensemble Samplers (in the REAL world) x y
with affine invariance
emcee danfm.ca/emcee Ensemble Samplers (in the REAL world) x y
with affine invariance
emcee danfm.ca/emcee Ensemble Samplers (in the REAL world) x y
with affine invariance
emcee danfm.ca/emcee Ensemble Samplers (in the REAL world) x y
with affine invariance
emcee danfm.ca/emcee Ensemble Samplers (in the REAL world) x y
with affine invariance min ✓ 1,Z D 1 p (x 0 ) p (x ) ◆
emcee danfm.ca/emcee Ensemble Samplers (in the REAL world) x y
with affine invariance min ✓ 1,Z D 1 p (x 0 ) p (x ) ◆
emcee danfm.ca/emcee Ensemble Samplers (in the REAL world) x y
with affine invariance
emcee danfm.ca/emcee Ensemble Samplers (in the REAL world) x y
with affine invariance
emcee danfm.ca/emcee Ensemble Samplers (in the REAL world) x y
with affine invariance
emcee danfm.ca/emcee Ensemble Samplers (in the REAL world) x y
with affine invariance
emcee danfm.ca/emcee Ensemble Samplers (in the REAL world) x y
with affine invariance Aside: this looks nice and parallel, eh? * * not quite as trivial as you might hope—but possible!
emcee danfm.ca/emcee +
emcee danfm.ca/emcee it's hammer time! emceethe MCMC Hammer introducing arxiv.org/abs/1202.3665
emcee danfm.ca/emcee pip install emcee get it:
emcee danfm.ca/emcee import numpy as np import emcee def lnprob(x):
return -0.5 * np.sum(x ** 2) ndim, nwalkers = 10, 100 p0 = [np.random.rand(ndim) for i in range(nwalkers)] sampler = emcee.EnsembleSampler(nwalkers, ndim, lnprob) sampler.run_mcmc(p0, 1000) use it:
emcee danfm.ca/emcee DOES IT WORK? obviously it does.
emcee danfm.ca/emcee 1.0 0.5 0.0 0.5 1.0 1.0 0.5 0.0
0.5 1.0 exp ✓ (x1 x2) 2 2 ✏ (x1 + x2) 2 2 ◆
emcee danfm.ca/emcee github.com/dfm/acor Autocorrelation Function the (covariance)
emcee danfm.ca/emcee 1.0 0.5 0.0 0.5 1.0 1.0 0.5 0.0
0.5 1.0 exp ✓ (x1 x2) 2 2 ✏ (x1 + x2) 2 2 ◆ Metropolis-Hastings Emcee Autocorrelation Function the
emcee danfm.ca/emcee 1.0 0.5 0.0 0.5 1.0 1.0 0.5 0.0
0.5 1.0 exp ✓ (x1 x2) 2 2 ✏ (x1 + x2) 2 2 ◆ Metropolis-Hastings Emcee Autocorrelation Function the
emcee danfm.ca/emcee 1.0 0.5 0.0 0.5 1.0 1.0 0.5 0.0
0.5 1.0 exp ✓ (x1 x2) 2 2 ✏ (x1 + x2) 2 2 ◆ Metropolis-Hastings Emcee Autocorrelation Function the
emcee danfm.ca/emcee Metropolis-Hastings Boom!
emcee danfm.ca/emcee 4 2 0 2 4 6 0 5
10 15 20 25 30 exp ✓ 100 (x2 x 2 1) 2 + (1 x1) 2 20 ◆
4 2 0 2 4 6 0 5 10 15
20 25 30 exp ✓ 100 (x2 x 2 1) 2 + (1 x1) 2 20 ◆ emcee danfm.ca/emcee Metropolis-Hastings Emcee Autocorrelation Function the
emcee isn't always The Right Choice™ emcee danfm.ca/emcee Mustache courtesy:
mustachify.me Brendon Brewer Remember:
emcee danfm.ca/emcee Mustache courtesy: mustachify.me continuous parameters in a vector
space emcee needs highly multimodal problems and it is not good at
emcee danfm.ca/emcee Mustache courtesy: mustachify.me continuous parameters in a vector
space emcee needs highly multimodal problems and it is not good at what is?
emcee danfm.ca/emcee Mustache courtesy: mustachify.me continuous parameters in a vector
space emcee needs highly multimodal problems and it is not good at what is? maybe Dnest github.com/eggplantbren/DNest3
emcee danfm.ca/emcee Mustache courtesy: mustachify.me continuous parameters in a vector
space emcee needs highly multimodal problems and it is not good at what is? maybe Dnest github.com/eggplantbren/DNest3 for example
emcee danfm.ca/emcee it's still been pretty useful... Lang & Hogg
(2011) Bovy et al. (2011) Dorman et al. (2012) Foreman-Mackey & Widrow (in prep) Mustaches courtesy: mustachify.me ... ... ...
emceethe MCMC Hammer arxiv.org/abs/1202.3665 danfm.ca/emcee github.com/dfm/emcee paper documentation issues/contributions Check
it out: Dustin Lang (Princeton) David W. Hogg (NYU) Jonathan Goodman (NYU)