TransportMaps.Maps.Functionals.FrozenMonotonicFunctions

Module Contents

Classes

MonotonicFrozenFunction

[Abstract] Frozen function. No optimization over the coefficients allowed.

FrozenLinear

Frozen Linear map \({\bf x} \rightarrow a_1 + a_2 {\bf x}_d\)

FrozenExponential

Frozen Exponential map \(f_{\bf a}:{\bf x} \mapsto \exp( {\bf x}_d )\)

FrozenNormalToUniform

Frozen Gaussian To Uniform map.

Attributes

FrozenGaussianToUniform

class TransportMaps.Maps.Functionals.FrozenMonotonicFunctions.MonotonicFrozenFunction(dim)[source]

Bases: TransportMaps.Maps.Functionals.MonotoneFunctionalBase.MonotoneFunctional

[Abstract] Frozen function. No optimization over the coefficients allowed.

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

[Abstract] Precompute necessary structures for the evaluation of \(f_{\bf a}\) at x.

Parameters:

x (ndarray [\(m,d\)]) – evaluation points

Returns:

(dict) – data structures

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

[Abstract] Precompute necessary structures for the evaluation of \(\nabla_{\bf x} f_{\bf a}\) at x

Parameters:

x (ndarray [\(m,d\)]) – evaluation points

Returns:

(dict) – data structures

precomp_hess_x(x, *args, **kwargs)[source]
precomp_partial_xd(x, *args, **kwargs)[source]

[Abstract] Precompute necessary structures for the evaluation of \(\partial_{x_d} f_{\bf a}\) at x.

Parameters:

x (ndarray [\(m,d\)]) – evaluation points

Returns:

(dict) – data structures

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

[Abstract] Precompute necessary structures for the evaluation of \(\nabla_{\bf x}\partial_{x_d} f_{\bf a}\) at x.

Parameters:

x (ndarray [\(m,d\)]) – evaluation points

Returns:

(dict) – data structures

precomp_hess_x_partial_xd(x, *args, **kwargs)[source]
precomp_partial2_xd(x, *args, **kwargs)[source]

[Abstract] Precompute necessary structures for the evaluation of \(\partial^2_{x_d} f_{\bf a}\) at x.

Parameters:

x (ndarray [\(m,d\)]) – evaluation points

Returns:

(dict) – data structures

class TransportMaps.Maps.Functionals.FrozenMonotonicFunctions.FrozenLinear(dim, a1, a2)[source]

Bases: MonotonicFrozenFunction

Frozen Linear map \({\bf x} \rightarrow a_1 + a_2 {\bf x}_d\)

Parameters:
  • dim (int) – input dimension \(d\)

  • a1 (int) – coefficient \(a_1\)

  • a2 (int) – coefficient \(a_2\)

property n_coeffs[source]

2

Type:

Returns

set_coeffs(a1, a2)[source]

Set coefficients \(a_1\) and \(a_2\).

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

Evaluate \(f_{\bf a}({\bf x}) = a_1 + a_2 {\bf x}_d\)

Parameters:

x (ndarray [\(m,d\)]) – evaluation points.

Returns:

(ndarray [\(m,1\)]) – function value at points x

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

Evaluate \(\nabla_{\bf x} f_{\bf a}({\bf x})\)

This is:

\[\begin{split}\nabla_{\bf x} f_{\bf a}({\bf x}) = \begin{bmatrix} \partial_{{\bf x}_1} f_{\bf a}({\bf x}) \\ \partial_{{\bf x}_2} f_{\bf a}({\bf x}) \\ \vdots \\ \partial_{{\bf x}_d} f_{\bf a}({\bf x}) \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \\ \vdots \\ a2 \end{bmatrix}\end{split}\]
Parameters:

x (ndarray [\(m,1,d\)]) – evaluation points.

Returns:

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

\(\nabla_{\bf x}f_{\bf a}({\bf x};{\bf a})\) at points x

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

Evaluate \(\partial_{{\bf x}_d} f_{\bf a}({\bf x}) = b\)

Parameters:

x (ndarray [\(m,d\)]) – evaluation points.

Returns:

(ndarray [\(m,1\)]) –

\(\partial_{{\bf x}_d}f_{\bf a}({\bf x})\) at points x

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

Evaluate \(\nabla_{\bf x}\partial_{{\bf x}_d} f_{\bf a}({\bf x}) = 0\)

Parameters:

x (ndarray [\(m,d\)]) – evaluation points.

Returns:

(ndarray [\(m,1,d\)]) –

\(\nabla_{\bf x}\partial_{{\bf x}_d}f_{\bf a}({\bf x})\) at points x

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

Evaluate \(\partial^2_{{\bf x}_d} f_{\bf a}({\bf x}) = 0\)

Parameters:

x (ndarray [\(m,d\)]) – evaluation points.

Returns:

(ndarray [\(m,1\)]) –

\(\partial^2_{{\bf x}_d}f_{\bf a}({\bf x};{\bf a})\) at points x

inverse(xkm1, y)[source]

Compute \(f_{\bf a}^{-1}({\bf x}_{1:d-1})(y):={\bf x}_d\) s.t. \(f_{\bf a}({\bf x}_{1:d-1},{\bf x}_d) - y = 0\).

Due to the form of the approximation we have:

\[f_{\bf a}^{-1}({\bf x}_{1:d-1})(y) = \frac{y-a_1}{a_2}\]
Parameters:
  • xkm1 (ndarray [\(d-1\)]) – fixed coordinates \({\bf x}_{1:d-1}\)

  • y (float) – value \(y\)

Returns:

(float) – inverse value \(x\).

class TransportMaps.Maps.Functionals.FrozenMonotonicFunctions.FrozenExponential(dim)[source]

Bases: MonotonicFrozenFunction

Frozen Exponential map \(f_{\bf a}:{\bf x} \mapsto \exp( {\bf x}_d )\)

Parameters:

dim (int) – input dimension \(d\)

property n_coeffs[source]

0

Type:

Returns

set_coeffs()[source]

No coefficients to be set.

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

Evaluate \(f_{\bf a}({\bf x}) = \exp({\bf x}_d)\)

Parameters:

x (ndarray [\(m,d\)]) – evaluation points.

Returns:

(ndarray [\(m,1\)]) – function value at points x

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

Evaluate \(\nabla_{\bf x} f_{\bf a}({\bf x})\)

This is:

\[\begin{split}\nabla_{\bf x} f_{\bf a}({\bf x}) = \begin{bmatrix} \partial_{{\bf x}_1} f_{\bf a}({\bf x}) \\ \partial_{{\bf x}_2} f_{\bf a}({\bf x}) \\ \vdots \\ \partial_{{\bf x}_d} f_{\bf a}({\bf x}) \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \\ \vdots \\ \exp({\bf x}_d) \end{bmatrix}\end{split}\]
Parameters:

x (ndarray [\(m,d\)]) – evaluation points.

Returns:

(ndarray [\(m,1,d\)]) –

\(\nabla_{\bf x}f_{\bf a}({\bf x};{\bf a})\) at points x

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

Evaluate \(\nabla^2_{\bf x} f_{\bf a}({\bf x})\)

This is:

\[\begin{split}\nabla^2_{\bf x} f_{\bf a}({\bf x}) = \begin{bmatrix} \partial^2_{{\bf x}_1} f_{\bf a}({\bf x}) & \partial_{{\bf x}_1{\bf x}_2} f_{\bf a}({\bf x}) & \cdots & \partial_{{\bf x}_1{\bf x}_d} f_{\bf a}({\bf x}) \\ \partial_{{\bf x}_2 {\bf x}_1} f_{\bf a}({\bf x}) & \partial^2_{{\bf x}_2} f_{\bf a}({\bf x}) & \cdots & \partial_{{\bf x}_2{\bf x}_d} f_{\bf a}({\bf x}) \\ \vdots & & \ddots & \\ \partial_{{\bf x}_d{\bf x}_1} f_{\bf a}({\bf x}) & \partial_{{\bf x}_d{\bf x}_2} f_{\bf a}({\bf x}) & \cdots & \partial^2_{{\bf x}_d} f_{\bf a}({\bf x}) \end{bmatrix} = \begin{bmatrix} 0 & \cdots & 0 & 0 \\ \vdots & \ddots & 0 & \vdots \\ 0 & \cdots & 0 & 0 \\ 0 & \cdots & 0 & \exp({\bf x}_d) \end{bmatrix}\end{split}\]
Parameters:

x (ndarray [\(m,d\)]) – evaluation points.

Returns:

(ndarray [\(m,1,d,d\)]) –

\(\nabla^2_{\bf x}f_{\bf a}({\bf x})\) at points x

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

Evaluate \(\partial_{{\bf x}_d} f_{\bf a}({\bf x}) = \exp({\bf x}_d)\)

Parameters:

x (ndarray [\(m,d\)]) – evaluation points.

Returns:

(ndarray [\(m,1\)]) –

\(\partial_{{\bf x}_d}f_{\bf a}({\bf x};{\bf a})\) at points x

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

Evaluate \(\nabla_{\bf x}\partial_{{\bf x}_d} f_{\bf a}({\bf x})\)

This is:

\[\begin{split}\nabla_{\bf x} \partial_{{\bf x}_d} f_{\bf a}({\bf x}) = \begin{bmatrix} \partial_{{\bf x}_1} f_{\bf a}({\bf x}) \\ \partial_{{\bf x}_2} f_{\bf a}({\bf x}) \\ \vdots \\ \partial_{{\bf x}_d} f_{\bf a}({\bf x}) \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \\ \vdots \\ \exp({\bf x}_d) \end{bmatrix}\end{split}\]
Parameters:

x (ndarray [\(m,1,d\)]) – evaluation points.

Returns:

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

\(\nabla_{\bf x}\partial_{{\bf x}_d}f_{\bf a}({\bf x})\) at points x

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

Evaluate \(\partial^2_{{\bf x}_d} f_{\bf a}({\bf x}) = \exp({\bf x}_d)\)

Parameters:

x (ndarray [\(m,d\)]) – evaluation points.

Returns:

(ndarray [\(m\)]) –

\(\partial^2_{{\bf x}_d}f_{\bf a}({\bf x})\) at points x

inverse(xkm1, y)[source]

Compute \(f_{\bf a}^{-1}({\bf x}_{1:d-1})(y):={\bf x}_d\) s.t. \(f_{\bf a}({\bf x}_{1:d-1},{\bf x}_d) - y = 0\).

Due to the form of the approximation we have:

\[f_{\bf a}^{-1}({\bf x}_{1:d-1})(y) = \log(y)\]
Parameters:
  • xkm1 (ndarray [\(d-1\)]) – fixed coordinates \({\bf x}_{1:d-1}\)

  • y (float) – value \(y\)

Returns:

(float) – inverse value \(x\).

class TransportMaps.Maps.Functionals.FrozenMonotonicFunctions.FrozenNormalToUniform(dim)[source]

Bases: MonotonicFrozenFunction

Frozen Gaussian To Uniform map.

This is given by the Cumulative Distribution Function of a standard normal distribution along the last coordinate:

\[f_{\bf a}({\bf x}) = \frac{1}{2} \left[ 1 + \text{erf}\left( \frac{x}{\sqrt{2}} \right)\right]\]
Parameters:

dim (int) – input dimension \(d\)

property n_coeffs[source]

0

Type:

Returns

set_coeffs()[source]

No coefficients to be set.

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

Evaluate \(f_{\bf a}({\bf x})\)

Parameters:

x (ndarray [\(m,d\)]) – evaluation points.

Returns:

(ndarray [\(m,1\)]) – function value at points x

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

Evaluate \(\nabla_{\bf x} f_{\bf a}({\bf x})\)

This is:

\[\begin{split}\nabla_{\bf x} f_{\bf a}({\bf x}) = \begin{bmatrix} \partial_{{\bf x}_1} f_{\bf a}({\bf x}) \\ \partial_{{\bf x}_2} f_{\bf a}({\bf x}) \\ \vdots \\ \partial_{{\bf x}_d} f_{\bf a}({\bf x}) \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \\ \vdots \\ (2\pi)^{-1}\exp(-\frac{{\bf x}^2_d}{2}) \end{bmatrix}\end{split}\]
Parameters:

x (ndarray [\(m,d\)]) – evaluation points.

Returns:

(ndarray [\(m,1,d\)]) –

\(\nabla_{\bf x}f_{\bf a}({\bf x})\) at points x

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

Evaluate \(\partial_{{\bf x}_d} f_{\bf a}({\bf x}) = (2\pi)^{-1}\exp(-\frac{{\bf x}^2_d}{2})\)

Parameters:

x (ndarray [\(m,d\)]) – evaluation points.

Returns:

(ndarray [\(m,1\)]) –

\(\partial_{{\bf x}_d}f_{\bf a}({\bf x})\) at points x

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

Evaluate \(\nabla^2_{\bf x} f_{\bf a}({\bf x})\)

This is:

\[\begin{split}\nabla^2_{\bf x} f_{\bf a}({\bf x}) = \begin{bmatrix} \partial^2_{{\bf x}_1} f_{\bf a}({\bf x}) & \partial_{{\bf x}_1{\bf x}_2} f_{\bf a}({\bf x}) & \cdots & \partial_{{\bf x}_1{\bf x}_d} f_{\bf a}({\bf x}) \\ \partial_{{\bf x}_2 {\bf x}_1} f_{\bf a}({\bf x}) & \partial^2_{{\bf x}_2} f_{\bf a}({\bf x}) & \cdots & \partial_{{\bf x}_2{\bf x}_d} f_{\bf a}({\bf x}) \\ \vdots & & \ddots & \\ \partial_{{\bf x}_d{\bf x}_1} f_{\bf a}({\bf x}) & \partial_{{\bf x}_d{\bf x}_2} f_{\bf a}({\bf x}) & \cdots & \partial^2_{{\bf x}_d} f_{\bf a}({\bf x}) \end{bmatrix} = \begin{bmatrix} 0 & \cdots & 0 & 0 \\ \vdots & \ddots & 0 & \vdots \\ 0 & \cdots & 0 & 0 \\ 0 & \cdots & 0 & -{\bf x}_d (2\pi)^{-1} \exp(-\frac{{\bf x}^2_d}{2}) \end{bmatrix}\end{split}\]
Parameters:

x (ndarray [\(m,d\)]) – evaluation points.

Returns:

(ndarray [\(m,1,d,d\)]) –

\(\nabla^2_{\bf x}f_{\bf a}({\bf x})\) at points x

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

Evaluate \(\nabla_{\bf x}\partial_{{\bf x}_d} f_{\bf a}({\bf x})\)

This is:

\[\begin{split}\nabla_{\bf x} \partial_{{\bf x}_d} f_{\bf a}({\bf x}) = \begin{bmatrix} \partial_{{\bf x}_1} f_{\bf a}({\bf x}) \\ \partial_{{\bf x}_2} f_{\bf a}({\bf x}) \\ \vdots \\ \partial_{{\bf x}_d} f_{\bf a}({\bf x}) \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \\ \vdots \\ -{\bf x}_d (2\pi)^{-1} \exp(-\frac{{\bf x}^2_d}{2}) \end{bmatrix}\end{split}\]
Parameters:

x (ndarray [\(m,d\)]) – evaluation points.

Returns:

(ndarray [\(m,1,d\)]) –

\(\nabla_{\bf x}\partial_{{\bf x}_d}f_{\bf a}({\bf x})\) at points x

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

Evaluate \(\partial^2_{{\bf x}_d} f_{\bf a}({\bf x}) = -{\bf x}_d (2\pi)^{-1} \exp(-\frac{{\bf x}^2_d}{2})\)

Parameters:

x (ndarray [\(m,d\)]) – evaluation points.

Returns:

(ndarray [\(m,1\)]) –

\(\partial^2_{{\bf x}_d}f_{\bf a}({\bf x})\) at points x

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

Evaluate \(\nabla^2_{\bf x} \partial_{{\bf x}_d} f_{\bf a}({\bf x})\)

This is:

\[\begin{split}\nabla^2_{\bf x} \partial_{{\bf x}_d} f_{\bf a}({\bf x}) = \begin{bmatrix} \partial^2_{{\bf x}_1} f_{\bf a}({\bf x}) & \partial_{{\bf x}_1{\bf x}_2} f_{\bf a}({\bf x}) & \cdots & \partial_{{\bf x}_1{\bf x}_d} f_{\bf a}({\bf x}) \\ \partial_{{\bf x}_2 {\bf x}_1} f_{\bf a}({\bf x}) & \partial^2_{{\bf x}_2} f_{\bf a}({\bf x}) & \cdots & \partial_{{\bf x}_2{\bf x}_d} f_{\bf a}({\bf x}) \\ \vdots & & \ddots & \\ \partial_{{\bf x}_d{\bf x}_1} f_{\bf a}({\bf x}) & \partial_{{\bf x}_d{\bf x}_2} f_{\bf a}({\bf x}) & \cdots & \partial^2_{{\bf x}_d} f_{\bf a}({\bf x}) \end{bmatrix} = \begin{bmatrix} 0 & \cdots & 0 & 0 \\ \vdots & \ddots & 0 & \vdots \\ 0 & \cdots & 0 & 0 \\ 0 & \cdots & 0 & ({\bf x}_d - 1) (2\pi)^{-1} \exp(-\frac{{\bf x}^2_d}{2}) \end{bmatrix}\end{split}\]
Parameters:

x (ndarray [\(m,d\)]) – evaluation points.

Returns:

(ndarray [\(m,1,d,d\)]) –

\(\nabla^2_{\bf x}\partial_{{\bf x}_d}f_{\bf a}({\bf x})\) at points x

invserse(xkm1, y)[source]

Compute \(f_{\bf a}^{-1}({\bf x}_{1:d-1})(y):={\bf x}_d\) s.t. \(f_{\bf a}({\bf x}_{1:d-1},{\bf x}_d) - y = 0\).

Due to the form of the approximation we have:

\[f_{\bf a}^{-1}({\bf x}_{1:d-1})(y) = \sqrt{2} \text{erf}^{-1}(2y-1)\]
Parameters:
  • xkm1 (ndarray [\(d-1\)]) – fixed coordinates \({\bf x}_{1:d-1}\)

  • y (float) – value \(y\)

Returns:

(float) – inverse value \(x\).

TransportMaps.Maps.Functionals.FrozenMonotonicFunctions.FrozenGaussianToUniform[source]