joshspeagle / dynesty

Dynamic Nested Sampling package for computing Bayesian posteriors and evidences
https://dynesty.readthedocs.io/
MIT License
347 stars 76 forks source link

How to plot part of the parameters? #143

Closed gapplef closed 5 years ago

gapplef commented 5 years ago

The problems is I have many parameters in the sampling, say 20, but I only want to choose 3 of them to draw the corner plot. In MCMC case I can simply choose the data to plot, but for dynesty, the result is not array and the samples are not equally weighted if I understand correctly. I checked the documents, but didn't find related settings. So it it possible to plot part of the parameters with dynesty.plotting.cornerplot, and how to do it?

joshspeagle commented 5 years ago

There should definitely be a simple API for this. My personal preference would be adding in a dims argument where you could specify which parameters you wanted to plot.

At the moment, dynesty.plotting.cornerplot essentially works by ripping out the results.samples and results.logwt and using those to plot up the weighted samples (similar to corner.py). So to get a subset of parameters, you just have to modify the results.samples to only include the dimensions you want. This is obviously not ideal, but should hopefully be okay as an immediate workaround.

gapplef commented 5 years ago

I'm new to nested sampling, also not familiar with the data format of dynesty and the pre-process in dynesty.plotting.cornerplot. So, manually modify results.samples would not cause dimension mismatch error or affect the weights calculation for the samples, thus output wrong plot.

joshspeagle commented 5 years ago

The results object is just a dictionary containing various quantities, and plotting.cornerplot just pulls out some of the things stored there when plotting. Modifying the results.samples before plotting shouldn't cause any huge issues, although I would make sure to save a copy of the original samples array elsewhere first.

gapplef commented 5 years ago

@joshspeagle thanks a lot!