TransportMaps.Diagnostics

Classes

Inheritance diagram of TransportMaps.Diagnostics.AlignedConditionalsObject, TransportMaps.Diagnostics.RandomConditionalsObject, TransportMaps.Diagnostics.KLMinimizationValidator, TransportMaps.Diagnostics.SampleAverageApproximationKLMinimizationValidator, TransportMaps.Diagnostics.GradientChi2KLMinimizationValidator, TransportMaps.Diagnostics.GradientStabilityKLMinimizationValidator
Class Description
AlignedConditionalsObject  
RandomConditionalsObject  
KLMinimizationValidator  
SampleAverageApproximationKLMinimizationValidator  
GradientChi2KLMinimizationValidator  
GradientStabilityKLMinimizationValidator  

Functions

Function Description
computeAlignedConditionals Compute the conditionals aligned with the axis
plotAlignedConditionals Plot the conditionals aligned with the axis
computeRandomConditionals Compute the random conditionals
plotRandomConditionals Plot the random conditionals
plotAlignedSliceMap Plot the conditionals aligned with the axis
plotAlignedMarginals Plot the marginals aligned with the axis
plotAlignedScatters Plot the marginals aligned with the axis
plotGradXMap  
plotLinearityMap  
niceSpy  
compute_vals_variance_approx_kl Compute values necessary for the evaluation of the variance diagnostic variance_approx_kl()
variance_approx_kl Variance diagnositc

Documentation

class TransportMaps.Diagnostics.AlignedConditionalsObject(nplots, X_list, Y_list, pdfEval_list)[source]
TransportMaps.Diagnostics.computeAlignedConditionals(distribution, dimensions_vec=0, pointEval=None, range_vec=[-3, 3], numPointsXax=30, mpi_pool=None)[source]

Compute the conditionals aligned with the axis

Parameters:
  • distribution (Distribution) – distribution \(\pi\)
  • dimensions_vec (list of int) – list of dimensions to be displayed. Default 0: display 10 dimensions at most.
  • pointEval (ndarray [\(d\)]) – anchor point. Default is zero.
  • range_vec (list) – range to be displayed. Either a list [2] of integers, or a list [d] of list [2] of integers.
  • numPointsXax (int) – number of points for each axis.
  • mpi_pool (mpi_map.MPI_Pool) – pool of processes
Returns:

(AlignedConditionalsObject) – object

storing all the necessary evaluated values

TransportMaps.Diagnostics.plotAlignedConditionals(distribution=None, data=None, dimensions_vec=0, pointEval=None, range_vec=[-3, 3], numPointsXax=30, numCont=15, figname=None, show_flag=True, show_title=False, title='Aligned conditionals', vartitles=None, fig=None, mpi_pool=None)[source]

Plot the conditionals aligned with the axis

Parameters:
  • distribution (Distribution) – distribution \(\pi\)
  • data (AlignedConditionalsObject) – output of computeAlignedConditionals()
  • dimensions_vec (list of int) – list of dimensions to be displayed. Default 0: display 10 dimensions at most.
  • pointEval (ndarray [\(d\)]) – anchor point. Default is zero.
  • range_vec (list) – range to be displayed. Either a list [2] of integers, or a list [d] of list [2] of integers.
  • numPointsXax (int) – number of points for each axis.
  • numCont (int) – number of contours in the contour plots.
  • figname (str) – if defined, store the figure in the provided path.
  • show_flag (bool) – whether to show the plot before returning
  • show_title (bool) – whether to show the title
  • title (str) – title for the figure
  • vartitles (list) – list of titles for each variable
  • fig (figure) – matplotlib figure object if one wants to re-useit.
  • mpi_pool (mpi_map.MPI_Pool) – pool of processes
class TransportMaps.Diagnostics.RandomConditionalsObject(nplots, X_list, Y_list, pdfEval_list)[source]
TransportMaps.Diagnostics.computeRandomConditionals(distribution, num_conditionalsXax=0, pointEval=None, range_vec=[-3, 3], numPointsXax=30, mpi_pool=None)[source]

Compute the random conditionals

Parameters:
  • distribution (Distribution) – distribution \(\pi\)
  • num_conditionalsXax (int) – number of random conditionals per axis
  • pointEval (ndarray`[:math:`d]) – anchor point. Default is zero.
  • range_vec (:class:`tuple`[2]) – range to be displayed.
  • numPointsXax (int) – number of points for each axis.
  • mpi_pool (mpi_map.MPI_Pool) – pool of processes
TransportMaps.Diagnostics.plotRandomConditionals(distribution=None, data=None, num_conditionalsXax=0, pointEval=None, range_vec=[-3, 3], numPointsXax=30, numCont=15, figname=None, show_flag=True, show_title=False, title='Random conditionals', fig=None, mpi_pool=None)[source]

Plot the random conditionals

Parameters:
  • distribution (Distribution) – distribution \(\pi\)
  • data (RandomConditionalsObject) – output of computeRandomConditionals()
  • num_conditionalsXax (int) – number of random conditionals per axis
  • pointEval (ndarray`[:math:`d]) – anchor point. Default is zero.
  • range_vec (:class:`tuple`[2]) – range to be displayed.
  • numPointsXax (int) – number of points for each axis.
  • numCont (int) – number of contours in the contour plots.
  • figname (str) – if defined, store the figure in the provided path.
  • show_flag (bool) – whether to show the plot before returning
  • show_title (bool) – whether to show the title
  • fig (figure) – matplotlib figure object if one wants to re-use it.
  • mpi_pool (mpi_map.MPI_Pool) – pool of processes
TransportMaps.Diagnostics.plotAlignedSliceMap(tr_map, dimensions_vec=0, pointEval=0, range_vec=[-4, 4], numPointsXax=30, numCont=30, figname=None, show_flag=True, tickslabelsize=6, show_title=False, fig=None, mpi_pool=None)[source]

Plot the conditionals aligned with the axis

Parameters:
  • tr_map (TriangularTransportMap) – Triangular transport map
  • dimensions_vec (list of int) – list of dimensions to be displayed. Default 0: display 10 dimensions at most.
  • pointEval (ndarray`[:math:`d]) – anchor point. Default is zero.
  • range_vec (list) – range to be displayed. Either a list [2] of integers, or a list [d] of list [2] of integers.
  • numPointsXax (int) – number of points for each axis.
  • numCont (int) – number of contours in the contour plots.
  • figname (str) – if defined, store the figure in the provided path.
  • show_flag (bool) – whether to show the plot before returning
  • show_title (bool) – whether to show a title on top of the figure
  • fig (figure) – matplotlib figure object if one wants to re-use it.
  • mpi_pool (mpi_map.MPI_Pool) – pool of processes
TransportMaps.Diagnostics.plotAlignedMarginals(mat_points, mat_points2=None, dimensions_vec=0, range_vec=None, colormap='jet', white_background=True, levels=10, do_diag=True, figname=None, show_flag=True, show_axis=False, title='Marginals along coordinate axes', vartitles=None, fig=None, mpi_pool=None)[source]

Plot the marginals aligned with the axis

Parameters:
  • mat_points (ndarray) – first dataset
  • mat_points2 (ndarray) – second dataset (optional)
  • dimensions_vec (list of int) – list of dimensions to be displayed. Default 0: display 10 dimensions at most.
  • range_vec (list of tuple [2]) – range to be displayed.
  • colormap (str) – colormap to be used
  • white_background (bool) – whether to have a white background of to use the last layer of the colormap
  • levels (int or list) – number of levels to be displayed or list of values defining the levels.
  • do_diag (bool) – whether to include the one dimensional marginals on the diagonal
  • numPointsXax (int) – number of points for each axis.
  • numCont (int) – number of contours in the contour plots.
  • figname (str) – if defined, store the figure in the provided path.
  • show_flag (bool) – whether to show the plot before returning
  • show_axis (bool) – whether to show the axis of the plot
  • vartitles (list) – list of titles for each variable
  • fig (figure) – matplotlib figure object if one wants to re-use it.
  • mpi_pool (mpi_map.MPI_Pool) – pool of processes
Returns:

(fig, list, list, list, list) – figure handle and list of handles to every subplot,

and three lists containing xx, yy, zz values

TransportMaps.Diagnostics.plotAlignedScatters(mat_points, dimensions_vec=0, do_diag=True, s=5, bins=10, show_axis=True, axis_fmt=None, figname=None, show_flag=True, show_title=False, title='Marginals along coordinate axes', vartitles=None, fig=None)[source]

Plot the marginals aligned with the axis

Parameters:
  • mat_points (ndarray [\(m,d\)]) – samples
  • dimensions_vec (list of int) – list of dimensions to be displayed. Default 0: display 10 dimensions at most.
  • do_diag (bool) – whether to include the one dimensional marginals on the diagonal
  • s (int) – size of scatter points
  • bins (int) – number of bins for one dimensional plots
  • show_axis (bool) – whether to show the axis
  • axis_fmt (list) – list of matplotlib formatters
  • figname (str) – if defined, store the figure in the provided path.
  • show_flag (bool) – whether to show the plot before returning
  • show_title (bool) – whether to show the title
  • title (str) – title for the figure
  • vartitles (list) – list of titles for each variable
  • fig (figure) – matplotlib figure object if one wants to re-use it.
TransportMaps.Diagnostics.compute_vals_variance_approx_kl(d1, d2, params1=None, params2=None, x=None, mpi_pool_tuple=(None, None), import_set=set())[source]

Compute values necessary for the evaluation of the variance diagnostic variance_approx_kl()

Returns:
(tuple [2] ndarray [\(m\)]) –
computed values of \(\log\pi_1\) and \(\log\pi_2\)
TransportMaps.Diagnostics.variance_approx_kl(d1, d2, params1=None, params2=None, vals_d1=None, vals_d2=None, qtype=None, qparams=None, x=None, w=None, mpi_pool_tuple=(None, None), import_set=set())[source]

Variance diagnositc

Statistical analysis of the variance diagnostic

\[\mathcal{D}_{KL}(\pi_1 \Vert \pi_2) \approx \frac{1}{2} \mathbb{V}_{\pi_1} \left( \log \frac{\pi_1}{\pi_2}\right)\]
Parameters:
  • d1 (Distribution) – distribution \(\pi_1\)
  • d2 (Distribution) – distribution \(\pi_2\)
  • params1 (dict) – parameters for distribution \(\pi_1\)
  • params2 (dict) – parameters for distribution \(\pi_2\)
  • vals_d1 (ndarray [\(m\)]) – computed values of \(\log\pi_1\)
  • vals_d2 (ndarray [\(m\)]) – computed values of:math:logpi_2
  • qtype (int) – quadrature type to be used for the approximation of \(\mathbb{E}_{\pi_1}\)
  • qparams (object) – parameters necessary for the construction of the quadrature
  • x (ndarray [\(m,d\)]) – quadrature points used for the approximation of \(\mathbb{E}_{\pi_1}\)
  • w (ndarray [\(m\)]) – quadrature weights used for the approximation of \(\mathbb{E}_{\pi_1}\)
  • mpi_pool_tuple (tuple [2] of mpi_map.MPI_Pool) – pool of processes to be used for the evaluation of d1 and d2
  • import_set (set) – list of couples (module_name,as_field) to be imported as import module_name as as_field (for MPI purposes)

Note

The parameters (qtype,qparams) and (x,w) are mutually exclusive, but one pair of them is necessary.

class TransportMaps.Diagnostics.KLMinimizationValidator(eps_sp, cost_function, max_cost, eps_sp_rel=0, max_nsamps=inf, stop_on_fcast=False)[source]
refinement(base_distribution, pull_tar, qtype, qparams, ref_params)[source]
Returns:
(tuple) – containing the new qparams and the
number of points corresponding to it.
class TransportMaps.Diagnostics.SampleAverageApproximationKLMinimizationValidator(eps_sp_rel, eps_sp_abs, cost_function, max_cost, max_nsamps=inf, stop_on_fcast=False, upper_mult=10, lower_n=2, alpha=0.05, lmb_def=2, lmb_max=10)[source]
refinement(base_distribution, pull_tar, qtype, qparams, err_mag, ref_params)[source]

Returns: (tuple) – containing the new qparams and the

number of points corresponding to it.
class TransportMaps.Diagnostics.GradientChi2KLMinimizationValidator(eps_sp, cost_function, max_cost, max_nsamps=inf, stop_on_fcast=False, n_grad_samps=10, n_bootstrap=None, alpha=0.95, lmb_def=2, lmb_max=10, fungrad=False)[source]
refinement(base_distribution, pull_tar, qtype, qparams, ref_params)[source]

Returns: (tuple) – containing the new qparams and the

number of points corresponding to it.
class TransportMaps.Diagnostics.GradientStabilityKLMinimizationValidator(eps_sp, cost_function, max_cost, max_nsamps=inf, stop_on_fcast=False, n_grad_samps=10, n_gap_resampling=10, beta=0.95, gamma=0.05, lmb_def=2, lmb_max=10, fungrad=False)[source]
refinement(base_distribution, pull_tar, qtype, qparams, ref_params)[source]

Returns: (tuple) – containing the new qparams and the

number of points corresponding to it.