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
550
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
88
Open Software for Astrophysics, AAS241
dfm
2
410
My research talk for CCA promotion
dfm
1
720
Astronomical software
dfm
1
660
emcee-odi
dfm
1
540
Exoplanet population inference: a tutorial
dfm
3
410
Data-driven discovery in the astronomical time domain
dfm
6
660
TensorFlow for astronomers
dfm
6
650
How to find a transiting exoplanets
dfm
1
370
Other Decks in Science
See All in Science
B-Cubed: Leveraging analysis-ready biodiversity datasets and cloud computing for timely and actionable biodiversity monitoring
peterdesmet
0
160
Mastering Feature Engineering: Mining the Hidden Salary Formula with CakeResume
tlyu0419
0
130
Microbiology Labs.
maleehafatima
0
130
ABEMAの効果検証事例〜効果の異質性を考える〜
s1ok69oo
3
1.5k
Non-Gaussian methods for causal discovery
sshimizu2006
0
170
Onsager代数とその周辺 / Onsager algebra tsudoi
usamik26
0
380
Design of three-dimensional binary manipulators based on the KS statistic and maximum empty circles (IECON2023)
konakalab
0
230
ultraArmをモニター提供してもらった話
miura55
0
110
Machine Learning for Materials (Lecture 7)
aronwalsh
0
730
Spark_Task_Optimization_Journey_How_I_Increased_10x_Speed_by_Performance_Tuning
tlyu0419
0
200
Machine Learning for Materials (Lecture 8)
aronwalsh
0
320
SIGDIAL論文読み会: PGTask: Introducing the Task of Profile Generation from Dialogues
kaiyo3
0
100
Featured
See All Featured
How to Ace a Technical Interview
jacobian
272
22k
Side Projects
sachag
451
41k
Imperfection Machines: The Place of Print at Facebook
scottboms
258
12k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
240
1.2M
A designer walks into a library…
pauljervisheath
199
23k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
29
6k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
34
8.9k
The MySQL Ecosystem @ GitHub 2015
samlambert
242
12k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
356
22k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
501
140k
Web development in the modern age
philhawksworth
202
10k
BBQ
matthewcrist
80
8.8k
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)