TransportMaps.Likelihoods

Classes

Inheritance diagram of TransportMaps.Likelihoods.LogLikelihood, TransportMaps.Likelihoods.AdditiveLogLikelihood, TransportMaps.Likelihoods.AdditiveLinearGaussianLogLikelihood, TransportMaps.Likelihoods.AdditiveConditionallyLinearGaussianLogLikelihood, TransportMaps.Likelihoods.IndependentLogLikelihood
Class Description
LogLikelihood Abstract class for log-likelihood \(\log \pi({\bf y} \vert {\bf x})\)
AdditiveLogLikelihood Log-likelihood \(\log \pi({\bf y} \vert {\bf x})=\log\pi({\bf y} - T({\bf x}))\)
AdditiveLinearGaussianLogLikelihood Define the log-likelihood for the additive linear Gaussian model
AdditiveConditionallyLinearGaussianLogLikelihood Define the log-likelihood for the additive linear Gaussian model
IndependentLogLikelihood Handling likelihoods in the form \(\pi({\bf y}\vert{\bf x}) = \prod_{i=1}^{n}\pi_i({\bf y}_i\vert{\bf x}_i)\)

Documentation

class TransportMaps.Likelihoods.LogLikelihood(y, dim)[source]

Abstract class for log-likelihood \(\log \pi({\bf y} \vert {\bf x})\)

Note that \(\log\pi:\mathbb{R}^d \rightarrow \mathbb{R}\) is considered a function of \({\bf x}\), while the data \({\bf y}\) is fixed.

Parameters:
  • y (ndarray) – data
  • dim (int) – input dimension $d$
action_hess_x(x, dx, *args, **kwargs)[source]

[Abstract] Evaluate \(\langle \nabla^2_{\bf x}\log\pi({\bf y} \vert {\bf x}),\delta{\bf x}\rangle\).

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points
  • dx (ndarray [\(m,d\)]) – direction on which to evaluate the Hessian
Returns:

(ndarray [\(m,d\)]) – Hessian evaluations

evaluate(x, *args, **kwargs)[source]

[Abstract] Evaluate \(\log\pi({\bf y} \vert {\bf x})\).

Parameters:x (ndarray [\(m,d\)]) – evaluation points
Returns:(ndarray [\(m\)]) – function evaluations
grad_x(x, *args, **kwargs)[source]

[Abstract] Evaluate \(\nabla_{\bf x}\log\pi({\bf y} \vert {\bf x})\).

Parameters:x (ndarray [\(m,d\)]) – evaluation points
Returns:(ndarray [\(m,d\)]) – gradient evaluations
hess_x(x, *args, **kwargs)[source]

[Abstract] Evaluate \(\nabla^2_{\bf x}\log\pi({\bf y} \vert {\bf x})\).

Parameters:x (ndarray [\(m,d\)]) – evaluation points
Returns:(ndarray [\(m,d,d\)]) – Hessian evaluations
tuple_grad_x(x, cache=None, **kwargs)[source]

Evaluate \(\left(\log\pi({\bf y} \vert {\bf x}),\nabla_{\bf x}\log\pi({\bf y} \vert {\bf x})\right)\).

Parameters:x (ndarray [\(m,d\)]) – evaluation points
Returns:
(tuple) –
\(\left(\log\pi({\bf y} \vert {\bf x}),\nabla_{\bf x}\log\pi({\bf y} \vert {\bf x})\right)\)
class TransportMaps.Likelihoods.AdditiveLogLikelihood(y, pi, T)[source]

Log-likelihood \(\log \pi({\bf y} \vert {\bf x})=\log\pi({\bf y} - T({\bf x}))\)

Parameters:
  • y (ndarray \([d_y]\)) – data
  • pi (Distribution) – distribution \(\nu_\pi\)
  • T (Map) – map \(T:\mathbb{R}^d\rightarrow\mathbb{R}^{d_y}\)
action_hess_x(x, dx, idxs_slice=slice(None, None, None), cache=None, **kwargs)[source]

Evaluate \(\langle\nabla^2_{\bf x}\log\pi({\bf y} \vert {\bf x}),\delta{\bf x}\rangle\).

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points
  • dx (ndarray [\(m,d\)]) – direction on which to evaluate the Hessian
  • cache (dict) – cache
Returns:

(ndarray [\(m,d,\)]) – action of Hessian evaluations

Todo

caching is not implemented

evaluate(x, idxs_slice=slice(None, None, None), cache=None, **kwargs)[source]

Evaluate \(\log\pi({\bf y} \vert {\bf x})\).

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points
  • cache (dict) – cache
Returns:

(ndarray [\(m\)]) – function evaluations

grad_x(x, idxs_slice=slice(None, None, None), cache=None, **kwargs)[source]

Evaluate \(\nabla_{\bf x}\log\pi({\bf y} \vert {\bf x})\).

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points
  • cache (dict) – cache
Returns:

(ndarray [\(m,d\)]) – gradient evaluations

Todo

caching is not implemented

hess_x(x, idxs_slice=slice(None, None, None), cache=None, **kwargs)[source]

Evaluate \(\nabla^2_{\bf x}\log\pi({\bf y} \vert {\bf x})\).

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points
  • cache (dict) – cache
Returns:

(ndarray [\(m,d,d\)]) – Hessian evaluations

Todo

caching is not implemented

tuple_grad_x(x, idxs_slice=slice(None, None, None), cache=None, **kwargs)[source]

Evaluate \(\log\pi({\bf y} \vert {\bf x}), \nabla_{\bf x}\log\pi({\bf y} \vert {\bf x})\).

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points
  • cache (dict) – cache
Returns:

(tuple) – function and gradient evaluations

Todo

caching is not implemented

class TransportMaps.Likelihoods.AdditiveLinearGaussianLogLikelihood(y, c, T, mu, sigma=None, precision=None)[source]

Define the log-likelihood for the additive linear Gaussian model

The model is

\[{\bf y} = {\bf c} + {\bf T}{\bf x} + \varepsilon \;, \quad \varepsilon \sim \mathcal{N}(\mu, \Sigma)\]

where \(T \in \mathbb{R}^{d_y \times d_x}\), \(\mu \in \mathbb{R}^{d_y}\) and \(\Sigma \in \mathbb{R}^{d_y \times d_y}\) is symmetric positve definite

Parameters:
  • y (ndarray [\(d_y\)]) – data
  • c (ndarray [\(d_y\)] or Map) – system constant or parametric map returning the constant
  • T (ndarray [\(d_y,d_x\)] or Map) – system matrix or parametric map returning the system matrix
  • mu (ndarray [\(d_y\)] or Map) – noise mean or parametric map returning the mean
  • sigma (ndarray [\(d_y,d_y\)] or Map) – noise covariance or parametric map returning the covariance
  • precision (ndarray [\(d_y,d_y\)] or Map) – noise precision matrix or parametric map returning the precision matrix
class TransportMaps.Likelihoods.AdditiveConditionallyLinearGaussianLogLikelihood(y, c, T, mu, sigma=None, precision=None, active_vars_system=[], active_vars_distribution=[], coeffs=None)[source]

Define the log-likelihood for the additive linear Gaussian model

The model is

\[{\bf y} = {\bf c}(\theta) + {\bf T}(\theta){\bf x} + \varepsilon \;, \quad \varepsilon \sim \mathcal{N}(\mu(\theta), \Sigma(\theta))\]

where \(T \in \mathbb{R}^{d_y \times d_x}\), \(\mu \in \mathbb{R}^{d_y}\) and \(\Sigma \in \mathbb{R}^{d_y \times d_y}\) is symmetric positve definite

Parameters:
  • y (ndarray [\(d_y\)]) – data
  • c (ndarray [\(d_y\)] or Map) – system constant or parametric map returning the constant
  • T (ndarray [\(d_y,d_x\)] or Map) – system matrix or parametric map returning the system matrix
  • mu (ndarray [\(d_y\)] or Map) – noise mean or parametric map returning the mean
  • sigma (ndarray [\(d_y,d_y\)] or Map) – noise covariance or parametric map returning the covariance
  • precision (ndarray [\(d_y,d_y\)] or Map) – noise precision matrix or parametric map returning the precision matrix
  • active_vars_system (list of int) – active variables identifying the parameters for for \(c(\theta), T(\theta)\).
  • active_vars_distribution (list of int) – active variables identifying the parameters for for \(\mu(\theta), \Sigma(\theta)\).
  • coeffs (ndarray) – initialization coefficients
class TransportMaps.Likelihoods.IndependentLogLikelihood(factors)[source]

Handling likelihoods in the form \(\pi({\bf y}\vert{\bf x}) = \prod_{i=1}^{n}\pi_i({\bf y}_i\vert{\bf x}_i)\)

Parameters:factors (list of tuple) – each tuple contains a log-likelihood (LogLikelihood) and the sub-set of variables of \({\bf x}\) on which it acts.

Example

Let \(\pi(y_0,y_2\vert x_0,x_1,x_2)= \pi_0(y_0\vert x_0) \pi_2(y_2,x_2)\).

>>> factors = [(ll0, [0]),
>>>            (ll2, [2])]
>>> ll = IndependentLogLikelihood(factors)
action_hess_x(x, dx, idxs_slice=slice(None, None, None), cache=None, **kwargs)[source]

Evaluate \(\langle\nabla^2_{\bf x}\log\pi({\bf y} \vert {\bf x}),\delta{\bf x}\rangle\).

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points
  • dx (ndarray [\(m,d\)]) – direction on which to evaluate the Hessian
  • cache (dict) – cache
Returns:

(ndarray [\(m,d\)]) – Hessian evaluations

append(factor)[source]

Add a new factor to the likelihood

Parameters:factors (tuple) – tuple containing a log-likelihood (LogLikelihood) and the sub-set of variables of \({\bf x}\) on which it acts.

Example

Let \(\pi(y_0,y_2\vert x_0,x_1,x_2)= \pi_0(y_0\vert x_0) \pi_2(y_2,x_2)\) and let’s add the factor \(\pi_1(y_1\vert x_1)\), obtaining:

\[\pi(y_0,y_1,y_2\vert x_0,x_1,x_2)= \pi_0(y_0\vert x_0) \pi_1(y_1\vert x_1) \pi_2(y_2,x_2)\]
>>> factor = (ll1, [1])
>>> ll.append(factor)
evaluate(x, idxs_slice=slice(None, None, None), cache=None, **kwargs)[source]

Evaluate \(\log\pi({\bf y} \vert {\bf x})\).

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points
  • cache (dict) – cache
Returns:

(ndarray [\(m\)]) – function evaluations

grad_x(x, idxs_slice=slice(None, None, None), cache=None, **kwargs)[source]

Evaluate \(\nabla_{\bf x}\log\pi({\bf y} \vert {\bf x})\).

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points
  • cache (dict) – cache
Returns:

(ndarray [\(m,d\)]) – gradient evaluations

hess_x(x, idxs_slice=slice(None, None, None), cache=None, **kwargs)[source]

Evaluate \(\nabla^2_{\bf x}\log\pi({\bf y} \vert {\bf x})\).

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points
  • cache (dict) – cache
Returns:

(ndarray [\(m,d,d\)]) – Hessian evaluations

tuple_grad_x(x, idxs_slice=slice(None, None, None), cache=None, **kwargs)[source]

Evaluate \(\log\pi({\bf y} \vert {\bf x}), \nabla_{\bf x}\log\pi({\bf y} \vert {\bf x})\).

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points
  • cache (dict) – cache
Returns:

(tuple) – function and gradient evaluations