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
110
Open Software for Astrophysics, AAS241
dfm
2
480
My research talk for CCA promotion
dfm
1
750
Astronomical software
dfm
1
700
emcee-odi
dfm
1
610
Exoplanet population inference: a tutorial
dfm
3
420
Data-driven discovery in the astronomical time domain
dfm
6
690
TensorFlow for astronomers
dfm
6
750
How to find a transiting exoplanets
dfm
1
450
Other Decks in Science
See All in Science
LIMEを用いた判断根拠の可視化
kentaitakura
0
380
マクロ経済学の視点で、財政健全化は必要か
ryo18cm
1
110
Snowflake上でRを使う: RStudioセットアップとShinyアプリケーションのデプロイ
ktatsuya
PRO
0
480
観察研究における因果推論
nearme_tech
PRO
1
100
私たちのプロダクトにとってのよいテスト/good test for our products
camel_404
0
200
白金鉱業Meetup Vol.16_【初学者向け発表】 数理最適化のはじめの一歩 〜身近な問題で学ぶ最適化の面白さ〜
brainpadpr
10
1.7k
非同期コミュニケーションの構造 -チャットツールを用いた組織における情報の流れの設計について-
koisono
0
170
ベイズのはなし
techmathproject
0
350
Celebrate UTIG: Staff and Student Awards 2024
utig
0
500
Inductive-bias Learning: 大規模言語モデルによる予測モデルの生成
fuyu_quant0
0
120
教師なしテンソル分解に基づく、有糸分裂後の転写再活性化におけるヒストン修飾ブックマークとしての転写因子候補の抽出法
tagtag
0
140
生成AI による論文執筆サポートの手引き(ワークショップ) / A guide to supporting dissertation writing with generative AI (workshop)
ks91
PRO
0
330
Featured
See All Featured
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Speed Design
sergeychernyshev
25
670
Navigating Team Friction
lara
183
15k
Docker and Python
trallard
42
3.1k
Statistics for Hackers
jakevdp
796
220k
Six Lessons from altMBA
skipperchong
27
3.5k
Git: the NoSQL Database
bkeepers
PRO
427
64k
Designing for Performance
lara
604
68k
The Pragmatic Product Professional
lauravandoore
32
6.3k
Mobile First: as difficult as doing things right
swwweet
222
9k
Optimising Largest Contentful Paint
csswizardry
33
3k
VelocityConf: Rendering Performance Case Studies
addyosmani
326
24k
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)