GaussianProcess#
- class gadfly.GaussianProcess(kernel, t=None, mean=0.0, light_curve=None, **kwargs)[source]#
Bases:
GaussianProcessThe
gadflyinterface to the celerite2 Gaussian Process (GP) solver.This subclass of the
GaussianProcessclass incelerite2knows how to handleunits, for ease of use ingadfly.- Parameters:
kernel (Subclass of
Term) –celerite2-compatible kernel. Could be aSolarOscillatorKernelorStellarOscillatorKernel, for example.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
xvalues) 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 argumenttis specified.
Attributes Summary
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 = yforxwhereKis the covariance matrix of the GP.Note
The mean function is not applied in this method.
- 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 thattis correctly sorted. AValueErrorwill be thrown when this check fails.quiet (bool) – If
True, when the matrix cannot be factorized (because of numerics or otherwise) the solver’sLinAlgErrorwill 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.
- dot_tril(y, *, inplace=False)[source]#
Dot the Cholesky factor of the GP system into a vector or matrix
Compute
x = L.ywhereK = L.L^TandKis the covariance matrix of the GP.Note
The mean function is not applied in this method.
- 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.
- 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
tas defined bygadfly.GaussianProcess.compute().(shape[M]) (t) – The independent coordinates where the prediction should be evaluated. If not provided, this will be evaluated at the observations
tfromcompute().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
Quantityin 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’sLinAlgErrorwill be silenced and the determiniant will be set to zero. Otherwise, the exception will be propagated.- Raises:
RuntimeError – If
GaussianProcess.compute()is not called first.ValueError – When the inputs are not valid (shape, number, etc.).