Example #1
0
    def corner_plot(self, **kwargs):
        """
        Produce the corner plot showing the marginal distributions in one and two directions.

        :param kwargs: arguments to be passed to the corner function
        :return: a matplotlib.figure instance
        """

        if self.samples is not None:

            assert len(self._free_parameters.keys()) == self.raw_samples[0].shape[0], ("Mismatch between sample"
                                                                                       " dimensions and number of free"
                                                                                       " parameters")

            labels = []
            priors = []

            for i, (parameter_name, parameter) in enumerate(self._free_parameters.iteritems()):

                short_name = parameter_name.split(".")[-1]

                labels.append(short_name)

                priors.append(self._likelihood_model.parameters[parameter_name].prior)

            fig = corner(self.raw_samples, labels=labels,
                         quantiles=[0.16, 0.50, 0.84],
                         priors=priors, **kwargs)

            return fig

        else:

            raise RuntimeError("You have to run the sampler first, using the sample() method")
Example #2
0
 def cornerPlot( self, **kwargs ):
     
     if hasattr( self, "samples" ):
         
         labels = []
         priors = []
         
         for i,( srcName, paramName ) in enumerate( self.freeParameters.keys() ):
             
             thisLabel = "%s of %s" % ( paramName, srcName )
             
             labels.append( thisLabel )
             
             priors.append( self.likelihoodModel.parameters[ srcName ][ paramName ].prior )
         
         fig = corner( self.samples, labels=labels, 
                       quantiles=[0.16, 0.50, 0.84],
                       priors = priors, **kwargs )
         
         return fig
     
     else:
         
         raise RuntimeError("You have to run the sampler first, using the sample() method")