TransportMaps.L2.L2_distance
¶
Module Contents¶
Functions¶
|
Compute \(\vert f_1 - f_2 \vert^2\) |
|
Compute \(\nabla_{\bf a}\vert f_{1,{\bf a}} - f_2 \vert^2\) |
|
Compute \(\nabla^2_{\bf a}\vert f_{1,{\bf a}} - f_2 \vert^2\) |
|
Compute \(\Vert f_1 - f_2 \Vert_{L^2_\pi}\) |
|
Compute \(\Vert f_1 - f_2 \Vert^2_{L^2_\pi}\) |
|
Compute \(\nabla_{\bf a}\Vert f_{1,{\bf a}} - f_2 \Vert^2_{L^2_\pi}\) |
|
Compute \(\nabla^2_{\bf a}\Vert f_{1,{\bf a}} - f_2 \Vert^2_{L^2_\pi}\) |
|
Assemble \(\nabla^2_{\bf a}\Vert f_{1,{\bf a}} - f_2 \Vert^2_{L^2_\pi}\). |
Evaluate the action of \(\nabla^2_{\bf a}\Vert f_{1,{\bf a}} - f_2 \Vert^2_{L^2_\pi}\) on \(v\). |
- TransportMaps.L2.L2_distance.misfit_squared(f1, f2, x, params1=None, params2=None, idxs_slice=None)[source]¶
Compute \(\vert f_1 - f_2 \vert^2\)
- Parameters:
f1 (
Function
orndarray
[\(m\)]) – function \(f_1\) or its functions valuesf2 (
Function
orndarray
[\(m\)]) – function \(f_2\) or its functions valuesx (
ndarray
[\(m,d\)]) – quadrature points used for the approximation of \(\mathbb{E}_{\pi}\)params1 (dict) – parameters for function \(f_1\)
params2 (dict) – parameters for function \(f_2\)
idxs_slice (
slice
) – slice of points to be
- Returns:
(
ndarray
) – misfit \(\vert f_1 - f_2 \vert^2\)
- TransportMaps.L2.L2_distance.grad_a_misfit_squared(f1, f2, x, params1=None, params2=None, idxs_slice=None)[source]¶
Compute \(\nabla_{\bf a}\vert f_{1,{\bf a}} - f_2 \vert^2\)
- Parameters:
f1 (
Function
orndarray
[\(m\)]) – function \(f_1\) or its functions valuesf2 (
Function
orndarray
[\(m\)]) – function \(f_2\) or its functions valuesx (
ndarray
[\(m,d\)]) – quadrature points used for the approximation of \(\mathbb{E}_{\pi}\)params1 (dict) – parameters for function \(f_1\)
params2 (dict) – parameters for function \(f_2\)
idxs_slice (
slice
) – slice of points to be
- Returns:
- (
ndarray
) – misfit \(\nabla_{\bf a}\vert f_{1,{\bf a}} - f_2 \vert^2\)
- (
- TransportMaps.L2.L2_distance.hess_a_misfit_squared(f1, f2, x, params1=None, params2=None, idxs_slice=None)[source]¶
Compute \(\nabla^2_{\bf a}\vert f_{1,{\bf a}} - f_2 \vert^2\)
- Parameters:
f1 (
Function
orndarray
[\(m\)]) – function \(f_1\) or its functions valuesf2 (
Function
orndarray
[\(m\)]) – function \(f_2\) or its functions valuesx (
ndarray
[\(m,d\)]) – quadrature points used for the approximation of \(\mathbb{E}_{\pi}\)params1 (dict) – parameters for function \(f_1\)
params2 (dict) – parameters for function \(f_2\)
idxs_slice (
slice
) – slice of points to be
- Returns:
- (
ndarray
) – misfit \(\nabla^2_{\bf a}\vert f_{1,{\bf a}} - f_2 \vert^2\)
- (
- TransportMaps.L2.L2_distance.L2_misfit(*args, **kwargs)[source]¶
Compute \(\Vert f_1 - f_2 \Vert_{L^2_\pi}\)
- Parameters:
f1 (
Function
orndarray
[\(m\)]) – function \(f_1\) or its functions valuesf2 (
Function
orndarray
[\(m\)]) – function \(f_2\) or its functions valuesd (Distribution) – distribution \(\pi\)
params1 (dict) – parameters for function \(f_1\)
params2 (dict) – parameters for function \(f_2\)
qtype (int) – quadrature type to be used for the approximation of \(\mathbb{E}_{\pi}\)
qparams (object) – parameters necessary for the construction of the quadrature
x (
ndarray
[\(m,d\)]) – quadrature points used for the approximation of \(\mathbb{E}_{\pi}\)w (
ndarray
[\(m\)]) – quadrature weights used for the approximation of \(\mathbb{E}_{\pi}\)batch_size (int) – this defines whether to evaluate in batches or not. A size
1
correspond to a completely non-vectorized evaluation. A sizeNone
correspond to a completely vectorized one. (Note: ifnprocs > 1
, then the batch size defines the size of the batch for each process)mpi_pool (
mpi_map.MPI_Pool
) – pool of processes to be used for the evaluation off1
and ``f2`
- Returns:
(
float
) – misfit \(\Vert f_1 - f_2 \Vert_{L^2_\pi}\)
Note
The parameters
(qtype,qparams)
and(x,w)
are mutually exclusive, but one pair of them is necessary.
- TransportMaps.L2.L2_distance.L2squared_misfit(f1, f2, d=None, params1=None, params2=None, qtype=None, qparams=None, x=None, w=None, batch_size=None, mpi_pool=None)[source]¶
Compute \(\Vert f_1 - f_2 \Vert^2_{L^2_\pi}\)
- Parameters:
f1 (
Function
orndarray
[\(m\)]) – function \(f_1\) or its functions valuesf2 (
Function
orndarray
[\(m\)]) – function \(f_2\) or its functions valuesd (Distribution) – distribution \(\pi\)
params1 (dict) – parameters for function \(f_1\)
params2 (dict) – parameters for function \(f_2\)
qtype (int) – quadrature type to be used for the approximation of \(\mathbb{E}_{\pi}\)
qparams (object) – parameters necessary for the construction of the quadrature
x (
ndarray
[\(m,d\)]) – quadrature points used for the approximation of \(\mathbb{E}_{\pi}\)w (
ndarray
[\(m\)]) – quadrature weights used for the approximation of \(\mathbb{E}_{\pi}\)batch_size (int) – this defines whether to evaluate in batches or not. A size
1
correspond to a completely non-vectorized evaluation. A sizeNone
correspond to a completely vectorized one. (Note: ifnprocs > 1
, then the batch size defines the size of the batch for each process)mpi_pool (
mpi_map.MPI_Pool
) – pool of processes to be used for the evaluation off1
and ``f2`
- Returns:
(
float
) – misfit \(\Vert f_1 - f_2 \Vert^2_{L^2_\pi}\)
Note
The parameters
(qtype,qparams)
and(x,w)
are mutually exclusive, but one pair of them is necessary.
- TransportMaps.L2.L2_distance.grad_a_L2squared_misfit(f1, f2, d=None, params1=None, params2=None, qtype=None, qparams=None, x=None, w=None, batch_size=None, mpi_pool=None)[source]¶
Compute \(\nabla_{\bf a}\Vert f_{1,{\bf a}} - f_2 \Vert^2_{L^2_\pi}\)
- Parameters:
f1 (
ParametricFunctionApproximation
) – function \(f_1\)f2 (
Function
orndarray
[\(m\)]) – function \(f_2\) or its functions valuesd (Distribution) – distribution \(\pi\)
params1 (dict) – parameters for function \(f_1\)
params2 (dict) – parameters for function \(f_2\)
qtype (int) – quadrature type to be used for the approximation of \(\mathbb{E}_{\pi}\)
qparams (object) – parameters necessary for the construction of the quadrature
x (
ndarray
[\(m,d\)]) – quadrature points used for the approximation of \(\mathbb{E}_{\pi}\)w (
ndarray
[\(m\)]) – quadrature weights used for the approximation of \(\mathbb{E}_{\pi}\)batch_size (int) – this defines whether to evaluate in batches or not. A size
1
correspond to a completely non-vectorized evaluation. A sizeNone
correspond to a completely vectorized one. (Note: ifnprocs > 1
, then the batch size defines the size of the batch for each process)mpi_pool (
mpi_map.MPI_Pool
) – pool of processes to be used for the evaluation off1
and ``f2`
- Returns:
- (
ndarray
[\(N\)]) – misfit gradient \(\nabla_{\bf a}\Vert f_1 - f_2 \Vert_{L^2_\pi}\)
- (
Note
The parameters
(qtype,qparams)
and(x,w)
are mutually exclusive, but one pair of them is necessary.
- TransportMaps.L2.L2_distance.hess_a_L2squared_misfit(f1, f2, d=None, params1=None, params2=None, qtype=None, qparams=None, x=None, w=None, batch_size=None, mpi_pool=None)[source]¶
Compute \(\nabla^2_{\bf a}\Vert f_{1,{\bf a}} - f_2 \Vert^2_{L^2_\pi}\)
- Parameters:
f1 (
ParametricFunctionApproximation
) – function \(f_1\)f2 (
Function
orndarray
[\(m\)]) – function \(f_2\) or its functions valuesd (Distribution) – distribution \(\pi\)
params1 (dict) – parameters for function \(f_1\)
params2 (dict) – parameters for function \(f_2\)
qtype (int) – quadrature type to be used for the approximation of \(\mathbb{E}_{\pi}\)
qparams (object) – parameters necessary for the construction of the quadrature
x (
ndarray
[\(m,d\)]) – quadrature points used for the approximation of \(\mathbb{E}_{\pi}\)w (
ndarray
[\(m\)]) – quadrature weights used for the approximation of \(\mathbb{E}_{\pi}\)batch_size (int) – this defines whether to evaluate in batches or not. A size
1
correspond to a completely non-vectorized evaluation. A sizeNone
correspond to a completely vectorized one. (Note: ifnprocs > 1
, then the batch size defines the size of the batch for each process)mpi_pool (
mpi_map.MPI_Pool
) – pool of processes to be used for the evaluation off1
and ``f2`
- Returns:
- (
ndarray
[\(N,N\)]) – misfit Hessian \(\nabla^2_{\bf a}\Vert f_1 - f_2 \Vert_{L^2_\pi}\)
- (
Note
The parameters
(qtype,qparams)
and(x,w)
are mutually exclusive, but one pair of them is necessary.
- TransportMaps.L2.L2_distance.storage_hess_a_L2squared_misfit(f1, f2, d=None, params1=None, params2=None, qtype=None, qparams=None, x=None, w=None, batch_size=None, mpi_pool=None)[source]¶
Assemble \(\nabla^2_{\bf a}\Vert f_{1,{\bf a}} - f_2 \Vert^2_{L^2_\pi}\).
- Parameters:
f1 (
ParametricFunctionApproximation
) – function \(f_1\)f2 (
Function
orndarray
[\(m\)]) – function \(f_2\) or its functions valuesd (Distribution) – distribution \(\pi\)
params1 (dict) – parameters for function \(f_1\)
params2 (dict) – parameters for function \(f_2\)
qtype (int) – quadrature type to be used for the approximation of \(\mathbb{E}_{\pi}\)
qparams (object) – parameters necessary for the construction of the quadrature
x (
ndarray
[\(m,d\)]) – quadrature points used for the approximation of \(\mathbb{E}_{\pi}\)w (
ndarray
[\(m\)]) – quadrature weights used for the approximation of \(\mathbb{E}_{\pi}\)batch_size (int) – this defines whether to evaluate in batches or not. A size
1
correspond to a completely non-vectorized evaluation. A sizeNone
correspond to a completely vectorized one. (Note: ifnprocs > 1
, then the batch size defines the size of the batch for each process)mpi_pool (
mpi_map.MPI_Pool
) – pool of processes to be used for the evaluation off1
and ``f2`
- Returns:
(None) – the result is stored in
params1['hess_a_L2_misfit']
Note
The parameters
(qtype,qparams)
and(x,w)
are mutually exclusive, but one pair of them is necessary.Note
the dictionary
params1
must be provided