Gaussian Process Computations

The main interface to the celerite solver is through the GP class. This main purpose of this class is to exposes methods for efficiently computing the marginalized likelihood of a Gaussian Process (GP) model. The covariance matrix for the GP will be specified by a kernel function as described in the Kernel Building section.

The GP class implements the Python: Modeling with submodels called kernel, mean, and log_white_noise so the modeling language can be used to fit for parameters for each of these models.

Below, the methods of the GP object are described in detail but the most important methods to look at are probably GP.compute(), GP.log_likelihood(), and GP.predict().

class celerite.GP(kernel, mean=0.0, fit_mean=False, log_white_noise=-inf, fit_white_noise=False, method=None)

The main interface to the celerite Gaussian Process solver

Parameters:
  • kernel – An instance of a subclass of terms.Term.
  • mean (Optional) – A simple mean value for the process. This can either be a float or a subclass of modeling.Model. (default: 0.0)
  • fit_mean (optional) – If False, all of the parameters of mean will be frozen. Otherwise, the parameter states are unaffected. (default: False)
  • log_white_noise (Optional) – A white noise model for the process. The exp of this will be added to the diagonal of the matrix in GP.compute(). In other words this model should be for the log of the _variance_ of the white noise. This can either be a float or a subclass of modeling.Model. (default: -inf)
  • fit_white_noise (Optional) – If False, all of the parameters of log_white_noise will be frozen. Otherwise, the parameter states are unaffected. (default: False)
  • method – Select a matrix solver method by name. This can be one of (a) simple: a simple banded Gaussian elimination based method, (b) lapack: an optimized band solver if compiled with LAPACK, (c) sparse: a sparse solver if compiled with Eigen/Sparse, or (d) default: uses heuristics to select the fastest method that is available.
apply_inverse(y)

Apply the inverse of the covariance matrix to a vector or matrix

Solve K.x = y for x where K is the covariance matrix of the GP with the white noise and yerr components included on the diagonal.

Parameters:
  • y (array[n] or array[n, nrhs]) – The vector or matrix y
  • above. (described) –
Returns:

The solution to the linear system. This will have the same shape as y.

Return type:

array[n] or array[n, nrhs]

Raises:

ValueError – For mismatched dimensions.

compute(t, yerr=1.123e-12, check_sorted=True)

Compute the extended form of the covariance matrix and factorize

Parameters:
  • x (array[n]) – The independent coordinates of the data points. This array must be _sorted_ in ascending order.
  • yerr (Optional[float or array[n]]) – The measurement uncertainties for the data points at coordinates x. These values will be added in quadrature to the diagonal of the covariance matrix. (default: 1.123e-12)
  • check_sorted (bool) – If True, x will be checked to make sure that it is properly sorted. If False, the coordinates will be assumed to be in the correct order.
Raises:

ValueError – For un-sorted data or mismatched dimensions.

dot(y, kernel=None)

Dot the covariance matrix into a vector or matrix

Compute K.y where K is the covariance matrix of the GP without the white noise or yerr values on the diagonal.

Parameters:
  • y (array[n] or array[n, nrhs]) – The vector or matrix y described above.
  • kernel (Optional[terms.Term]) – A different kernel can optionally be provided to compute the matrix K from a different kernel than the kernel property on this object.
Returns:

The dot product K.y as described above. This will have the same shape as y.

Return type:

array[n] or array[n, nrhs]

Raises:

ValueError – For mismatched dimensions.

get_matrix(x1=None, x2=None, include_diagonal=None)

Get the covariance matrix at given independent coordinates

Parameters:
  • x1 (Optional[array[n1]]) – The first set of independent coordinates. If this is omitted, x1 will be assumed to be equal to x from a previous call to GP.compute().
  • x2 (Optional[array[n2]]) – The second set of independent coordinates. If this is omitted, x2 will be assumed to be x1.
  • include_diagonal (Optional[bool]) – Should the white noise and yerr terms be included on the diagonal? (default: False)
log_likelihood(y, _const=1.8378770664093453)

Compute the marginalized likelihood of the GP model

The factorized matrix from the previous call to GP.compute() is used so compute must be called first.

Parameters:y (array[n]) – The observations at coordinates x from GP.compute().
Returns:The marginalized likelihood of the GP model.
Return type:float
Raises:ValueError – For mismatched dimensions.
log_white_noise

The white noise modeling.Model

mean

The mean modeling.Model

predict(y, t=None, return_cov=True, return_var=False)

Compute the conditional predictive distribution of the model

You must call GP.compute() before this method.

Parameters:y (array[n]) – The observations at coordinates x from GP.compute().
t (Optional[array[ntest]]): The independent coordinates where the
prediction should be made. If this is omitted the coordinates will be assumed to be x from GP.compute() and an efficient method will be used to compute the prediction.
return_cov (Optional[bool]): If True, the full covariance matrix
is computed and returned. Otherwise, only the mean prediction is computed. (default: True)
return_var (Optional[bool]): If True, only return the diagonal of
the predictive covariance; this will be faster to compute than the full covariance matrix. This overrides return_cov so, if both are set to True, only the diagonal is computed. (default: False)
Returns:mu, (mu, cov), or (mu, var) depending on the values of return_cov and return_var. These output values are: (a) mu (ntest,): mean of the predictive distribution, (b) cov (ntest, ntest): the predictive covariance matrix, and (c) var (ntest,): the diagonal elements of cov.
Raises:ValueError – For mismatched dimensions.
sample(x=None, diag=None, include_diagonal=False, size=None)

Sample from the prior distribution over datasets

Parameters:
  • x (Optional[array[n]]) – The independent coordinates where the observations should be made. If None, the coordinates used in the last call to compute will be used.
  • diag (Optional[array[n] or float]) – If provided, this will be added to the diagonal of the covariance matrix.
  • include_diagonal (Optional[bool]) – Should the white noise and/or yerr terms be included on the diagonal? (default: False)
  • size (Optional[int]) – The number of samples to draw.
Returns:

The samples from the prior distribution over datasets.

Return type:

array[n] or array[size, n]