Skip to content

Integrators

gpjax.integrators

Likelihood = TypeVar('Likelihood', bound=Union['gpjax.likelihoods.AbstractLikelihood', None]) module-attribute
Gaussian = TypeVar('Gaussian', bound='gpjax.likelihoods.Gaussian') module-attribute
__all__ = ['AbstractIntegrator', 'GHQuadratureIntegrator', 'AnalyticalGaussianIntegrator'] module-attribute
AbstractIntegrator dataclass

Base class for integrators.

__init__() -> None
integrate(fun: Callable, y: Float[Array, 'N D'], mean: Float[Array, 'N D'], variance: Float[Array, 'N D'], likelihood: Likelihood) -> Float[Array, ' N'] abstractmethod

Integrate a function with respect to a Gaussian distribution.

Typically, the function will be the likelihood function and the mean and variance will be the parameters of the variational distribution.

Parameters:

Name Type Description Default
fun Callable

The function to be integrated.

required
y Float[Array, 'N D']

The observed response variable.

required
mean Float[Array, 'N D']

The mean of the variational distribution.

required
variance Float[Array, 'N D']

The variance of the variational distribution.

required
likelihood AbstractLikelihood

The likelihood function.

required
__call__(fun: Callable, y: Float[Array, 'N D'], mean: Float[Array, 'N D'], variance: Float[Array, 'N D'], likelihood: Likelihood) -> Float[Array, ' N']

Integrate a function with respect to a Gaussian distribution.

Typically, the function will be the likelihood function and the mean and variance will be the parameters of the variational distribution.

Parameters:

Name Type Description Default
fun Callable

The function to be integrated.

required
y Float[Array, 'N D']

The observed response variable.

required
mean Float[Array, 'N D']

The mean of the variational distribution.

required
variance Float[Array, 'N D']

The variance of the variational distribution.

required
likelihood AbstractLikelihood

The likelihood function.

required
GHQuadratureIntegrator dataclass

Bases: AbstractIntegrator

Compute an integral using Gauss-Hermite quadrature.

Gauss-Hermite quadrature is a method for approximating integrals through a weighted sum of function evaluations at specific points

∫F(t)exp⁑(βˆ’t2)dtβ‰ˆβˆ‘j=1JwjF(tj) \int F(t)\exp(-t^2)\mathrm{d}t \approx \sum_{j=1}^J w_j F(t_j)

where tjt_j and wjw_j are the roots and weights of the JJ-th order Hermite polynomial HJ(t)H_J(t) that we can look up in table link.

num_points: int = 20 class-attribute instance-attribute
__call__(fun: Callable, y: Float[Array, 'N D'], mean: Float[Array, 'N D'], variance: Float[Array, 'N D'], likelihood: Likelihood) -> Float[Array, ' N']

Integrate a function with respect to a Gaussian distribution.

Typically, the function will be the likelihood function and the mean and variance will be the parameters of the variational distribution.

Parameters:

Name Type Description Default
fun Callable

The function to be integrated.

required
y Float[Array, 'N D']

The observed response variable.

required
mean Float[Array, 'N D']

The mean of the variational distribution.

required
variance Float[Array, 'N D']

The variance of the variational distribution.

required
likelihood AbstractLikelihood

The likelihood function.

required
__init__(num_points: int = 20) -> None
integrate(fun: Callable, y: Float[Array, 'N D'], mean: Float[Array, 'N D'], variance: Float[Array, 'N D'], likelihood: Likelihood) -> Float[Array, ' N']

Compute a quadrature integral.

Parameters:

Name Type Description Default
fun Callable

The likelihood to be integrated.

required
y Float[Array, 'N D']

The observed response variable.

required
mean Float[Array, 'N D']

The mean of the variational distribution.

required
variance Float[Array, 'N D']

The variance of the variational distribution.

required
likelihood AbstractLikelihood

The likelihood function.

required

Returns:

Type Description
Float[Array, ' N']

Float[Array, 'N']: The expected log likelihood.

AnalyticalGaussianIntegrator dataclass

Bases: AbstractIntegrator

Compute the analytical integral of a Gaussian likelihood.

When the likelihood function is Gaussian, the integral can be computed in closed form. For a Gaussian likelihood p(y∣f)=N(y∣f,Οƒ2)p(y|f) = \mathcal{N}(y|f, \sigma^2) and a variational distribution q(f)=N(f∣m,s)q(f) = \mathcal{N}(f|m, s), the expected log-likelihood is given by

Eq(f)[log⁑p(y∣f)]=βˆ’12(log⁑(2πσ2)+1Οƒ2((yβˆ’m)2+s)) \mathbb{E}_{q(f)}[\log p(y|f)] = -\frac{1}{2}\left(\log(2\pi\sigma^2) + \frac{1}{\sigma^2}((y-m)^2 + s)\right)

__call__(fun: Callable, y: Float[Array, 'N D'], mean: Float[Array, 'N D'], variance: Float[Array, 'N D'], likelihood: Likelihood) -> Float[Array, ' N']

Integrate a function with respect to a Gaussian distribution.

Typically, the function will be the likelihood function and the mean and variance will be the parameters of the variational distribution.

Parameters:

Name Type Description Default
fun Callable

The function to be integrated.

required
y Float[Array, 'N D']

The observed response variable.

required
mean Float[Array, 'N D']

The mean of the variational distribution.

required
variance Float[Array, 'N D']

The variance of the variational distribution.

required
likelihood AbstractLikelihood

The likelihood function.

required
__init__() -> None
integrate(fun: Callable, y: Float[Array, 'N D'], mean: Float[Array, 'N D'], variance: Float[Array, 'N D'], likelihood: Gaussian) -> Float[Array, ' N']

Compute a Gaussian integral.

Parameters:

Name Type Description Default
fun Callable

The Gaussian likelihood to be integrated.

required
y Float[Array, 'N D']

The observed response variable.

required
mean Float[Array, 'N D']

The mean of the variational distribution.

required
variance Float[Array, 'N D']

The variance of the variational distribution.

required
likelihood Gaussian

The Gaussian likelihood function.

required

Returns:

Type Description
Float[Array, ' N']

Float[Array, 'N']: The expected log likelihood.