TransportMaps.Misc
¶
Module Contents¶
Classes¶
Loader of state provided to functions |
Functions¶
|
|
|
|
|
|
|
Set the log level for all existing and new objects related to the TransportMaps module |
|
|
|
|
|
Generate a total order multi-index |
|
|
|
|
|
|
|
Test the gradient and Hessian of a function using the Taylor test. |
|
Attributes¶
- TransportMaps.Misc.setLogLevel(level)[source]¶
Set the log level for all existing and new objects related to the TransportMaps module
- Parameters:
level (int) – logging level
- TransportMaps.Misc.generate_total_order_midxs(max_order_list)[source]¶
Generate a total order multi-index
Given the list of maximums \({\bf m}\), the returned set of multi-index \(I\) is such that \(\sum_j^d {\bf_i}_j <= max {\bf m}\) and \({\bf i}_j <= {\bf m}_j\).
- TransportMaps.Misc.total_time_cost_function(ncalls, nevals, teval, ncalls_x_solve=None, new_nx=None)[source]¶
- class TransportMaps.Misc.cached_tuple(commands=[], sub_cache_list=[], caching=True)[source]¶
Bases:
object
- TransportMaps.Misc.taylor_test(x, dx, f, gf=None, hf=None, ahf=None, h=0.0001, fungrad=False, caching=False, args={})[source]¶
Test the gradient and Hessian of a function using the Taylor test.
Using a Taylor expansion around \({\bf x}\), we have
\[f({\bf x}+h \delta{\bf x}) = f({\bf x}) + h (\nabla f({\bf x}))^\top \delta{\bf x} + \frac{h^2}{2} (\delta{\bf x})^\top \nabla^2 f({\bf x}) \delta{\bf x} + \mathcal{O}(h^3)\]Therefore
\[\vert f({\bf x}+h \delta{\bf x}) - f({\bf x}) - h (\nabla f({\bf x}))^\top \delta{\bf x} \vert = \mathcal{O}(h^2)\]and
\[\vert f({\bf x}+h \delta{\bf x}) - f({\bf x}) - h (\nabla f({\bf x}))^\top \delta{\bf x} - \frac{h^2}{2} (\delta{\bf x})^\top \nabla^2 f({\bf x}) \delta{\bf x} \vert = \mathcal{O}(h^3)\]- Parameters:
x (
ndarray
[\(m,d_x\)]) – evaluation points \({\bf x}\)dx (
ndarray
[\(m,d_x\)]) – perturbation direction \(\delta{\bf x}\)f (function) – function \({\bf x} \mapsto f({\bf x})\). If
fungrad==True
, thenf
is the mapping \({\bf x} \mapsto (\nabla f({\bf x}), f({\bf x}))\).gf (function) – gradient function \({\bf x} \mapsto \nabla f({\bf x})\)
hf (function) – Hessian function \({\bf x} \mapsto \nabla^2 f({\bf x})\)
ahf (function) – action of the Hessian function \({\bf x},\delta{\bf x} \mapsto (\nabla f({\bf x}))^\top \delta{\bf x}\)
h (float) – perturbation step
fungrad (bool) – whether
f
returns also the gradient or not.caching (bool) – whether to pass a cache dictionary to the functions.
args (dict) – arguments to be passed to functions