Skip to content

Likelihoods

AbstractLikelihood

AbstractLikelihood(num_datapoints, integrator=GHQuadratureIntegrator())

Bases: Module

Abstract base class for likelihoods.

All likelihoods must inherit from this class and implement the predict and link_function methods.

Parameters:

  • num_datapoints (int) –

    the number of data points.

  • integrator (AbstractIntegrator, default: GHQuadratureIntegrator() ) –

    The integrator to be used for computing expected log likelihoods. Must be an instance of AbstractIntegrator.

__call__

__call__(*args, **kwargs)

Evaluate the likelihood function at a given predictive distribution.

Parameters:

  • *args (Any, default: () ) –

    Arguments to be passed to the likelihood's predict method.

  • **kwargs (Any, default: {} ) –

    Keyword arguments to be passed to the likelihood's predict method.

Returns:

  • Distribution –

    The predictive distribution.

predict abstractmethod

predict(*args, **kwargs)

Evaluate the likelihood function at a given predictive distribution.

Parameters:

  • *args (Any, default: () ) –

    Arguments to be passed to the likelihood's predict method.

  • **kwargs (Any, default: {} ) –

    Keyword arguments to be passed to the likelihood's predict method.

Returns:

  • Distribution –

    tfd.Distribution: The predictive distribution.

link_function(f)

Return the link function of the likelihood function.

Parameters:

  • f (Float[Array, ...]) –

    the latent Gaussian process values.

Returns:

  • Distribution –

    tfd.Distribution: The distribution of observations, y, given values of the Gaussian process, f.

expected_log_likelihood

expected_log_likelihood(y, mean, variance)

Compute the expected log likelihood.

For a variational distribution \(q(f)\sim\mathcal{N}(m, s)\) and a likelihood \(p(y|f)\), compute the expected log likelihood:

Eq(f)[log⁑p(y∣f)] \mathbb{E}_{q(f)}\left[\log p(y|f)\right]

Parameters:

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

    The observed response variable.

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

    The variational mean.

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

    The variational variance.

Returns:

  • ScalarFloat ( Float[Array, ' N'] ) –

    The expected log likelihood.

Gaussian

Gaussian(num_datapoints, obs_stddev=1.0, integrator=AnalyticalGaussianIntegrator())

Bases: AbstractLikelihood

Gaussian likelihood object.

Parameters:

  • num_datapoints (int) –

    the number of data points.

  • obs_stddev (Union[ScalarFloat, Float[Array, '#N']], default: 1.0 ) –

    the standard deviation of the Gaussian observation noise.

  • integrator (AbstractIntegrator, default: AnalyticalGaussianIntegrator() ) –

    The integrator to be used for computing expected log likelihoods. Must be an instance of AbstractIntegrator. For the Gaussian likelihood, this defaults to the AnalyticalGaussianIntegrator, as the expected log likelihood can be computed analytically.

__call__

__call__(*args, **kwargs)

Evaluate the likelihood function at a given predictive distribution.

Parameters:

  • *args (Any, default: () ) –

    Arguments to be passed to the likelihood's predict method.

  • **kwargs (Any, default: {} ) –

    Keyword arguments to be passed to the likelihood's predict method.

Returns:

  • Distribution –

    The predictive distribution.

expected_log_likelihood

expected_log_likelihood(y, mean, variance)

Compute the expected log likelihood.

For a variational distribution \(q(f)\sim\mathcal{N}(m, s)\) and a likelihood \(p(y|f)\), compute the expected log likelihood:

Eq(f)[log⁑p(y∣f)] \mathbb{E}_{q(f)}\left[\log p(y|f)\right]

Parameters:

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

    The observed response variable.

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

    The variational mean.

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

    The variational variance.

Returns:

  • ScalarFloat ( Float[Array, ' N'] ) –

    The expected log likelihood.

link_function(f)

The link function of the Gaussian likelihood.

Parameters:

  • f (Float[Array, ...]) –

    Function values.

Returns:

  • Normal –

    tfd.Normal: The likelihood function.

predict

predict(dist)

Evaluate the Gaussian likelihood.

Evaluate the Gaussian likelihood function at a given predictive distribution. Computationally, this is equivalent to summing the observation noise term to the diagonal elements of the predictive distribution's covariance matrix.

Parameters:

  • dist (Distribution) –

    The Gaussian process posterior, evaluated at a finite set of test points.

Returns:

  • MultivariateNormalFullCovariance –

    tfd.Distribution: The predictive distribution.

Bernoulli

Bernoulli(num_datapoints, integrator=GHQuadratureIntegrator())

Bases: AbstractLikelihood

Parameters:

  • num_datapoints (int) –

    the number of data points.

  • integrator (AbstractIntegrator, default: GHQuadratureIntegrator() ) –

    The integrator to be used for computing expected log likelihoods. Must be an instance of AbstractIntegrator.

__call__

__call__(*args, **kwargs)

Evaluate the likelihood function at a given predictive distribution.

Parameters:

  • *args (Any, default: () ) –

    Arguments to be passed to the likelihood's predict method.

  • **kwargs (Any, default: {} ) –

    Keyword arguments to be passed to the likelihood's predict method.

Returns:

  • Distribution –

    The predictive distribution.

expected_log_likelihood

expected_log_likelihood(y, mean, variance)

Compute the expected log likelihood.

For a variational distribution \(q(f)\sim\mathcal{N}(m, s)\) and a likelihood \(p(y|f)\), compute the expected log likelihood:

Eq(f)[log⁑p(y∣f)] \mathbb{E}_{q(f)}\left[\log p(y|f)\right]

Parameters:

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

    The observed response variable.

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

    The variational mean.

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

    The variational variance.

Returns:

  • ScalarFloat ( Float[Array, ' N'] ) –

    The expected log likelihood.

link_function(f)

The probit link function of the Bernoulli likelihood.

Parameters:

  • f (Float[Array, ...]) –

    Function values.

Returns:

  • Distribution –

    tfd.Distribution: The likelihood function.

predict

predict(dist)

Evaluate the pointwise predictive distribution.

Evaluate the pointwise predictive distribution, given a Gaussian process posterior and likelihood parameters.

Parameters:

  • dist (Distribution) –

    The Gaussian process posterior, evaluated at a finite set of test points.

Returns:

  • Distribution –

    tfd.Distribution: The pointwise predictive distribution.

Poisson

Poisson(num_datapoints, integrator=GHQuadratureIntegrator())

Bases: AbstractLikelihood

Parameters:

  • num_datapoints (int) –

    the number of data points.

  • integrator (AbstractIntegrator, default: GHQuadratureIntegrator() ) –

    The integrator to be used for computing expected log likelihoods. Must be an instance of AbstractIntegrator.

__call__

__call__(*args, **kwargs)

Evaluate the likelihood function at a given predictive distribution.

Parameters:

  • *args (Any, default: () ) –

    Arguments to be passed to the likelihood's predict method.

  • **kwargs (Any, default: {} ) –

    Keyword arguments to be passed to the likelihood's predict method.

Returns:

  • Distribution –

    The predictive distribution.

expected_log_likelihood

expected_log_likelihood(y, mean, variance)

Compute the expected log likelihood.

For a variational distribution \(q(f)\sim\mathcal{N}(m, s)\) and a likelihood \(p(y|f)\), compute the expected log likelihood:

Eq(f)[log⁑p(y∣f)] \mathbb{E}_{q(f)}\left[\log p(y|f)\right]

Parameters:

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

    The observed response variable.

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

    The variational mean.

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

    The variational variance.

Returns:

  • ScalarFloat ( Float[Array, ' N'] ) –

    The expected log likelihood.

link_function(f)

The link function of the Poisson likelihood.

Parameters:

  • f (Float[Array, ...]) –

    Function values.

Returns:

  • Distribution –

    tfd.Distribution: The likelihood function.

predict

predict(dist)

Evaluate the pointwise predictive distribution.

Evaluate the pointwise predictive distribution, given a Gaussian process posterior and likelihood parameters.

Parameters:

  • dist (Distribution) –

    The Gaussian process posterior, evaluated at a finite set of test points.

Returns:

  • Distribution –

    tfd.Distribution: The pointwise predictive distribution.

inv_probit

inv_probit(x)

Compute the inverse probit function.

Parameters:

  • x (Float[Array, '*N']) –

    A vector of values.

Returns

Float[Array, "*N"]: The inverse probit of the input vector.