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
610
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
470
My research talk for CCA promotion
dfm
1
740
Astronomical software
dfm
1
690
emcee-odi
dfm
1
600
Exoplanet population inference: a tutorial
dfm
3
420
Data-driven discovery in the astronomical time domain
dfm
6
680
TensorFlow for astronomers
dfm
6
730
How to find a transiting exoplanets
dfm
1
440
Other Decks in Science
See All in Science
(論文読み)贈り物の交換による地位の競争と社会構造の変化 - 文化人類学への統計物理学的アプローチ -
__ymgc__
1
110
統計的因果探索の方法
sshimizu2006
1
1.2k
Mechanistic Interpretability の紹介
sohtakahashi
0
350
Machine Learning for Materials (Lecture 9)
aronwalsh
0
210
大規模言語モデルの開発
chokkan
PRO
84
33k
はじめての「相関と因果とエビデンス」入門:“動機づけられた推論” に抗うために
takehikoihayashi
17
6.9k
Science of Scienceおよび科学計量学に関する研究論文の俯瞰可視化_LT版
hayataka88
0
940
Презентация программы бакалавриата СПбГУ "Искусственный интеллект и наука о данных"
dscs
0
730
HAS Dark Site Orientation
astronomyhouston
0
5.4k
科学で迫る勝敗の法則(名城大学公開講座.2024年10月) / The principle of victory discovered by science (Open lecture in Meijo Univ. 2024)
konakalab
0
200
理論計算機科学における 数学の応用: 擬似ランダムネス
nobushimi
1
340
WeMeet Group - 採用資料
wemeet
0
3.3k
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
88
5.7k
The Pragmatic Product Professional
lauravandoore
31
6.3k
Bash Introduction
62gerente
608
210k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
380
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
Into the Great Unknown - MozCon
thekraken
32
1.5k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
430
4 Signs Your Business is Dying
shpigford
180
21k
How STYLIGHT went responsive
nonsquared
95
5.2k
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)