Integrators
AbstractIntegrator
Base class for integrators.
integrate
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:
-
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__
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
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__
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
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__
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
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.