Skip to content

Integrators

AbstractIntegrator

Base class for integrators.

integrate abstractmethod

integrate(fun, y, mean, variance, likelihood)

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:

  • fun (Callable) –

    The function to be integrated.

  • y (Float[Array, 'N D']) –

    The observed response variable.

  • mean (Float[Array, 'N D']) –

    The mean of the variational distribution.

  • variance (Float[Array, 'N D']) –

    The variance of the variational distribution.

  • likelihood (AbstractLikelihood) –

    The likelihood function.

__call__

__call__(fun, y, mean, variance, likelihood)

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:

  • fun (Callable) –

    The function to be integrated.

  • y (Float[Array, 'N D']) –

    The observed response variable.

  • mean (Float[Array, 'N D']) –

    The mean of the variational distribution.

  • variance (Float[Array, 'N D']) –

    The variance of the variational distribution.

  • likelihood (AbstractLikelihood) –

    The likelihood function.

GHQuadratureIntegrator

GHQuadratureIntegrator(num_points=20)

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 $$ \int F(t)\exp(-t^2)\mathrm{d}t \approx \sum_{j=1}^J w_j F(t_j) $$ where \(t_j\) and \(w_j\) are the roots and weights of the \(J\)-th order Hermite polynomial \(H_J(t)\) that we can look up in table link.

Parameters:

  • num_points (int, default: 20 ) –

    The number of points to use in the quadrature. Defaults to 20.

__call__

__call__(fun, y, mean, variance, likelihood)

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:

  • fun (Callable) –

    The function to be integrated.

  • y (Float[Array, 'N D']) –

    The observed response variable.

  • mean (Float[Array, 'N D']) –

    The mean of the variational distribution.

  • variance (Float[Array, 'N D']) –

    The variance of the variational distribution.

  • likelihood (AbstractLikelihood) –

    The likelihood function.

integrate

integrate(fun, y, mean, variance, likelihood)

Compute a quadrature integral.

Parameters:

  • fun (Callable) –

    the likelihood to be integrated.

  • y (Float[Array, 'N D']) –

    the observed response variable.

  • mean (Float[Array, 'N D']) –

    the mean of the variational distribution.

  • variance (Float[Array, 'N D']) –

    the variance of the variational distribution.

  • likelihood (L | None) –

    the likelihood function.

Returns:

  • Float[Array, ' N'] –

    The expected log likelihood as an array of shape (N,).

AnalyticalGaussianIntegrator

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) = \mathcal{N}(y|f, \sigma^2)\) and a variational distribution \(q(f) = \mathcal{N}(f|m, s)\), the expected log-likelihood is given by $$ \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__

__call__(fun, y, mean, variance, likelihood)

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:

  • fun (Callable) –

    The function to be integrated.

  • y (Float[Array, 'N D']) –

    The observed response variable.

  • mean (Float[Array, 'N D']) –

    The mean of the variational distribution.

  • variance (Float[Array, 'N D']) –

    The variance of the variational distribution.

  • likelihood (AbstractLikelihood) –

    The likelihood function.

integrate

integrate(fun, y, mean, variance, likelihood)

Compute a Gaussian integral.

Parameters:

  • fun (Callable) –

    The Gaussian likelihood to be integrated.

  • y (Float[Array, 'N D']) –

    The observed response variable.

  • mean (Float[Array, 'N D']) –

    The mean of the variational distribution.

  • variance (Float[Array, 'N D']) –

    The variance of the variational distribution.

  • likelihood (Gaussian) –

    The Gaussian likelihood function.

Returns:

  • Float[Array, ' N'] –

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