Solvers¶
There are currently two different GP solvers included with George using
different libraries for doing linear algebra.
Both of the solvers implement the same API and should (up to some tolerance)
give the same answers on the same datasets.
A solver is just a class that takes a Kernel
and that exposes 3
methods:
compute
— to compute and factorize the kernel matrix,apply_inverse
— to leftmultiply the input by the covariance matrix \(C^{1}\,b\) (actually implemented by solving the system \(C\,x = b\)), andapply_sqrt
— to apply the (Cholesky) square root of the covariance.
The solvers also provide the properties computed
and log_determinant
.
The simplest solver provided by George (BasicSolver
) uses scipy’s
Cholesky implementation
and the second implementation (HODLRSolver
) uses Sivaram
Amambikasaran’s HODLR algorithm to do the
linear algebra in \(\mathcal{O}(N\,\log^2 N)\) instead of
\(\mathcal{O}(N^3)\).
By default, George uses the BasicSolver
but the HODLRSolver
can be used as follows:
import george
kernel = ...
gp = george.GP(kernel, solver=george.HODLRSolver)
The HODLRSolver
is probably best for most onedimensional problems
and some large multidimensional problems but it doesn’t (in general) scale
well with the number of input dimensions.
In practice, it’s worth trying both solvers on your specific problem to see
which runs faster.
Basic Solver¶

class
george.
BasicSolver
(kernel)¶ This is the most basic solver built using
scipy.linalg.cholesky()
. kernel (george.kernels.Kernel): A subclass of
Kernel
specifying  the kernel function.

apply_inverse
(y, in_place=False)¶ Apply the inverse of the covariance matrix to the input by solving
\[K\,x = y\]Parameters:  y (ndarray[nsamples] or ndadrray[nsamples, nrhs]) – The vector or matrix \(y\).
 in_place (Optional[bool]) – Should the data in
y
be overwritten with the result \(x\)? (default:False
)

apply_sqrt
(r)¶ Apply the Cholesky square root of the covariance matrix to the input vector or matrix.
Parameters: (ndarray[nsamples] or ndarray[nsamples, nrhs] (r) – The input vector or matrix.

compute
(x, yerr)¶ Compute and factorize the covariance matrix.
Parameters:  x (ndarray[nsamples, ndim]) – The independent coordinates of the data points.
 yerr (ndarray[nsamples] or float) – The Gaussian uncertainties on
the data points at coordinates
x
. These values will be added in quadrature to the diagonal of the covariance matrix.

computed
¶ A flag indicating whether or not the covariance matrix was computed and factorized (using the
compute()
method).

dot_solve
(y)¶ Compute the inner product of a vector with the inverse of the covariance matrix applied to itself:
\[y\,K^{1}\,y\]Parameters: y (ndarray[nsamples]) – The vector \(y\).

get_inverse
()¶ Get the dense inverse covariance matrix. This is used for computing gradients, but it is not recommended in general.
 kernel (george.kernels.Kernel): A subclass of
HODLR Solver¶

class
george.
HODLRSolver
(kernel, min_size=100, tol=0.1, seed=42)¶ 
apply_inverse
(y, in_place=False)¶ Apply the inverse of the covariance matrix to the input by solving
\[K\,x = y\]Parameters:  y (ndarray[nsamples] or ndadrray[nsamples, nrhs]) – The vector or matrix \(y\).
 in_place (Optional[bool]) – Should the data in
y
be overwritten with the result \(x\)? (default:False
)

apply_sqrt
(r)¶ Apply the Cholesky square root of the covariance matrix to the input vector or matrix.
Parameters: (ndarray[nsamples] or ndarray[nsamples, nrhs] (r) – The input vector or matrix.

compute
(x, yerr)¶ Compute and factorize the covariance matrix.
Parameters:  x (ndarray[nsamples, ndim]) – The independent coordinates of the data points.
 yerr (ndarray[nsamples] or float) – The Gaussian uncertainties on
the data points at coordinates
x
. These values will be added in quadrature to the diagonal of the covariance matrix.

computed
¶ A flag indicating whether or not the covariance matrix was computed and factorized (using the
compute()
method).

dot_solve
(y)¶ Compute the inner product of a vector with the inverse of the covariance matrix applied to itself:
\[y\,K^{1}\,y\]Parameters: y (ndarray[nsamples]) – The vector \(y\).

get_inverse
()¶ Get the dense inverse covariance matrix. This is used for computing gradients, but it is not recommended in general.
