Skip to content

Commit

Permalink
updating, including Udos comments
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesBuchner committed Nov 21, 2013
1 parent 1b0baff commit 1d856b6
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 33 deletions.
3 changes: 2 additions & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,5 @@


# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'http://docs.python.org/': None}
intersphinx_mapping = {} #'http://docs.python.org/': None}

4 changes: 4 additions & 0 deletions doc/source/example1.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Example 1: One-dimensional multi-modal problem
===============================================

Get a copy of the `tutorial example code <https://github.com/JohannesBuchner/pymultinest-tutorial>`_::

$ git clone https://github.com/JohannesBuchner/pymultinest-tutorial

In the folder example1, find the file 1d_multimodal.py. It illustrates how to call pymultinest with

* one dimension only
Expand Down
3 changes: 2 additions & 1 deletion doc/source/example2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ Your task
3. What is the evidence for this model?
4. **Extend the model to 2 gaussian lines.**
5. Are 2 gaussian lines preferred? I.e. is the evidence higher?
6. Analyse the other datasets. Are the results the same?
6. Are 3 gaussian lines preferred?
7. Analyse the other datasets. Are the results the same?

Continue with :doc:`example3` ...

17 changes: 10 additions & 7 deletions doc/source/example3.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Example 3: Gaussian Emission lines - correlations
==================================================

In :doc:example2, we analysed emission lines. We now have the derived parameters
In :doc:`example2`, we analysed emission lines. We now have the derived parameters
distribution for each spectrum.

* Are the line widths and heights correlated?
Expand All @@ -13,15 +13,18 @@ How would you answer these questions?
Keep in mind, that you want to take into account the uncertainties in the
derived parameters!


Next
-----
------

a) For inspiration to the problem above, look at `SysCorr <http://johannesbuchner.github.io/syscorr/index.html>`_ and continue with the example there.
b) Solve the `light-house problem <http://www.gps.caltech.edu/classes/ge193/practicals/practical3/Lighthouse.pdf>`_ with one light house, and with two light houses. Apply model selection!
c) You may want to implement your own problem using pymultinest.

* You may want to implement your own problem using pymultinest.
* For inspiration, to the problem above, look at `SysCorr <http://johannesbuchner.github.io/syscorr/index.html>`_ and continue with its example.
Links
-------
* `jbopt <http://johannesbuchner.github.io/jbopt/index.html>`_ is a cross-algorithm parameter space exploration toolkit. Check out the code example!
* `PyMultiNest documentation <http://johannesbuchner.github.io/pymultinest/index.html>`_
* Also check out pycuba, a integration library.
* `jbopt <http://johannesbuchner.github.io/jbopt/index.html>`_ is a cross-algorithm parameter space exploration toolkit. Check out the code example.
* Also check out pycuba, a Monte Carlo integration library.



3 changes: 2 additions & 1 deletion doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ It should kickstart you to
* run pymultinest
* visualize and interpret the results

Make sure you have :doc:`pymultinest installed <install>`. Then, **go get started with** :doc:`Example 1 <example1>`!
Make sure you have :doc:`pymultinest installed <install>` correctly.
Then, **go get started with** :doc:`Example 1 <example1>`!

Contents
---------------
Expand Down
19 changes: 8 additions & 11 deletions doc/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,18 @@ On the school computers

1. Log in, and run the bash shell::

[school08@naf-school01]~% bash
school08@naf-school01 ~ $
$ ssh -Y schoolNN@naf-school01.desy.de
[schoolNN@naf-school01]~% bash
bash-4.1$

2. Load the environment::
$ . /afs/desy.de/group/school/mc-school/setup_pymultinest.sh

3. Test it::

$ mkdir test
$ cd test
$ python /afs/desy.de/group/school/mc-school/multinest-install/PyMultiNest/pymultinest_demo_minimal.py
$ multinest_marginals.py chains/1-

bash-4.1$ source /afs/desy.de/group/school/mc-school/setup_pymultinest.sh
installing pymultinest ... installation successful
configuring environment and testing ... ok
schoolNN@naf-school01 ~ $

Go start with Example 1. Do not waste time installing on your own computer before having finished Example 1.

On your own computer
----------------------------
Expand Down
5 changes: 3 additions & 2 deletions example1/1d_multimodal.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def loglike(cube, ndim, nparams):
# get the current parameter (is between 0:2 now)
pos = cube[0]
likelihood = exp(-0.5 * ((pos - positions) / width)**2) / (2*pi*width**2)**0.5
return log(likelihood.sum())
return log(likelihood.mean())

# number of dimensions our problem has
parameters = ["position"]
Expand All @@ -37,5 +37,6 @@ def loglike(cube, ndim, nparams):
#
# then open the file 1_1d_multimodal_outmarg.pdf
#
# Btw, ln(ev) should be ln(6 / 2)
# Btw, ln(ev) should be ln(1 / 2)


6 changes: 5 additions & 1 deletion example2/lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ def loglike(cube, ndim, nparams):

a_lnZ = a.get_stats()['global evidence']
print
print ' log p(model = 1 line ) = %.1f%s' % (a_lnZ / log(10),
print '************************'
print 'MAIN RESULT: Evidence Z '
print '************************'
print ' log Z for model with 1 line = %.1f' % (a_lnZ / log(10))
print

# TODO: implement a model with 2 lines?

Expand Down
103 changes: 94 additions & 9 deletions slides/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@
padding: 0.2em 0.5em;
border-bottom: 1px dashed #CCC;
}

.checkboxlist li {
list-style: none;
}
.checkboxlist li:before
{
content: "\2610";
margin-right:5px;
}

.checkboxlist li:hover:before
{
content: "\2611";
margin-right:5px;
}
</style>

<script type="text/javascript">
Expand All @@ -51,17 +66,62 @@ <h3>Casual parameter estimation and model selection</h3>
<p style="font-size: 0.75em">Max Planck Institute for Extraterrestrial Physics
<p style="font-size: 0.75em">November 2013
</section>

<section>
<h2>About me</h2>
<ul><li>implemented MCMC sampler for Bachelor thesis
<li>since then, 5 years of experience with Monte Carlo methods for Bayesian inference
<li>Numerical Likelihood functions, low-dimensional (&lt;20)
<li>Numerical Likelihood functions (0.1-5s), low-dimensional (&lt;20)
<li>Research on accreting supermassive black hole in X-ray (Poisson spectra)
<li>Recent interest: smooth field reconstruction with numerical likelihoods (20-500 dimensions)
</ul>
<p style="font-size: 0.5em"><a href="https://www.mpe.mpg.de/~jbuchner/">https://www.mpe.mpg.de/~jbuchner/</a> -- Johannes Buchner
</section>

<section>
<h2>Go-to Methods</h2>
<div style="text-align: left">
(for numerical likelihoods)
<h3>Parameter estimation</h3>
<ul>
<li>Optimize to maximum (ML/MAP)
<li>explore around it with MCMC
<li>High-dimensional, misbehaved: MCMC (?), HMC (?)
<li>
</ul>
<h3>Model selection</h3>
<ul>
<li>High-dimensional:
<li>Low-dimensional:
<li>Nested models:
</ul>
</div>
</section>

<section>
<h2>Tools so far</h2>
<div style="text-align: left">
(for numerical likelihoods)
<h3>Parameter estimation</h3>
<ul>
<li>Optimize to maximum (ML/MAP)
<li>explore around it with MCMC
<li>High-dimensional, misbehaved: MCMC (?), HMC (?)
<li>Low-dimensional, multi-modal: MultiNest
</ul>
<h3>Model selection</h3>
<ul>
<li>High-dimensional: give up
<li>Low-dimensional (&lt;20), multi-modal: MultiNest
<li>Nested models: AIC + DE
</ul>
also for Low-dimensional, multi-modal: MultiNest
</div>
</section>

<section>
<h2>What will we do today?</h2>
Goal: solving <script type="math/tex">Z</script> integrals
<ul>
<li>Write likelihood functions
<li>Write prior functions
Expand All @@ -73,9 +133,11 @@ <h2>What will we do today?</h2>
<section>
<h2>Software: PyMultiNest</h2>
<ul>
<li>based on MultiNest: written by Farhan Feroz and Mike Hobson
<li>based on MultiNest: written by Farhan Feroz and Mike Hobson (2007)
<li>Finds clusters -> sampling from ellipses
<li>Python instead of writing Fortran or C functions
<li>parses output, and does a bit of plotting
<li>Also produces "Markov Chain" for uncertainty propagation
</ul>
</section>

Expand All @@ -92,14 +154,23 @@ <h2>Prior functions: A math trick</h2>

<div class="fragment"><ul><li>transformation through inverse of CDF
<li>compresses unimportant regions
<li>"native units" - can also do this in MCMC!
<li>"native units": <script type="math/tex">P(\theta|D)\propto \int_0^1{P(D|u) du} </script>
<li>can also do this in MCMC!
</ul></div>
</section>
<section>
<h2>Prior functions: A math trick</h2>
<ul>
<li>Transform from unit cube to parameter space
<li>Using inverse CDF of prior
</ul>

<img src="prior_transform_uniform.png" style="background-color: white;" />
<img src="prior_transform_loguniform.png" style="background-color: white;"/>
<pre><code data-trim class="python">
def prior(cube, ndim, nparams):
cube[0] = cube[0] * 2
cube[1] = 10**(cube[1] * 10 - 5)
</code></pre></div>
cube[0] = cube[0] * (3 - 1) + 1
cube[1] = 10**(cube[1] * (1 + 0.5) - 1)
</code></pre>
</section>


Expand All @@ -125,11 +196,25 @@ <h2>Shortest Code Example</h2>
<section>
<h2>Tutorial</h2>
<a href="http://johannesbuchner.github.io/pymultinest-tutorial/" target="_window">http://johannesbuchner.github.io/pymultinest-tutorial/</a>
<pre><code data-trim class="bash">$ ssh -Y schoolNN@naf-school01.desy.de
$ bash
$ source /afs/desy.de/group/school/mc-school/setup_pymultinest.sh
$ git clone https://github.com/JohannesBuchner/pymultinest-tutorial</code></pre>
<ul class="checkboxlist">
<li>Example 1: <i>1d multi-modal problem</i>
<li>Example 2: <i>Spectral line analysis</i> -- 1 line or 2 lines?
<li>Example 3: Hierarchical Bayes, Your own, Lighthouse problem, further reading
</ul>
</section>

<section>
<h2>References</h2>

<h2>Final points</h2>
<ul>
<li>Correlation of parameters from posterior samples <a href="http://johannesbuchner.github.io/syscorr/index.html">SysCorr</a>
<li>Throw multiple algorithms against problem (<a href="http://johannesbuchner.github.io/jbopt/index.html">jbopt</a>)
<li>Fully automated model selection, but is model a good one? Systematic errors? Confidence on model choice?
<li>PyMultiNest reference: Buchner et al (in prep), MultiNest: arXiv:0704.3704, arXiv:0809.3437 & arXiv:1306.2144
</ul>
</section>

</div>
Expand Down

0 comments on commit 1d856b6

Please sign in to comment.