LALInference  4.1.6.1-fe68b98
lalinference.bayespputils.Posterior Class Reference

Detailed Description

Data structure for a table of posterior samples .

Definition at line 901 of file bayespputils.py.

Inherits object.

Inherited by lalinference.bayespputils.BurstPosterior.

Public Member Functions

def __init__ (self, commonResultsFormatData, SimInspiralTableEntry=None, inj_spin_frame='OrbitalL', injFref=100, SnglInspiralList=None, name=None, description=None)
 Constructor. More...
 
def extend_posterior (self)
 Add some useful derived parameters (such as tilt angles, time delays, etc) in the Posterior object. More...
 
def bootstrap (self)
 Returns a new Posterior object that contains a bootstrap sample of self. More...
 
def delete_samples_by_idx (self, samples)
 Remove samples from all OneDPosteriors. More...
 
def delete_NaN_entries (self, param_list)
 Remove samples containing NaN in request params. More...
 
def DIC (self)
 Returns the Deviance Information Criterion estimated from the posterior samples. More...
 
def injection (self)
 Return the injected values. More...
 
def triggers (self)
 Return the trigger values . More...
 
def longest_chain_cycles (self)
 Returns the number of cycles in the longest chain. More...
 
def set_injection (self, injection)
 Set the injected values of the parameters. More...
 
def set_triggers (self, triggers)
 Set the trigger values of the parameters. More...
 
def __getitem__ (self, key)
 Container method . More...
 
def __len__ (self)
 Container method. More...
 
def __iter__ (self)
 Container method. More...
 
def forward (self)
 Generate a forward iterator (in sense of list of names) over Posterior with name,one_d_pos. More...
 
def bySample (self)
 Generate a forward iterator over the list of samples corresponding to the data stored within the Posterior instance. More...
 
def dim (self)
 Return number of parameters. More...
 
def names (self)
 Return list of parameter names. More...
 
def means (self)
 Return dict {paramName:paramMean} . More...
 
def medians (self)
 Return dict {paramName:paramMedian} . More...
 
def stdevs (self)
 Return dict {paramName:paramStandardDeviation} . More...
 
def name (self)
 Return qualified string containing the 'name' of the Posterior instance. More...
 
def description (self)
 Return qualified string containing a 'description' of the Posterior instance. More...
 
def append (self, one_d_posterior)
 Container method. More...
 
def pop (self, param_name)
 Container method. More...
 
def append_mapping (self, new_param_names, func, post_names)
 Append posteriors pos1,pos2,...=func(post_names) More...
 
def di_evidence (self, boxing=64)
 Returns the log of the direct-integration evidence for the posterior samples. More...
 
def elliptical_subregion_evidence (self)
 Returns an approximation to the log(evidence) obtained by fitting an ellipse around the highest-posterior samples and performing the harmonic mean approximation within the ellipse. More...
 
def harmonic_mean_evidence (self)
 Returns the log of the harmonic mean evidence for the set of posterior samples. More...
 
def maxL (self)
 Return the maximum likelihood probability and the corresponding set of parameters. More...
 
def maxP (self)
 Return the maximum a posteriori probability and the corresponding set of parameters. More...
 
def samples (self)
 Return an (M,N) numpy.array of posterior samples; M = len(self); N = dim(self) . More...
 
def write_to_file (self, fname)
 Dump the posterior table to a file in the 'common format'. More...
 
def gelman_rubin (self, pname)
 Returns an approximation to the Gelman-Rubin statistic (see Gelman, A. More...
 
def healpix_map (self, resol, nest=True)
 Returns a healpix map in the pixel ordering that represents the posterior density (per square degree) on the sky. More...
 
def __str__ (self)
 Define a string representation of the Posterior class ; returns a html formatted table of various properties of posteriors. More...
 

Constructor & Destructor Documentation

◆ __init__()

def lalinference.bayespputils.Posterior.__init__ (   self,
  commonResultsFormatData,
  SimInspiralTableEntry = None,
  inj_spin_frame = 'OrbitalL',
  injFref = 100,
  SnglInspiralList = None,
  name = None,
  description = None 
)

Constructor.

Parameters
commonResultsFormatDataA 2D array containing the posterior samples and related data. The samples chains form the columns.
SimInspiralTableEntryA SimInspiralTable row containing the injected values.
SnglInspiralListA list of SnglInspiral objects containing the triggers.
inj_spin_framespin frame
injFrefreference frequency
nameoptional name
descriptionoptional description

Definition at line 915 of file bayespputils.py.

Member Function Documentation

◆ extend_posterior()

def lalinference.bayespputils.Posterior.extend_posterior (   self)

Add some useful derived parameters (such as tilt angles, time delays, etc) in the Posterior object.

Definition at line 1023 of file bayespputils.py.

◆ bootstrap()

def lalinference.bayespputils.Posterior.bootstrap (   self)

Returns a new Posterior object that contains a bootstrap sample of self.

Definition at line 1396 of file bayespputils.py.

◆ delete_samples_by_idx()

def lalinference.bayespputils.Posterior.delete_samples_by_idx (   self,
  samples 
)

Remove samples from all OneDPosteriors.

Parameters
samplesThe indexes of the samples to be removed.

Definition at line 1420 of file bayespputils.py.

◆ delete_NaN_entries()

def lalinference.bayespputils.Posterior.delete_NaN_entries (   self,
  param_list 
)

Remove samples containing NaN in request params.

Parameters
param_listThe parameters to be checked for NaNs.

Definition at line 1430 of file bayespputils.py.

◆ DIC()

def lalinference.bayespputils.Posterior.DIC (   self)

Returns the Deviance Information Criterion estimated from the posterior samples.

The DIC is defined as -2*(<log(L)> - Var(log(L))); smaller values are "better."

Definition at line 1454 of file bayespputils.py.

◆ injection()

def lalinference.bayespputils.Posterior.injection (   self)

Return the injected values.

Definition at line 1463 of file bayespputils.py.

◆ triggers()

def lalinference.bayespputils.Posterior.triggers (   self)

Return the trigger values .

Definition at line 1472 of file bayespputils.py.

◆ longest_chain_cycles()

def lalinference.bayespputils.Posterior.longest_chain_cycles (   self)

Returns the number of cycles in the longest chain.

Definition at line 1490 of file bayespputils.py.

◆ set_injection()

def lalinference.bayespputils.Posterior.set_injection (   self,
  injection 
)

Set the injected values of the parameters.

Parameters
injectionA SimInspiralTable row object containing the injected parameters.

Definition at line 1514 of file bayespputils.py.

◆ set_triggers()

def lalinference.bayespputils.Posterior.set_triggers (   self,
  triggers 
)

Set the trigger values of the parameters.

Parameters
triggersA list of SnglInspiral objects.

Definition at line 1527 of file bayespputils.py.

◆ __getitem__()

def lalinference.bayespputils.Posterior.__getitem__ (   self,
  key 
)

Container method .

Returns posterior chain,one_d_pos, with name one_d_pos.name.

Definition at line 1568 of file bayespputils.py.

◆ __len__()

def lalinference.bayespputils.Posterior.__len__ (   self)

Container method.

Defined as number of samples.

Definition at line 1574 of file bayespputils.py.

◆ __iter__()

def lalinference.bayespputils.Posterior.__iter__ (   self)

Container method.

Returns iterator from self.forward for use in for (...) in (...) etc.

Definition at line 1581 of file bayespputils.py.

◆ forward()

def lalinference.bayespputils.Posterior.forward (   self)

Generate a forward iterator (in sense of list of names) over Posterior with name,one_d_pos.

Definition at line 1588 of file bayespputils.py.

◆ bySample()

def lalinference.bayespputils.Posterior.bySample (   self)

Generate a forward iterator over the list of samples corresponding to the data stored within the Posterior instance.

These are returned as ParameterSamples instances.

Definition at line 1601 of file bayespputils.py.

◆ dim()

def lalinference.bayespputils.Posterior.dim (   self)

Return number of parameters.

Definition at line 1614 of file bayespputils.py.

◆ names()

def lalinference.bayespputils.Posterior.names (   self)

Return list of parameter names.

Definition at line 1621 of file bayespputils.py.

◆ means()

def lalinference.bayespputils.Posterior.means (   self)

Return dict {paramName:paramMean} .

Definition at line 1631 of file bayespputils.py.

◆ medians()

def lalinference.bayespputils.Posterior.medians (   self)

Return dict {paramName:paramMedian} .

Definition at line 1641 of file bayespputils.py.

◆ stdevs()

def lalinference.bayespputils.Posterior.stdevs (   self)

Return dict {paramName:paramStandardDeviation} .

Definition at line 1651 of file bayespputils.py.

◆ name()

def lalinference.bayespputils.Posterior.name (   self)

Return qualified string containing the 'name' of the Posterior instance.

Definition at line 1661 of file bayespputils.py.

◆ description()

def lalinference.bayespputils.Posterior.description (   self)

Return qualified string containing a 'description' of the Posterior instance.

Definition at line 1668 of file bayespputils.py.

◆ append()

def lalinference.bayespputils.Posterior.append (   self,
  one_d_posterior 
)

Container method.

Add a new OneDParameter to the Posterior instance.

Definition at line 1674 of file bayespputils.py.

◆ pop()

def lalinference.bayespputils.Posterior.pop (   self,
  param_name 
)

Container method.

Remove PosteriorOneDPDF from the Posterior instance.

Definition at line 1681 of file bayespputils.py.

◆ append_mapping()

def lalinference.bayespputils.Posterior.append_mapping (   self,
  new_param_names,
  func,
  post_names 
)

Append posteriors pos1,pos2,...=func(post_names)

Definition at line 1687 of file bayespputils.py.

◆ di_evidence()

def lalinference.bayespputils.Posterior.di_evidence (   self,
  boxing = 64 
)

Returns the log of the direct-integration evidence for the posterior samples.

Definition at line 1789 of file bayespputils.py.

◆ elliptical_subregion_evidence()

def lalinference.bayespputils.Posterior.elliptical_subregion_evidence (   self)

Returns an approximation to the log(evidence) obtained by fitting an ellipse around the highest-posterior samples and performing the harmonic mean approximation within the ellipse.

Because the ellipse should be well-sampled, this provides a better approximation to the evidence than the full-domain HM.

Definition at line 1817 of file bayespputils.py.

◆ harmonic_mean_evidence()

def lalinference.bayespputils.Posterior.harmonic_mean_evidence (   self)

Returns the log of the harmonic mean evidence for the set of posterior samples.

Definition at line 1884 of file bayespputils.py.

◆ maxL()

def lalinference.bayespputils.Posterior.maxL (   self)

Return the maximum likelihood probability and the corresponding set of parameters.

Definition at line 1939 of file bayespputils.py.

◆ maxP()

def lalinference.bayespputils.Posterior.maxP (   self)

Return the maximum a posteriori probability and the corresponding set of parameters.

Definition at line 1952 of file bayespputils.py.

◆ samples()

def lalinference.bayespputils.Posterior.samples (   self)

Return an (M,N) numpy.array of posterior samples; M = len(self); N = dim(self) .

Definition at line 1965 of file bayespputils.py.

◆ write_to_file()

def lalinference.bayespputils.Posterior.write_to_file (   self,
  fname 
)

Dump the posterior table to a file in the 'common format'.

Definition at line 1978 of file bayespputils.py.

◆ gelman_rubin()

def lalinference.bayespputils.Posterior.gelman_rubin (   self,
  pname 
)

Returns an approximation to the Gelman-Rubin statistic (see Gelman, A.

and Rubin, D. B., Statistical Science, Vol 7, No. 4, pp. 457–511 (1992)) for the parameter given, accurate as the number of samples in each chain goes to infinity. The posterior samples must have a column named 'chain' so that the different chains can be separated.

Definition at line 1996 of file bayespputils.py.

◆ healpix_map()

def lalinference.bayespputils.Posterior.healpix_map (   self,
  resol,
  nest = True 
)

Returns a healpix map in the pixel ordering that represents the posterior density (per square degree) on the sky.

The pixels will be chosen to have at least the given resolution (in degrees).

Definition at line 2029 of file bayespputils.py.

◆ __str__()

def lalinference.bayespputils.Posterior.__str__ (   self)

Define a string representation of the Posterior class ; returns a html formatted table of various properties of posteriors.

Definition at line 2062 of file bayespputils.py.