Package pylal :: Module bayespputils :: Class Posterior
[hide private]
[frames] | no frames]

Class Posterior

source code

object --+
         |
        Posterior

Data structure for a table of posterior samples .

Instance Methods [hide private]
 
__init__(self, commonResultsFormatData, SimInspiralTableEntry=None, inj_spin_frame='OrbitalL', injFref=100, SnglInpiralList=None, name=None, description=None, votfile=None)
Constructor.
source code
 
extend_posterior(self)
Add some usefule derived parameters (such as tilt angles, time delays, etc) in the Posterior object
source code
Posterior
bootstrap(self)
Returns a new Posterior object that contains a bootstrap sample of self.
source code
 
delete_samples_by_idx(self, samples)
Remove samples from all OneDPosteriors.
source code
 
delete_NaN_entries(self, param_list)
Remove samples containing NaN in request params.
source code
 
DIC(self)
Returns the Deviance Information Criterion estimated from the posterior samples.
source code
glue.ligolw.lsctables.SimInspiral
injection(self)
Return the injected values.
source code
list
triggers(self)
Return the trigger values .
source code
 
_total_incl_restarts(self, samples) source code
number
longest_chain_cycles(self)
Returns the number of cycles in the longest chain
source code
 
set_injection(self, injection)
Set the injected values of the parameters.
source code
 
set_triggers(self, triggers)
Set the trigger values of the parameters.
source code
 
_getinjpar(self, paramname)
Map parameter names to parameters in a SimInspiralTable .
source code
 
_gettrigpar(self, paramname)
Map parameter names to parameters in a SnglInspiral.
source code
 
__getitem__(self, key)
Container method .
source code
 
__len__(self)
Container method.
source code
 
__iter__(self)
Container method.
source code
 
forward(self)
Generate a forward iterator (in sense of list of names) over Posterior with name,one_d_pos.
source code
 
bySample(self)
Generate a forward iterator over the list of samples corresponding to the data stored within the Posterior instance.
source code
 
dim(self)
Return number of parameters.
source code
 
names(self)
Return list of parameter names.
source code
 
means(self)
Return dict {paramName:paramMean} .
source code
 
medians(self)
Return dict {paramName:paramMedian} .
source code
 
stdevs(self)
Return dict {paramName:paramStandardDeviation} .
source code
 
name(self)
Return qualified string containing the 'name' of the Posterior instance.
source code
 
description(self)
Return qualified string containing a 'description' of the Posterior instance.
source code
 
append(self, one_d_posterior)
Container method.
source code
 
pop(self, param_name)
Container method.
source code
 
append_mapping(self, new_param_names, func, post_names)
Append posteriors pos1,pos2,...=func(post_names)
source code
 
_average_posterior(self, samples, post_name)
Returns the average value of the 'post_name' column of the given samples.
source code
 
_average_posterior_like_prior(self, samples, logl_name, prior_name, log_bias=0)
Returns the average value of the posterior assuming that the 'logl_name' column contains log(L) and the 'prior_name' column contains the prior (un-logged).
source code
 
_bias_factor(self)
Returns a sensible bias factor for the evidence so that integrals are representable as doubles.
source code
 
di_evidence(self, boxing=64)
Returns the log of the direct-integration evidence for the posterior samples.
source code
 
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.
source code
 
harmonic_mean_evidence(self)
Returns the log of the harmonic mean evidence for the set of posterior samples.
source code
 
_posMaxL(self)
Find the sample with maximum likelihood probability.
source code
 
_posMap(self)
Find the sample with maximum a posteriori probability.
source code
 
_print_table_row(self, name, entries)
Print a html table row representation of
source code
 
maxL(self)
Return the maximum likelihood probability and the corresponding set of parameters.
source code
 
maxP(self)
Return the maximum a posteriori probability and the corresponding set of parameters.
source code
 
samples(self)
Return an (M,N) numpy.array of posterior samples; M = len(self); N = dim(self) .
source code
 
write_to_file(self, fname)
Dump the posterior table to a file in the 'common format'.
source code
 
gelman_rubin(self, pname)
Returns an approximation to the Gelman-Rubin statistic (see Gelman, A.
source code
 
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.
source code
 
__str__(self)
Define a string representation of the Posterior class ; returns a html formatted table of various properties of posteriors.
source code
 
write_vot_info(self)
Writes the information stored in the VOTtree if there is one
source code
number
_inj_m1(self, inj)
Return the mapping of (mchirp,eta)->m1; m1>m2 i.e.
source code
number
_inj_m2(self, inj)
Return the mapping of (mchirp,eta)->m2; m1>m2 i.e.
source code
number
_inj_q(self, inj)
Return the mapping of (mchirp,eta)->q; m1>m2 i.e.
source code
number
_inj_longitude(self, inj)
Return the mapping of longitude found in inj to the interval [0,2*pi).
source code
 
_inj_spins(self, inj, frame='OrbitalL') source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, commonResultsFormatData, SimInspiralTableEntry=None, inj_spin_frame='OrbitalL', injFref=100, SnglInpiralList=None, name=None, description=None, votfile=None)
(Constructor)

source code 

Constructor.

Parameters:
  • commonResultsFormatData (custom type) - A 2D array containing the posterior samples and related data. The samples chains form the columns.
  • SimInspiralTableEntry (glue.ligolw.lsctables.SimInspiral) - A SimInspiralTable row containing the injected values.
  • SnglInspiralList (list) - A list of SnglInspiral objects containing the triggers.
Overrides: object.__init__

delete_samples_by_idx(self, samples)

source code 

Remove samples from all OneDPosteriors.

Parameters:
  • samples (list) - The indexes of the samples to be removed.

delete_NaN_entries(self, param_list)

source code 

Remove samples containing NaN in request params.

Parameters:
  • param_list (list) - The parameters to be checked for NaNs.

DIC(self)

source code 

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."

Decorators:
  • @property

injection(self)

source code 

Return the injected values.

Returns: glue.ligolw.lsctables.SimInspiral
Decorators:
  • @property

triggers(self)

source code 

Return the trigger values .

Returns: list
Decorators:
  • @property

set_injection(self, injection)

source code 

Set the injected values of the parameters.

Parameters:
  • injection (glue.ligolw.lsctables.SimInspiral) - A SimInspiralTable row object containing the injected parameters.

set_triggers(self, triggers)

source code 

Set the trigger values of the parameters.

Parameters:
  • triggers (list) - A list of SnglInspiral objects.

__getitem__(self, key)
(Indexing operator)

source code 

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

__len__(self)
(Length operator)

source code 

Container method. Defined as number of samples.

__iter__(self)

source code 

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

bySample(self)

source code 

Generate a forward iterator over the list of samples corresponding to the data stored within the Posterior instance. These are returned as ParameterSamples instances.

dim(self)

source code 

Return number of parameters.

Decorators:
  • @property

names(self)

source code 

Return list of parameter names.

Decorators:
  • @property

means(self)

source code 

Return dict {paramName:paramMean} .

Decorators:
  • @property

medians(self)

source code 

Return dict {paramName:paramMedian} .

Decorators:
  • @property

stdevs(self)

source code 

Return dict {paramName:paramStandardDeviation} .

Decorators:
  • @property

name(self)

source code 

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

Decorators:
  • @property

description(self)

source code 

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

Decorators:
  • @property

append(self, one_d_posterior)

source code 

Container method. Add a new OneDParameter to the Posterior instance.

pop(self, param_name)

source code 

Container method. Remove PosteriorOneDPDF from the Posterior instance.

elliptical_subregion_evidence(self)

source code 

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.

_posMaxL(self)

source code 

Find the sample with maximum likelihood probability. Returns value of likelihood and index of sample .

_posMap(self)

source code 

Find the sample with maximum a posteriori probability. Returns value of posterior and index of sample .

_print_table_row(self, name, entries)

source code 

Print a html table row representation of

name:item1,item2,item3,...

maxL(self)

source code 

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

Decorators:
  • @property

maxP(self)

source code 

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

Decorators:
  • @property

gelman_rubin(self, pname)

source code 

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.

healpix_map(self, resol, nest=True)

source code 

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).

__str__(self)
(Informal representation operator)

source code 

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

Overrides: object.__str__

_inj_m1(self, inj)

source code 

Return the mapping of (mchirp,eta)->m1; m1>m2 i.e. return the greater of the mass components (m1) calculated from the chirp mass and the symmetric mass ratio.

Parameters:
  • inj (glue.ligolw.lsctables.SimInspiral) - a custom type with the attributes 'mchirp' and 'eta'.
Returns: number

_inj_m2(self, inj)

source code 

Return the mapping of (mchirp,eta)->m2; m1>m2 i.e. return the lesser of the mass components (m2) calculated from the chirp mass and the symmetric mass ratio.

Parameters:
  • inj (glue.ligolw.lsctables.SimInspiral) - a custom type with the attributes 'mchirp' and 'eta'.
Returns: number

_inj_q(self, inj)

source code 

Return the mapping of (mchirp,eta)->q; m1>m2 i.e. return the mass ratio q=m2/m1.

Parameters:
  • inj (glue.ligolw.lsctables.SimInspiral) - a custom type with the attributes 'mchirp' and 'eta'.
Returns: number

_inj_longitude(self, inj)

source code 

Return the mapping of longitude found in inj to the interval [0,2*pi).

Parameters:
  • inj (glue.ligolw.lsctables.SimInspiral) - a custom type with the attribute 'longitude'.
Returns: number