Parameter Functions

Creator for parameters and priors for the gaussian model

class src.magpy_rv.parameters.Gaussian(hparam, mu, sigma)[source]

Gaussian prior computed as:

\[-0.5 \cdot (\frac{(x - \mu)}{\sigma})^2 - 0.5 \cdot log(2\pi \cdot \sigma^2)\]
Parameters
  • hparam (string) – parameter label

  • mu (float) – centre of Gaussian Prior

  • sigma (float) – width of the Gaussian Prior

logprob(x)[source]
Parameters

x (array, floats) – Assumed value of the parameter (number space over which to sample)

Returns

logprob – Natural logarithm of the probabiliy of x being the best fit

Return type

float

class src.magpy_rv.parameters.Jeffrey(hparam, minval, maxval)[source]

Jeffrey prior computed as:

p(x) proportional to \(\frac{1}{x}\) with upper and lower bound to avoid singularity at x = 0

and normalized as:

\(\frac{1}{ln(\frac{maxval}{minval})}\)

Parameters
  • hparam (string) – parameter label

  • minval (float) – minimum allowed value

  • maxval (float) – maximum allowed value

logprob(x)[source]
Parameters

x (array, floats) – Assumed value of the parameter (number space over which to sample)

Returns

logprob – Natural logarithm of the probabiliy of x being the best fit

Return type

float

class src.magpy_rv.parameters.Modified_Jeffrey(hparam, minval, maxval, kneeval)[source]

Modified Jeffrey prior computed as:

p(x) proportional to \(\frac{1}{x-x_0}\) with upper bound

Parameters
  • hparam (string) – parameter label

  • kneeval (float) – x0, knee of the Jeffrey prior

  • minval (float) – minimum allowed value

  • maxval (float) – maximum allowed value

logprob(x)[source]
Parameters

x (float) – Assumed value of the parameter (number space over which to sample)

Returns

logprob – Natural logarithm of the probabiliy of x being the best fit

Return type

float

src.magpy_rv.parameters.PRINTPRIORDER(pri_name=None)[source]

Function to print the information and orders for the prior values

Parameters

pri_name (string, optional) – name of the desired prior to check Defaults to None

src.magpy_rv.parameters.PrintPriorList()[source]

Function to print the list of all currently available PRIORS

class src.magpy_rv.parameters.Prior[source]

Parent class for all priors. All new priors should inherit from this class and follow its structure. Each new prior will require a __init__() method to override the parent class. In the __init__ function, call the neccesary parameters.

abstract logprob(x)[source]

computes the natural logarithm of the probability of x being the best fit

class src.magpy_rv.parameters.Uniform(hparam, minval, maxval)[source]

Uniform prior

Parameters
  • hparam (string) – parameter label

  • minval (float) – minimum allowed value

  • maxval (float) – maximum allowed value

logprob(x)[source]
Parameters

x (array) – Assumed value of the parameter (number space over which to sample)

Returns

logprob – Natural logarithm of the probabiliy of x being the best fit

Return type

float

src.magpy_rv.parameters.defPriorList()[source]

Function to return the list of all currently available PRIORS

src.magpy_rv.parameters.par_create(kernel)[source]

Funciton to create the hyperparameters of the kernel to be used in the gp model

Parameters

kernel (string) – name of the desired kernel

Returns

hparams – dictionary of necessary hyperparameters for the relevant kernel

Return type

dict

class src.magpy_rv.parameters.parameter(value=None, error=None, vary=True)[source]

Object to assign initial values to a parameter and define whether it is allowed to vary in the fitting

Parameters
  • value (float, optional) – Assumed initial value of the chosen variable. The default is None.

  • error (float, optional) – Error on the value. The default is None

  • vary (True or False, optional) – Is the variable allowed to vary? The default is True.

src.magpy_rv.parameters.pri_create(param_name, prior, vals=None)[source]

Funciton to generate a set of parameters necessary for the chosen prior

Parameters
  • param_name (string) – name of parameter that the prior is being assigned to - should be the same as it appears in the kernel or model

  • prior (string) – name of the desired prior

  • vals (list or tuple of floats or ints, optional) – list of floats containing the prior parameters in order specified by the PRINTPRIORDER function. To view which values belong in the list and the format, run the PRINTPRIORDER function.

Raises
  • Assertion: – Raised if vals is not None and not a list or a tuple

  • Assertion: – Raised if vals is not None and not made of floats or ints

  • Assertion: – Raised if length of the vals list does not match the required length for the prior

  • Assertion: – Raised if the minval is larger than the maxval for the prior

Returns

prior_params – dictionary of all prior parameters

Return type

dictionary