Priors

Objects for handling priors.

class priors.Priors

Class for holding prior functions for a specific variable and applying them.

Initializes a Priors object with a list to hold functions and default lower and upper bounds on the variable of negative and positive infinity, respectively.

add_gaussian_prior(mean, std)

Adds a Gaussian prior function to the list of priors with the given parameters. The prior function returns the log of the prior value for a given trial value to be added to the log likelihood during fitting.

Parameters:
  • mean (float) – The mean of the Gaussian distribution.

  • std (float) – The standard deviation of the Gaussian distribution.

add_uniform_prior(lower, upper)

Adds a uniform prior function to the list of priors with the given bounds. The prior function returns negative infinity if the given trial value is out of the bounds, otherwise 0. Updates the lower and upper bounds of the Priors object.

add_jeffreys_prior(lower, upper)

Adds a Jeffrey’s prior function to the list of priors with the given bounds. Variable must be positive definite. The prior function returns negative infinity if the given trial value is out of the bounds, otherwise the normalized Jeffrey’s prior. Does not work if the lower bound is 0!!! In that case, use a modified Jeffrey’s prior. Updates the lower and upper bounds of the Priors object.

add_modified_jeffreys_prior(upper, knee)

Adds a modified Jeffrey’s prior function to the list of priors with the given bounds. Variable must be positive definite. Implicit lower bound of 0. The prior function returns negative infinity if the given trial value is out of the bounds, otherwise the normalized modified Jeffrey’s prior. The modified Jeffrey’s prior becomes log uniform below the knee value. Updates the lower and upper bounds of the Priors object.

apply_priors(x)

Applies all priors in the list of functions to the given trial value, and returns the log likelihood value to be added during fitting.

Parameters:

x (float) – The value to apply the priors to.

Returns:

The log likelihood value from the priors.

Return type:

float

bounds()

Retrieves the boundaries on this parameter set by any priors.

Returns:

The lower and upper boundaries of this variable given the set of priors stored.

Return type:

tuple[float, float]

class priors.AllPriors(tab, x0, fit_ttv)

A class for parsing the Init_priors tables into actual priors, and applying them to all parameters. Stores a dict of Priors objects for each parameter and a dict of all fixed parameters.

Initializes an AllPriors object from an Init_priors table and a list of fit parameters. Parses the table into actual priors for any relevant parameters. Sets up a dict of fixed parameters and their values.

Parameters:
  • tab (Table) – The table from an Init_priors object with a list of priors to set up.

  • x0 (dict) – A dict with initial values for all fit parameters from an ExoSystem fit, used to determine which variables are being fit for and require priors to be set up.

  • fit_ttv (ndarray[tuple[Any, ...], dtype[TypeVar(_ScalarT, bound= generic)]]) – An array of bools for each planet. They represent whether or not each planet is being fit for TTVs. Priors can be placed

  • parameters. (on P and Tc for a planet even if they are fit for TTVs and don't directly have those in the fit)

set_up_prior(var, prior_type, params)

Sets up a Priors object for a parameter in the dict of Priors, if one doesn’t exist already. Then adds the given prior to that object with the given parameters.

Parameters:
  • var (str) – The parameter the prior is for.

  • prior_type (str) – The type of prior to set up.

  • params (list) – A list of the parameters required to set up the prior (e.g. mean and std for a Gaussian prior).

apply(par)

Applies all priors to all fit parameters and returns the total log likelihood.

Parameters:

par (dict) – A dict of the fit parameters from the ExoSystem fit.

Returns:

The total log likelihood from the priors.

Return type:

float

get_bounds(var)

Gets the bounds on a fit parameter, if there are any from uniform priors. Used for setting up truncated Gaussians when initializing the MCMC chains to ensure they do not leave any bounds. Combines bounds from any variations on the actual fitted parameter, for instance P to log(P) or e to secw.

Parameters:

var (str) – The parameter to get the bounds for.

Returns:

The lower and upper bounds on this fit parameter.

Return type:

tuple[float, float]

priors.setup_star_priors(tab, starmod)

Sets up any priors on the stellar parameters that are directly fit for using the internal priors functionality from isochrones. Will replace the default priors on those parameters. Only one prior can be applied to each parameter, with the exception of Gaussian plus uniform, which is interpreted as a truncated Gaussian.

Parameters:
  • tab (Table) – The table from an Init_priors object.

  • starmod (SingleStarModel) – The isochrones starmodel object being used in the ExoSystem fit.

Returns:

Returns the updated starmodel object that was input.

Return type:

SingleStarModel