gns.toy_models module¶
-
gns.toy_models.getTargetSupport(priorParams)[source]¶ Returns prior domain for prior specified by priorParams. Assumes support of priors (in each dimension) is well connected, which it will always be for simple priors considered so far. Returns array of shape (3, nDims) where first column is lower bound on prior, second is upper bound, and third is difference between too (note inf - -inf is set equal to inf). Fourth row is only important for theoretical Z/ H functions, as it tells them if the prior corresponding to the dimension is rectangular, and thus if it needs to be integrated over or not
Args:
priorParams: array containing prior type (denoted by integer) and hyperparameters (array).
Returns:
array of target support values in array of shape (3, nDims)
-
gns.toy_models.getToyFuncs(priorParams, LhoodParams)[source]¶ get prior and lhood functions which can be passed to NestedRun or multinest wrapper functions, i.e. calls the functions getToyObjects() and getToyProbFuncs().
Args:
priorParams: array containing prior type (denoted by integer) and hyperparameters (array), see getToyHypers() docstring.
LhoodParams: list containing likelihood type (denoted by integer) and hyperparameters (array), see getToyHypers() docstring.
Priors which prior types integers correspond to can be found in fitPriors() in prob_funcs.py.
Likelihoods which likelihood types integers correspond to can be found in fitLhood() in prob_funcs.py.
Returns:
Prior and likelihood probability functions in order: prior, log prior, prior quantile, likehood, loglikelihood.
-
gns.toy_models.getToyHypers(n, p, l)[source]¶ Takes three string arguments which are used in dictionary to look up types of priors/ lhoods (denoted by integers) as well as their hyperparameters (arrays). The priors/likelihoods that each dictionary entry corresponds to is written above the respective dictionary value definition.
Args:
n: string for dictionary key of parameter names dictionary e.g. ‘n1’
p: string for dictionary key of priors dictionary e.g. ‘p1’
l: string for dictionary key of likelihoods dictionary e.g. ‘l1’
Returns:
values of respective dictionaries, which contain lists of parameter names, prior and likelihood types, and their hyperparameters in the form:
paramNames: list of strings representing parameter names
priorParams: array containing prior type (denoted by integer) and hyperparameters (array). priorParams has shape (3, nDims), where the first element of each row corresponds to the prior type, while the remaining two elements are hyperparameter values (e.g. mean and standard deviation).
LhoodParams: list containing likelihood type (denoted by integer) and hyperparameters (array). First element of the list is the likelihood type which is an integer, the second element is a (1, nDims) array specifying the mean of each dimension of the likelihood. The third element is an (nDims, nDims) specifying the covariance (scale) of the likelihood.
NOTE: Likelihoods involving the Kent distribution are parameterised differently (see https://en.wikipedia.org/wiki/Kent_distribution), and so the second element of LhoodParams should be a list of three arrays of shape (3,) while the third element of LhoodParams should be an array of shape (2,).
For examples please see the body of the function.
Priors which prior types integers correspond to can be found in fitPriors() in prob_funcs.py.
Likelihoods which likelihood types integers correspond to can be found in fitLhood() in prob_funcs.py.
-
gns.toy_models.getToyHypersGen(dists)[source]¶ wrapper around getToyHypers() to get priors/ lhoods specific to geometric nested sampling project
See getToyHypers for priors/likelihood that these different models correspond to.
Args:
shape: string representing toy model name e.g. ‘gauss p gauss l’
Returns:
values of respective dictionaries, which contain lists of parameter names, prior and likelihood types, and their hyperparameters in the form:
paramNames: list of strings representing parameter names
priorParams: array containing prior type (denoted by integer) and hyperparameters (array), see getToyHypers() docstring.
LhoodParams: list containing likelihood type (denoted by integer) and hyperparameters (array), see getToyHypers() docstring.
Priors which prior types integers correspond to can be found in fitPriors() in prob_funcs.py.
Likelihoods which likelihood types integers correspond to can be found in fitLhood() in prob_funcs.py.
-
gns.toy_models.getToyHypersGeom(shape)[source]¶ wrapper around getToyHypers() to get priors/ lhoods specific to geometric nested sampling project. NOTE ‘sphere’ changed to l8 on 18th Feb 2018. See getToyHypers for priors/likelihood that these different shapes (models) correspond to.
Args:
shape: string representing toy model name e.g. ‘torus III’
Returns:
values of respective dictionaries, which contain lists of parameter names, prior and likelihood types, and their hyperparameters in the form:
paramNames: list of strings representing parameter names
priorParams: array containing prior type (denoted by integer) and hyperparameters (array), see getToyHypers() docstring.
LhoodParams: list containing likelihood type (denoted by integer) and hyperparameters (array), see getToyHypers() docstring.
Priors which prior types integers correspond to can be found in fitPriors() in prob_funcs.py.
Likelihoods which likelihood types integers correspond to can be found in fitLhood() in prob_funcs.py.
-
gns.toy_models.getToyObjects(priorParams, LhoodParams)[source]¶ fit priors and Lhoods of toy model.
Args:
priorParams: array containing prior type (denoted by integer) and hyperparameters (array), see getToyHypers() docstring.
LhoodParams: list containing likelihood type (denoted by integer) and hyperparameters (array), see getToyHypers() docstring.
Returns:
Prior and likelihood objects to be passed to getToyProbFuncs()
-
gns.toy_models.getToyProbFuncs(priorObjs, LhoodObj)[source]¶ Obtain pdf and ppf methods of priors and pdf & logpdf methods of likelihood.
Args:
priorObjs: array containing prior objects obtained from getToyObjects()
LhoodObj: likelihood object obtained from getToyObjects()
Returns:
Prior and likelihood probability functions in order: prior, log prior, prior quantile, likehood, loglikelihood.