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
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
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
最適化超入門
tkm2261
14
3.4k
Analysis-Ready Cloud-Optimized Data for your community and the entire world with Pangeo-Forge
jbusecke
0
120
[第62回 CV勉強会@関東] Long-CLIP: Unlocking the Long-Text Capability of CLIP / kantoCV 62th ECCV 2024
lychee1223
1
790
非同期コミュニケーションの構造 -チャットツールを用いた組織における情報の流れの設計について-
koisono
0
180
The Incredible Machine: Developer Productivity and the Impact of AI
tomzimmermann
0
450
Spectral Sparsification of Hypergraphs
tasusu
0
210
Introduction to Image Processing: 2.Frequ
hachama
0
350
科学で迫る勝敗の法則(名城大学公開講座.2024年10月) / The principle of victory discovered by science (Open lecture in Meijo Univ. 2024)
konakalab
0
240
局所保存性・相似変換対称性を満たす機械学習モデルによる数値流体力学
yellowshippo
1
130
WeMeet Group - 採用資料
wemeet
0
4k
All-in-One Bioinformatics Platform Realized with Snowflake ~ From In Silico Drug Discovery, Disease Variant Analysis, to Single-Cell RNA-seq
ktatsuya
PRO
0
280
As We May Interact: Challenges and Opportunities for Next-Generation Human-Information Interaction
signer
PRO
0
240
Featured
See All Featured
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5.1k
What's in a price? How to price your products and services
michaelherold
244
12k
Designing for Performance
lara
604
68k
Optimising Largest Contentful Paint
csswizardry
33
3k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
120k
GitHub's CSS Performance
jonrohan
1030
460k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Building Adaptive Systems
keathley
38
2.3k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.4k
Learning to Love Humans: Emotional Interface Design
aarron
274
40k
The Cost Of JavaScript in 2023
addyosmani
46
7.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)