observations to models lecture 3
play

Observations to Models Lecture 3 Exploring likelihood spaces - PowerPoint PPT Presentation

Observations to Models Lecture 3 Exploring likelihood spaces with CosmoSIS Joe Zuntz University of Manchester Defining Likelihood Pipelines Boltzmann Nonlinear P(k) P(k) and D A (z) Theory shear Photometric C


  1. Observations to Models Lecture 3 � Exploring likelihood spaces 
 with CosmoSIS Joe Zuntz 
 University of Manchester

  2. Defining Likelihood Pipelines Boltzmann 
 Nonlinear P(k) P(k) and D A (z) Theory shear 
 Photometric 
 C ℓ redshift n(z) Binned Theory 
 Likelihood C b Measured 
 C b

  3. Defining Likelihood Pipelines Boltzmann 
 Nonlinear P(k) P(k) and D A (z) Theory shear 
 Photo-z Photometric 
 C ℓ Systematics redshift n(z) Binned Theory 
 Shape Errors Likelihood C b Measured 
 C b

  4. Modular Likelihood Pipelines • Each box is an independent piece of code ( module ) • With well-defined inputs and outputs • This lets you replace, compare, insert, and combine code more easily

  5. CosmoSIS • CosmoSIS is a parameter estimation framework • Connect inference methods to cosmology likelihoods https://bitbucket.org/joezuntz/cosmosis

  6. Setting up CosmoSIS on teaching machines • Open VirtualBox • Click “start” • Password cosmosis • Click Terminal > su • use password cosmosis > cd /opt/cosmosis > source config/setup-cosmosis

  7. Pipeline Example > cosmosis demos/demo2.ini > postprocess -o plots -p demo2 demos/demo2.ini CMB 
 Planck 
 Bicep 
 Parameters Calculation Likelihood Likelihood Total 
 Saved Cosmological Theory Information Likelihood https://bitbucket.org/joezuntz/cosmosis/wiki/Demo2

  8. Basic Inference Methods • You’ve made a posterior function from a 
 likelihood function and a prior • Now what? • Explore the parameter space and build constraints on parameters • Remember: “the answer” is a probability distribution

  9. Basic Inference: 
 Grids · · · · · · · · · · • Low number of parameters 
 · · · · · · · · · · ⇒ can try grid of all possible · · · · · · · · · · · · · · · · · · · · y · · · · · · · · · · parameter combinations · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · • Number of posterior evaluations 
 · · · · · · · · · · = (grid points per param) (number params) · · · · · · · · · · x • Approximate PDF integrals as sums

  10. Basic Inference: 
 Grids • Get constraints on lower dimensions by summing along axes Z P ( X ) = P ( XY )d y X δ Y i P ( X, Y i ) ≈ i X δ P ( X, Y i ) ∝ i

  11. Grid Example > cosmosis demos/demo7.ini > postprocess -o plots -p demo7 demos/demo7.ini Growth 
 BOSS 
 Parameters Function Likelihood Total 
 Saved Cosmological Theory Information Likelihood https://bitbucket.org/joezuntz/cosmosis/wiki/Demo7

  12. Basic Inference: 
 Maximum Likelihood/Posterior • The modal value of a distribution can be of interest, especially for near-symmetric distributions • Find mode by solving gradient=0 
 • Maximum-likelihood (ML) 
 Maximum a Posteriori (MAP) 


  13. Basic Inference: 
 Maximum Likelihood/Posterior • In 1D cases solve: d P d log P d x = 0 or = 0 � d x • Multi-dimensional case: r log P = 0 r P = 0 or

  14. Basic Inference: 
 Maximum Likelihood/Posterior • Around the peak of a likelihood the curvature is related to distribution width • Usually easiest to do with logs, for example for a Gaussian: d 2 log P � = − 1 � � d x 2 σ 2 � x = µ

  15. ML Exercise • Find the maximum likelihood of our LMC cepheid likelihood, assuming fixed σ i : ✓ ( V obs − ( α + β log 10 P i )) 2 ◆ 1 P ( V obs i | p ) ∝ exp − 0 . 5 i σ 2 int + σ 2 σ 2 int + σ 2 i i • Much easier to use log(P)

  16. ML Example > cosmosis demos/demo4.ini > postprocess -o plots -p demo4 demos/demo4.ini CMB 
 Planck 
 Parameters Calculation Likelihood Total 
 Saved Cosmological Theory Information Likelihood https://bitbucket.org/joezuntz/cosmosis/wiki/Demo4

  17. Basic Inference: 
 Maximum Likelihood/Posterior • In simple cases you can solve these analytically. Otherwise need some kind of optimization • Numerical solvers - various algorithms; 
 google scipy.minimize for a nice list • Usually easier with gradients 
 e.g. Newton-Raphson • See also Expectation-Maximization algorithm

  18. Monte Carlo Methods • Collection of methods 
 involving repeated sampling 
 to get numerical results • e.g. chance of dealing 
 two pairs in five cards? • Multi-dimensional integrals, graphics, fluid dynamics, genetics & evolution, AI, finance

  19. Sampling Overview • “Sample” = “Generate values with given distribution” • Easy: distribution written down analytically • Harder: can only evaluate distribution for given parameter choice

  20. Sampling Motivation • Simulate systems • Short-cut to expectations if you hate maths • Approximate & characterize distributions • Estimate distributions mean, std, etc. • Make constraint plots • Compare with other data

  21. Direct Sampling • Simple analytic distribution: 
 can generate samples 
 pseudo-randomly • Actually incredibly complicated! • import scipy.stats 
 X = scipy.stats.poisson(5.0) 
 x = X.rvs(1000) � • Be aware of random seeds

  22. Direct Sampling • e.g. approx solution to Lecture 1 homework problem � � � • Often easier than doing sums/integrals

  23. Monte Carlo Markov Chains • Often cannot directly sample from a distribution • But can evaluate P(x) for any given x • Markov chain = memory-less sequence x n = f ( x n − 1 ) � • MCMC: Random generation rule for f(x) which yields x n with stationary distribution P(x) 
 i.e. chain histogram tends to P

  24. MCMC • Jump around parameter space • Number of jumps near x ~ P(x) 
 � � � • Standard algorithms: x = single parameter set 
 Advanced algorithms: x = multiple parameter sets

  25. Metropolis-Hastings • Given current sample x n in parameter space p n ∼ Q ( p n | x n ) • Generate new proposed sample Q ( p | x ) = Q ( x | p ) • For simplest algorithm ( ⇣ ⌘ P ( p n ) with probability max P ( x n ) , 1 p n x n +1 = otherwise x n

  26. Metropolis-Hastings x n

  27. Metropolis-Hastings Q ( p n | x n )

  28. Metropolis-Hastings P ( p n ) > P ( x n ) Definite accept

  29. Metropolis-Hastings P ( p n ) < P ( x n ) Let α = P ( p n ) /P ( x n ) Generate u ∼ U (0 , 1) Accept if α > u

  30. Metropolis-Hastings unlikely to 
 accept maybe 
 accept

  31. Metropolis-Hastings

  32. Metropolis-Hastings Proposal • MCMC will always converge in ∞ samples • Proposal function Q determines efficiency of MCMC • Ideal proposal has cov(Q) ~ cov(P) • (Multivariate) Gaussian centred on x n usually good 
 Tune σ (+covariance) to match P • Ideal acceptance fraction ~ 0.2 - 0.3

  33. Metropolis Example > cosmosis demos/demo10.ini > #This will take too long! Figure out how to change demo 7 to use Metropolis! CMB 
 WMAP 
 Parameters Calculation Likelihood Total 
 Saved Cosmological Theory Information Likelihood https://bitbucket.org/joezuntz/cosmosis/wiki/Demo10

  34. Metropolis-Hastings Convergence • Have I taken enough samples? • Many convergence tests available • Easiest is visual!

  35. Metropolis-Hastings Convergence • Bad Mixing • Structure and x correlations visible Chain Position

  36. Metropolis-Hastings Convergence • Good Mixing • Looks like noise x • Must be true for all parameters in space Chain Position

  37. Metropolis-Hastings Convergence • Run several chains and compare results • (Variance of means) / (Mean of variances) 
 Less than e.g. 3%

  38. Metropolis-Hastings Burn in • Chain will explore Probability peak only after finding it • Cut off start of chain Chain Position

  39. Metropolis-Hastings Analysis • Probability proportional to chain multiplicity Probability • Histogram chain, in 1D or 2D • Can also thin e.g. remove every other sample x

  40. Metropolis-Hastings Analysis • Can also get expectations of derived parameters P ( x ) f ( x )d x ≈ 1 Z X E [ f ( x )] = f ( x i ) N i

  41. Emcee Sampling • Goodman & Weare algorithm • Group of live “walkers” in parameter space • Parallel update rule on connecting lines - affine invariant • Popular in astronomy for nice and friendly python package

  42. Emcee Sampling • Goodman & Weare algorithm • Group of live “walkers” in parameter space • Parallel update rule on connecting lines - affine invariant • Popular in astronomy for nice and friendly python package

  43. Emcee Example > cosmosis demos/demo5.ini > postprocess demos/demo5.ini -o plots -p demo5 Distance 
 Supernova 
 H 0 
 Parameters Calculation Likelihood Likelihood Total 
 Saved Cosmological Theory Information Likelihood https://bitbucket.org/joezuntz/cosmosis/wiki/Demo5

  44. Model Selection • Given two models, how can we compare them? • Simplest approach = compare ML • Does not include uncertainty or Occam’s Razor • Recall that all our probabilities have been conditional on the model, as in Bayes: P ( p | M ) = P ( d | pM ) P ( p | M ) P ( d | M )

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend