The GP object

The core element of George is the GP object. All of the available methods and properties are documented here:

class george.GP(kernel=None, fit_kernel=True, mean=None, fit_mean=None, white_noise=None, fit_white_noise=None, solver=None, **kwargs)

The basic Gaussian Process object.

Parameters:
  • kernel – An instance of a subclass of kernels.Kernel.
  • fit_kernel – (optional) If True, the parameters of the kernel will be included in all the relevant methods (get_parameter_vector(), grad_log_likelihood(), etc.). (default: True)
  • mean – (optional) A description of the mean function. See mean for more information. (default: 0.0)
  • fit_mean – (optional) If True, the parameters of the mean function will be included in all the relevant methods (get_parameter_vector(), grad_log_likelihood(), etc.). (default: False)
  • white_noise – (optional) A description of the logarithm of the white noise variance added to the diagonal of the covariance matrix. See white_noise for more information. (default: log(TINY))
  • fit_white_noise – (optional) If True, the parameters of white_noise will be included in all the relevant methods (get_parameter_vector(), grad_log_likelihood(), etc.). (default: False)
  • solver – (optional) The solver to use for linear algebra as documented in Solvers.
  • kwargs – (optional) Any additional arguments are passed directly to the solver’s init function.
apply_inverse(y)

Self-consistently apply the inverse of the computed kernel matrix to some vector or matrix of samples. This method subtracts the mean, sorts the samples, then returns the samples in the correct (unsorted) order.

Parameters:y(nsamples, ) or (nsamples, K) The vector (or matrix) of sample values.
compute(x, yerr=0.0, **kwargs)

Pre-compute the covariance matrix and factorize it for a set of times and uncertainties.

Parameters:
  • x(nsamples,) or (nsamples, ndim) The independent coordinates of the data points.
  • yerr – (optional) (nsamples,) or scalar The Gaussian uncertainties on the data points at coordinates x. These values will be added in quadrature to the diagonal of the covariance matrix.
compute_gradient(*args, **kwargs)

Compute the “gradient” of the model for the current parameters

The default implementation computes the gradients numerically using a first order forward scheme. For better performance, this method should be overloaded by subclasses. The output of this function should be an array where the first dimension is full_size.

computed

Has the processes been computed since the last update of the kernel?

get_gradient(*args, **kwargs)

A synonym for GP.grad_log_likelihood() provided for consistency with the modeling protocol.

get_matrix(x1, x2=None)

Get the covariance matrix at a given set or two of independent coordinates.

Parameters:
  • x1(nsamples,) or (nsamples, ndim) A list of samples.
  • x2(nsamples,) or (nsamples, ndim) (optional) A second list of samples. If this is given, the cross covariance matrix is computed. Otherwise, the auto-covariance is evaluated.
get_parameter_bounds(include_frozen=False)

Get a list of the parameter bounds

Parameters:include_frozen (Optional[bool]) – Should the frozen parameters be included in the returned value? (default: False)
get_parameter_dict(include_frozen=False)

Get an ordered dictionary of the parameters

Parameters:include_frozen (Optional[bool]) – Should the frozen parameters be included in the returned value? (default: False)
get_parameter_names(include_frozen=False)

Get a list of the parameter names

Parameters:include_frozen (Optional[bool]) – Should the frozen parameters be included in the returned value? (default: False)
get_parameter_vector(include_frozen=False)

Get an array of the parameter values in the correct order

Parameters:include_frozen (Optional[bool]) – Should the frozen parameters be included in the returned value? (default: False)
get_value(*args, **kwargs)

A synonym for GP.log_likelihood() provided for consistency with the modeling protocol.

grad_log_likelihood(y, quiet=False)

Compute the gradient of GP.log_likelihood() as a function of the parameters returned by GP.get_parameter_vector(). You must call GP.compute() before this function.

Parameters:
  • y(nsamples,) The list of observations at coordinates x provided to the compute() function.
  • quiet – If True return a gradient of zero instead of raising an exception when there is an invalid kernel or linear algebra failure. (default: False)
log_likelihood(y, quiet=False)

Compute the logarithm of the marginalized likelihood of a set of observations under the Gaussian process model. You must call GP.compute() before this function.

Parameters:
  • y(nsamples, ) The observations at the coordinates provided in the compute step.
  • quiet – If True return negative infinity instead of raising an exception when there is an invalid kernel or linear algebra failure. (default: False)
mean

An object (following the modeling protocol) that specifies the mean function of the GP. You can safely set this to a scalar, a callable, or an instance of a class satisfying the modeling protocol. In each case, the mean will be evaluated (either by calling the function or evaluating the get_value() method) at the input coordinates and it should return the one-dimensional mean evaluated at these coordinates.

parse_samples(t)

Parse a list of samples to make sure that it has the correct dimensions.

Parameters:t(nsamples,) or (nsamples, ndim) The list of samples. If 1-D, this is assumed to be a list of one-dimensional samples otherwise, the size of the second dimension is assumed to be the dimension of the input space.
Raises:ValueError – If the input dimension doesn’t match the dimension of the kernel.
predict(y, t, return_cov=True, return_var=False, cache=True, kernel=None)

Compute the conditional predictive distribution of the model. You must call GP.compute() before this function.

Parameters:
  • y(nsamples,) The observations to condition the model on.
  • t(ntest,) or (ntest, ndim) The coordinates where the predictive distribution should be computed.
  • return_cov – (optional) If True, the full covariance matrix is computed and returned. Otherwise, only the mean prediction is computed. (default: True)
  • return_var – (optional) 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)
  • cache – (optional) If True the value of alpha will be cached to speed up repeated predictions.
  • kernel – (optional) If provided, this kernel will be used to calculate the cross terms. This can be used to separate the predictions from different kernels.

Returns mu, (mu, cov), or (mu, var) depending on the values of return_cov and return_var. These output values are:

  • mu (ntest,): mean of the predictive distribution,
  • cov (ntest, ntest): the predictive covariance matrix, and
  • var (ntest,): the diagonal elements of cov.
recompute(quiet=False, **kwargs)

Re-compute a previously computed model. You might want to do this if the kernel parameters change and the kernel is labeled as dirty.

Parameters:quiet – (optional) If True, return false when the computation fails. Otherwise, throw an error if something goes wrong. (default: False)
sample(t=None, size=1)

Draw samples from the prior distribution.

Parameters:
  • t(ntest, ) or (ntest, ndim) (optional) The coordinates where the model should be sampled. If no coordinates are given, the precomputed coordinates and factorization are used.
  • size – (optional) The number of samples to draw. (default: 1)

Returns samples (size, ntest), a list of predictions at coordinates given by t. If size == 1, the result is a single sample with shape (ntest,).

sample_conditional(y, t, size=1)

Draw samples from the predictive conditional distribution. You must call GP.compute() before this function.

Parameters:
  • y(nsamples, ) The observations to condition the model on.
  • t(ntest, ) or (ntest, ndim) The coordinates where the predictive distribution should be computed.
  • size – (optional) The number of samples to draw. (default: 1)

Returns samples (size, ntest), a list of predictions at coordinates given by t.

set_parameter_vector(vector, include_frozen=False)

Set the parameter values to the given vector

Parameters:
  • vector (array[vector_size] or array[full_size]) – The target parameter vector. This must be in the same order as parameter_names and it should only include frozen parameters if include_frozen is True.
  • include_frozen (Optional[bool]) – Should the frozen parameters be included in the returned value? (default: False)
white_noise

An object (following the modeling protocol) that specifies the natural logarithm of the white noise variance added to the diagonal of the covariance matrix. You can safely set this to a scalar, a callable, or an instance of a class satisfying the modeling protocol. In each case, it will be evaluated (either by calling the function or evaluating the get_value() method) at the input coordinates and it should return the one-dimensional log-variance evaluated at these coordinates.

This functionality is preferred to the WhiteKernel class provided by earlier versions of this module.