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 where and are the roots and weights of the -th order Hermite polynomial 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 and a variational distribution , the expected log-likelihood is given by
__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.