GP Likelihood Functions
GP likelihood calculation for the gaussian model
- class src.magpy_rv.gp_likelihood.GPLikelihood(x, y, yerr, hparameters, kernel_name, model_y=None, model_param=None)[source]
Gaussian Process likelihood
- Parameters
x (array or list, floats) – Time series of the radial velocity
y (array or list, floats) – Radial velocity values
yerr (array or list, floats) – Radial velocity errors
hparamters (dictionary) – dictionary of all hyper parameters considered
kernel_name (string) – name of the used kernel
model_y (array, floats, optional) – Array of y (rv) values from the model chosen Default to None
model_param (dictionary, optional) – dictionary of all model parameters considered Default to None
- Raises
Assertion: – Raised if the hyperparameters are not a dictionary
Assertion: – Raised if the a model is in use and the model parameters are not a dictionary
KeyError: – Raised if a model is in use and model_y is not given
KeyError: – Raised if a model_y is given but no parameters are specified
KeyError: – Raised if a model_y is given but no model is in use
- LogL(prior_list)[source]
Function to compute the log likelihood after applying the priors
- Parameters
prior_list (list of sets of 3 objects) –
List of the priors applied. Each item in the list should countain the following 3 objects:
String of the name of the parameter the prior is applied to
String of the name of the prior
pri_create dictionary of the prior
- Raises
Assertion: – Raised if the prior_list is not a list
Assertion: – Raised if the name of the parameter is not a string
Assertion: – Raised if the name of the prior is not a string
Assertion: – Raised if the prior parameters are not a dictionary
- Returns
LogL – Final ln of likelihood after applying all posteriors from priors
- Return type
float
- compute_kernel(x1, x2)[source]
- Parameters
x1 (array or list, floats) – array to be used in calculation of covariance matrix
x2 (array or list, floats) – other array to be used in the calculations of covariance matrix
- Returns
covmatrix – Covariance matrix of the chosen set of varaibles x1 and x2
- Return type
array, floats
- logprob()[source]
Computes the natural logarith of the likelihood of the gaussian fit. Following the equation:
\[ln(L) = -\frac{n}{2} ln(2\pi) \cdot -\frac{1}{2} ln(det(K)) -\frac{1}{2} Y^T \cdot (K-1) \cdot Y\]- Returns
logL – Ln of the likelihood
- Return type
float
- predict(xpred, FullCov=False)[source]
- Parameters
xpred (array, floats) – X array over which to do the prediction
FullCov (True/False, optional) – Want to return the full covariance? The default is False.
- Returns
pred_mean (array, floats) – Predicted values of the y axis
stdev (array, floats) – Standard deviation of the y points, to be used as error
OR
np.array(pred_cov) (array, floats) – Full covariance of the data set
- priors(param_name, prior_name, prior_parameters)[source]
Fuction to compute the natural logarithm of the prior likelihood
- Parameters
hparam_name (string) – Name of the hyperparameter on which to impose the prior
prior_name (string) – Name of the prior to apply
prior_parameters (dictionary) – Dictionary containing all necessary prior parameters (get with pri_create and assign values)
- Raises
Assertion: – Raised if the selected prior is not in the list of currently available priors
- Returns
prior_logprob – Natural logarithm of the prior likelihood
- Return type
float