Clone wiki

cosmosis / Demo20

Demo 20: Split Demo5 into two parts using the Importance sampler

The basic idea in Importance sampling is that, given some broad sample of points in a parameter space, some of the sample points have more influence on some maximizing function than others, and if we push a Monte-Carlo re-sampling process to follow paths of these more influential samples then the estimator will have overall less variance and will approach the maximum quicker (with less computational effort).

Demo 5 uses the sum of two likelihood functions, jla (supernovae Joint Light-curve Analysis) and riess (Riess 2011), to constrain the cosmological parameters. In this demonstration of the use of the Importance sampler we perform the same analysis but separate the constraining of H0 by riess into a second step which re-samples the jla sample points using the riess likelihood to determine the importance of those sample points according to their H0 values; more specifically in this demonstration, the riess log-likelihoods are added to those produced from the jla run to determine the new `importance' likelihoods.


Run Demo 20a with this command:

cosmosis demos/demo20a.ini

The output will be demo20a.txt, which will contain the set of points sampled by emcee according only to likelihoods computed from jla.

Now run Demo 20b with this command:

cosmosis demos/demo20b.ini

which will take the demo20a.txt as input, and output demo20b.txt; this latter file should be similar--but not identical to--the output from Demo 5. You can make plots of the outputs exactly as you could with Demo 5, and compare the results!

Cosmosis Configuration

Regarding demo20b.ini, the Importance sampler is selected in the top section, runtime, of the file, and a new section called importance is accordingly added to the file. There are three parameters to set here

  • input is the file with the log-likelihoods of the input samples; this file is in exactly the same format as Cosmosis' output files, hence in this case we can directly specify the output from Demo 20a as our input file.

  • nstep is the number of likelihood steps performed between each line of output to the output file.

  • add_to_likelihood is a boolean value indicating that newly computed log-likelihoods should be added to the input ones, rather than outright replacing them, in determining the importance of the input sample points.

Finally, we notice that the item [pipeline]/modules is modified to only run the riess likelihood function.