GaussianProcess#

class gadfly.GaussianProcess(kernel, t=None, mean=0.0, light_curve=None, **kwargs)[source]#

Bases: celerite2.numpy.GaussianProcess

The gadfly interface to the celerite2 Gaussian Process (GP) solver.

This subclass of the GaussianProcess class in celerite2 knows how to handle units, for ease of use in gadfly.

Parameters
  • kernel (Subclass of Term) – celerite2-compatible kernel. Could be a SolarOscillatorKernel or StellarOscillatorKernel, for example.

  • t (Quantity or Time) –

  • mean (float or callable) – The mean function of the process. This can either be a callable (it will be evaluated with a single argument, a vector of x values) or a scalar. (default: 0.0)

  • light_curve (LightCurve) – The light curve on which predictions will be computed

  • kwargs (dict) – Other arguments will be passed directly to compute() if the argument t is specified.

Attributes Summary

mean

mean_value

Methods Summary

apply_inverse(y, *[, inplace])

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

compute(t[, yerr, diag, check_sorted, quiet])

Compute the Cholesky factorization of the GP covariance matrix.

condition(y[, t, include_mean, kernel, ...])

Condition the Gaussian process given observations y.

dot_tril(y, *[, inplace])

Dot the Cholesky factor of the GP system into a vector or matrix

log_likelihood(y, *[, inplace])

Compute the marginalized likelihood of the GP model

predict(y[, t, return_cov, return_var, ...])

Compute the conditional distribution

recompute(*[, quiet])

Re-compute the factorization given a previous call to compute

sample(*[, size, include_mean, return_quantity])

Generate random samples from the prior implied by the GP system

Attributes Documentation

mean#
mean_value#

Methods Documentation

apply_inverse(y, *, inplace=False)[source]#

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.

Note

The mean function is not applied in this method.

Parameters
  • y (Quantity) – The vector or matrix y described above.

  • inplace (bool) – If True, y will be overwritten with the result x.

compute(t, yerr=None, diag=None, check_sorted=True, quiet=False)[source]#

Compute the Cholesky factorization of the GP covariance matrix.

Parameters
  • t (Quantity or Time) – The independent coordinates of the observations. This must be sorted in increasing order.

  • yerr (Quantity) – If provided, the diagonal standard deviation of the observation model.

  • diag (Quantity) – If provided, the diagonal variance of the observation model.

  • check_sorted (bool) – If True, a check is performed to make sure that t is correctly sorted. A ValueError will be thrown when this check fails.

  • quiet (bool) – If True, when the matrix cannot be factorized (because of numerics or otherwise) the solver’s LinAlgError will be silenced and the determiniant will be set to zero. Otherwise, the exception will be propagated.

condition(y, t=None, include_mean=True, kernel=None, return_quantity=False)[source]#

Condition the Gaussian process given observations y.

Parameters
  • y (Quantity) – Observations

  • t (Quantity or Time) – Times

  • include_mean (bool) – Include the mean model in the prediction

  • kernel (subclass of Term) – Evaluate conditional distribution given this kernel

  • return_quantity (bool) – Return the fluxes as a Quantity in the same units as the input light curve.

dot_tril(y, *, inplace=False)[source]#

Dot the Cholesky factor of the GP system into a vector or matrix

Compute x = L.y where K = L.L^T and K is the covariance matrix of the GP.

Note

The mean function is not applied in this method.

Parameters
  • y (Quantity) – The vector or matrix y described above.

  • inplace (bool) – If True, y will be overwritten with the result x.

log_likelihood(y, *, inplace=False)[source]#

Compute the marginalized likelihood of the GP model

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

Parameters
  • (shape[N]) (y) – The observations at coordinates t as defined by compute().

  • inplace (bool) – If True, y will be overwritten in the process of the calculation. This will reduce the memory footprint, but should be used with care since this will overwrite the data.

predict(y, t=None, return_cov=False, return_var=False, include_mean=True, kernel=None, return_quantity=False)[source]#

Compute the conditional distribution

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

Parameters
  • (shape[N]) (y) – The observations at coordinates t as defined by gadfly.GaussianProcess.compute().

  • (shape[M]) (t) – The independent coordinates where the prediction should be evaluated. If not provided, this will be evaluated at the observations t from compute().

  • return_var (bool) – Return the variance of the conditional distribution.

  • return_cov (bool) – Return the full covariance matrix of the conditional distribution.

  • include_mean (bool) – Include the mean function in the prediction.

  • kernel (subclass of Term) – If provided, compute the conditional distribution using a different kernel. This is generally used to separate the contributions from different model components. Note that the computational cost and scaling will be worse when using this parameter.

  • return_quantity (bool) – Return the fluxes as a Quantity in the same units as the input light curve.

recompute(*, quiet=False)#

Re-compute the factorization given a previous call to compute

Parameters

quiet (bool, optional) – If True, when the matrix cannot be factorized (because of numerics or otherwise) the solver’s LinAlgError will be silenced and the determiniant will be set to zero. Otherwise, the exception will be propagated.

Raises
sample(*, size=None, include_mean=True, return_quantity=False)[source]#

Generate random samples from the prior implied by the GP system

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

Parameters
  • size (int) – The number of samples to generate. If not provided, only one sample will be produced.

  • include_mean (bool) – Include the mean function in the prediction.

  • return_quantity (bool) – Return the fluxes as a Quantity in the same units as the input light curve.