truth#
Module implementing the main class Truth wrapping the true
log-posterior and associated definitions: parameter names and labels, prior bounds and
reference bounds for initialization (optional).
- gpry.truth.get_truth(loglike, bounds=None, ref_bounds=None, params=None)[source]#
Instantiates and returns a Truth|TruthCobaya object.
- Parameters:
loglike (callable or Cobaya model object) – Log-likelihood function or Cobaya Model instance. If a Cobaya model is passed, arguments
bounds,ref_boundsandparamsare ignored, since all that information is already contained in the Cobaya model.bounds (List of [min, max], or Dict {name: [min, max],...}) – List or dictionary of parameter bounds. If it is a dictionary, the keys need to correspond to the argument names of the
likelihoodfunction, and the values can be either bounds specified as[min, max], or bounds and labels, as{"prior": [min, max], "latex": [label]}. It does not need to be defined (will be ignored) if a CobayaModelinstance is passed asloglike.ref_bounds (List of [min, max], or Dict {name: [min, max],...}) – List or dictionary of “reference” parameter bounds, i.e. bounds from within which to raw the initial set of training samples.
params (list of str, dict {str: str}, optional) – List of names for the parameters. Alternatively, a dictionary
{name: label}, wherelabelis a LaTeX-coded string, without$’s. By default, generic parameter namesx_1, x_2,...will be used.
- Return type:
truth.Truthortruth.TruthCobaya
- class gpry.truth.Truth(loglike, bounds=None, ref_bounds=None, params=None)[source]#
Bases:
objectClass holding the true log-posterior and some information about it.
- Parameters:
loglike (callable) – Log-likelihood function.
bounds (List of [min, max], or Dict {name: [min, max],...}) – List or dictionary of parameter bounds. If it is a dictionary, the keys need to correspond to the argument names of the
likelihoodfunction, and the values can be either bounds specified as[min, max], or bounds and labels, as{"prior": [min, max], "latex": [label]}. It does not need to be defined (will be ignored) if a CobayaModelinstance is passed asloglike.ref_bounds (List of [min, max], or Dict {name: [min, max],...}) – List or dictionary of “reference” parameter bounds, i.e. bounds from within which to raw the initial set of training samples.
ref_boundsmust have the same length asbounds, with None as an entry for which reference bounds different from the prior bounds are not given.params (list of str, dict {str: str}, optional) – List of names for the parameters. Alternatively, a dictionary
{name: label}, wherelabelis a LaTeX-coded string, without$’s. By default, generic parameter namesx_1, x_2,...will be used.
- property d#
Dimensionality of the problem.
- property prior_bounds#
Prior bounds, as an array of shape = (dim, 2).
- property params#
Returns the list of parameter names.
- property labels#
Returns the list of labels.