<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>TransportMaps Q&amp;A - Recent questions</title>
<link>https://transportmaps.mit.edu/qa/index.php?qa=questions</link>
<description>Powered by Question2Answer</description>
<item>
<title>Code to extract sparse transport support from Markov Graph</title>
<link>https://transportmaps.mit.edu/qa/index.php?qa=503&amp;qa_1=code-to-extract-sparse-transport-support-from-markov-graph</link>
<description>Hi,&lt;br /&gt;
&lt;br /&gt;
If the target map satisfies a marjov random field structure, then the inverse transport map will be sparse. I know how to extract the nonzero components from the MRF. But I was wondering if you had code to do this automatically? I see in this example: https://transportmaps.mit.edu/docs/example-inverse-stochastic-volatility-6d.html?highlight=conditional%20independence You do it by hand. &lt;br /&gt;
&lt;br /&gt;
I just wanted to check if you already wrote this code before doing it myself.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
Thanks,&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
Patrick</description>
<category>usage</category>
<guid isPermaLink="true">https://transportmaps.mit.edu/qa/index.php?qa=503&amp;qa_1=code-to-extract-sparse-transport-support-from-markov-graph</guid>
<pubDate>Thu, 09 Feb 2023 15:42:08 +0000</pubDate>
</item>
<item>
<title>applying optimal tranport map to filtering theory</title>
<link>https://transportmaps.mit.edu/qa/index.php?qa=251&amp;qa_1=applying-optimal-tranport-map-to-filtering-theory</link>
<description>Hi there,&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;I have seen your team has done a lot of work about developing parametric approximations of the Knothe-Rosenblatt rearrangement (Moselhy and Marzouk, 2012) to design a good map. I just want to know how many ways until now we can select to applying this Bayesian inference technology to non-linear filter .&lt;br /&gt;
&lt;br /&gt;
Pengcheng</description>
<category>theory</category>
<guid isPermaLink="true">https://transportmaps.mit.edu/qa/index.php?qa=251&amp;qa_1=applying-optimal-tranport-map-to-filtering-theory</guid>
<pubDate>Fri, 16 Aug 2019 15:21:44 +0000</pubDate>
</item>
<item>
<title>constructing transport map from given samples and use it to get/samples from standard normal</title>
<link>https://transportmaps.mit.edu/qa/index.php?qa=205&amp;qa_1=constructing-transport-given-samples-samples-standard-normal</link>
<description>&lt;p&gt;Hello&lt;/p&gt;&lt;p&gt;I want to construct&amp;nbsp; a map from given samples ( from unknown distrubution) that has standard normal distribution as target distribution so that I can get standard normal samples when samples from unknown distribution are&amp;nbsp; plugged into the map.&lt;/p&gt;&lt;p&gt;I followed the tutorial example: Inverse transport from samples,&amp;nbsp; where samples from Gumbel distribution&amp;nbsp; are used to construct the map:Gumbel to Standard normal. However in the code, I could not understand&amp;nbsp; in the following block&amp;nbsp; ( where map is constructed):&lt;/p&gt;&lt;p&gt;####################################################&lt;/p&gt;&lt;pre&gt;S = TM.Default_IsotropicIntegratedSquaredTriangularTransportMap(
    1, 3, &amp;#39;total&amp;#39;)
rho = DIST.StandardNormalDistribution(1)
push_L_pi = DIST.PushForwardTransportMapDistribution(L, pi)
push_SL_pi = DIST.PushForwardTransportMapDistribution(
    S, push_L_pi)
qtype = 0      # Monte-Carlo quadratures from pi
qparams = 500  # Number of MC points
reg = None     # No regularization
tol = 1e-3     # Optimization tolerance
ders = 2       # Use gradient and Hessian
log = push_SL_pi.minimize_kl_divergence(
    rho, qtype=qtype, qparams=qparams, regularization=reg,
    tol=tol, ders=ders)
#########################################################
specifically the line  
&amp;quot;push_L_pi = DIST.PushForwardTransportMapDistribution(L, pi)&amp;quot;.
Here we are explicitly specifying the &amp;quot;Gumbel distribution&amp;quot; ,defined by pi, instead of the samples, arent we supposed to not know the distribution in the first place ( instead we only have samples, like the situation that I have i.e. only samples without having any knowledge about its distribution)

Could you kindly clear my misunderstanding,if possible with an example code.  I would be very grateful

thanks

saad 
&lt;/pre&gt;</description>
<category>theory</category>
<guid isPermaLink="true">https://transportmaps.mit.edu/qa/index.php?qa=205&amp;qa_1=constructing-transport-given-samples-samples-standard-normal</guid>
<pubDate>Tue, 23 Jul 2019 14:55:49 +0000</pubDate>
</item>
<item>
<title>I get an MPI error for Inverse Transport.</title>
<link>https://transportmaps.mit.edu/qa/index.php?qa=120&amp;qa_1=i-get-an-mpi-error-for-inverse-transport</link>
<description>&lt;p&gt;Hi there,&lt;/p&gt;&lt;p&gt;I am very much interested in using the parallel setup for the inverse transport&amp;nbsp;computation. I have the most up-to-date installation of TM, mpi4py and mpi_map. I can also successfully run the Example 0&amp;nbsp;(direct transport) in the MPI tutorial:&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;# Example 0: Minimization of the KL-divergence and sampling
nprocs = 2
# Define target distribution
mu = 3.
beta = 4.
target_density = DIST.GumbelDistribution(mu,beta)
# Define base density
base_density = DIST.StandardNormalDistribution(1)
# Define approximating transport map
order = 5
tm_approx = TM.Default_IsotropicIntegratedExponentialTriangularTransportMap(1, order, 'full')
# Define approximating density
tm_density = DIST.PushForwardTransportMapDistribution(tm_approx, base_density)
# Start pool of processes
mpi_pool = TM.get_mpi_pool()
mpi_pool.start(nprocs)

# Solve and sample
try:
    qtype = 0      # Gauss quadrature
    qparams = 1000 # Quadrature order
    reg = None     # No regularization
    tol = 1e-8    # Optimization tolerance
    ders = 1       # Use gradient and Hessian
    log_entry_solve = tm_density.minimize_kl_divergence(
        target_density, qtype=qtype, qparams=qparams,
        regularization=reg, tol=tol, ders=ders,
        mpi_pool=mpi_pool) 
finally:
    mpi_pool.stop()
log_entry_solve&lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;code class=&quot;language-xml&quot;&gt;2019-03-20 13:21:46 WARNING:mpi_map: MPI_Pool_v2.alloc_dmem DEPRECATED since v&amp;gt;2.4. Use MPI_Pool_v2.bcast_dmem instead.
2019-03-20 13:21:46 WARNING:mpi_map: MPI_Pool_v2.alloc_dmem DEPRECATED since v&amp;gt;2.4. Use MPI_Pool_v2.bcast_dmem instead.
Out[16]:
{'success': True,
 'message': 'Optimization terminated successfully.',
 'fval': 1.4265539022688227,
 'nit': 40,
 'n_fun_ev': 41,
 'n_jac_ev': 41,
.......&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Now when I try to replicate the same process for the inverse map estimation using the tutorial example on Gumbel distribution, I get an error:&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;import TransportMaps.Distributions as DIST


class GumbelDistribution(DIST.Distribution):
    def __init__(self, mu, beta):
        super(GumbelDistribution,self).__init__(1)
        self.mu = mu
        self.beta = beta
        self.dist = stats.gumbel_r(loc=mu, scale=beta)
    def pdf(self, x, params=None):
        return self.dist.pdf(x).flatten()
    def quadrature(self, qtype, qparams, *args, **kwargs):
        if qtype == 0: # Monte-Carlo
            x = self.dist.rvs(qparams)[:,np.newaxis]
            w = np.ones(qparams)/float(qparams)
        else: raise ValueError(&quot;Quadrature not defined&quot;)
        return (x, w)

mu = 3.
beta = 4.
pi = GumbelDistribution(mu,beta)
x, w = pi.quadrature(0, 5000)

# linear adjustment
xmax = np.max(x)
xmin = np.min(x)
a = np.array([ 4*(xmin+xmax)/(xmin-xmax) ])
b = np.array([ 8./(xmax-xmin) ])
L = MAPS.FrozenLinearDiagonalTransportMap(a,b)


S = TM.Default_IsotropicIntegratedSquaredTriangularTransportMap(
    1, 3, 'total')
rho = DIST.StandardNormalDistribution(1)
push_L_pi = DIST.PushForwardTransportMapDistribution(L, pi)
push_SL_pi = DIST.PushForwardTransportMapDistribution(
    S, push_L_pi)

# Start pool of processes
nprocs = 2
mpi_pool = TM.get_mpi_pool()
mpi_pool.start(nprocs)

# Solve and sample
try:
    qtype = 0      # Monte-Carlo quadratures from pi
    qparams = 500  # Number of MC points
    reg = None     # No regularization
    tol = 1e-3     # Optimization tolerance
    ders = 2       # Use gradient and Hessian
    log = push_SL_pi.minimize_kl_divergence(
        rho, qtype=qtype, qparams=qparams, regularization=reg,
        tol=tol, ders=ders,mpi_pool=mpi_pool)

finally:
    mpi_pool.stop()
    
SL = MAPS.CompositeMap(S,L)
pull_SL_rho = DIST.PullBackTransportMapDistribution(SL, rho)
log&lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;code&gt;---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
&amp;lt;ipython-input-15-d1561f88f5fc&amp;gt; in &amp;lt;module&amp;gt;
     54     log = push_SL_pi.minimize_kl_divergence(
     55         rho, qtype=qtype, qparams=qparams, regularization=reg,
---&amp;gt; 56         tol=tol, ders=ders,mpi_pool=mpi_pool)
     57 
     58 finally:

~/anaconda3/lib/python3.7/site-packages/TransportMaps/Distributions/TransportMapDistributions.py in minimize_kl_divergence(self, tar, qtype, qparams, parbase, partar, x0, regularization, tol, maxit, ders, fungrad, hessact, batch_size, mpi_pool, grad_check, hess_check)
    525             tol=tol, maxit=maxit, ders=ders, fungrad=fungrad, hessact=hessact,
    526             batch_size=batch_size,
--&amp;gt; 527             mpi_pool=mpi_pool, grad_check=grad_check, hess_check=hess_check)
    528         return log
    529 

~/anaconda3/lib/python3.7/site-packages/TransportMaps/Maps/TriangularTransportMapBase.py in minimize_kl_divergence(self, d1, d2, qtype, qparams, x, w, params_d1, params_d2, x0, regularization, tol, maxit, ders, fungrad, hessact, precomp_type, batch_size, mpi_pool, grad_check, hess_check)
   1018             print('mpi_pool_list is '+str(mpi_pool_list)) # added by Hassan
   1019             for i, (a, avars, batch_size, mpi_pool) in enumerate(zip(
-&amp;gt; 1020                     self.approx_list, self.active_vars, batch_size_list, mpi_pool_list)):
   1021                 f = ProductDistributionParametricPullbackComponentFunction(
   1022                     a, d2.base_distribution.get_component([i]) )

TypeError: zip argument #4 must support iteration&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;I print out the argument #4 and get&lt;/p&gt;&lt;pre&gt;mpi_pool_list is &amp;lt;mpi_map.misc.MPI_Pool_v2 object at 0x7fa08444b8d0&amp;gt;.&lt;/pre&gt;&lt;pre&gt;&lt;span style=&quot;font-family:Arial,Helvetica,sans-serif&quot;&gt;I have tried this for my own data in 2D and 3D, and get the same error. &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=&quot;font-family:Arial,Helvetica,sans-serif&quot;&gt;I have studied the turorial on MPI, but still it is still beyond me to see where this comes from. &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=&quot;font-family:Arial,Helvetica,sans-serif&quot;&gt;Will appreciate if you have suggestions or thoughts.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;
&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;</description>
<category>usage</category>
<guid isPermaLink="true">https://transportmaps.mit.edu/qa/index.php?qa=120&amp;qa_1=i-get-an-mpi-error-for-inverse-transport</guid>
<pubDate>Wed, 20 Mar 2019 17:40:21 +0000</pubDate>
</item>
<item>
<title>Inverse map computational speed</title>
<link>https://transportmaps.mit.edu/qa/index.php?qa=105&amp;qa_1=inverse-map-computational-speed</link>
<description>&lt;p&gt;I am using the TransportMaps (TM) for density estimation: I have 1M data points with 2 features and use TM to&amp;nbsp;compute the map S which takes my distribution to the standard normal distribution. Computing S takes some reasonable time as shown in the log below. Now I need to compute the inverse map S^{-1}&amp;nbsp;for large data sets (~10M) as well, but when I use the method S.inverse() to map those values back to my original space it takes way longer, in fact, about 100 times longer. I have also tried creating another object &amp;quot;T=TransportMaps.Maps.TransportMapBase.InverseTransportMap(S)&amp;quot; and use T, but it takes similarly long. Below I share a log for computing S using 1M and then trying to compute the inverse map for some 1M points.&lt;/p&gt;&lt;p&gt;My question is wether I am missing something e.g.&amp;nbsp;there is a way in TM to compute inverse maps much faster?&amp;nbsp;If not I am thinking of using&amp;nbsp;e.g. K-neighbor regression for the inverse map, any tips or thoughts on that?&lt;/p&gt;&lt;p&gt;bests,&lt;/p&gt;&lt;p&gt;Hassan&lt;/p&gt;&lt;p&gt;runing log (OS: Fedora release 28, 32 cores and 128G memory - didn&amp;#39;t use MPI tho):&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;language-html&quot;&gt;Polynomial order: 4
Number of coefficients: 20
==========================
2019-03-04 20:41:38 INFO: TM.MonotonicIntegratedSquaredApproximation: Optimization terminated successfully
2019-03-04 20:41:38 INFO: TM.MonotonicIntegratedSquaredApproximation:   Function value:          1.412383
2019-03-04 20:41:38 INFO: TM.MonotonicIntegratedSquaredApproximation:   Norm of the Jacobian:    0.000000
2019-03-04 20:41:38 INFO: TM.MonotonicIntegratedSquaredApproximation:   Number of iterations:         5
2019-03-04 20:41:38 INFO: TM.MonotonicIntegratedSquaredApproximation:   N. function evaluations:      6
2019-03-04 20:41:38 INFO: TM.MonotonicIntegratedSquaredApproximation:   N. Jacobian evaluations:     10
2019-03-04 20:41:38 INFO: TM.MonotonicIntegratedSquaredApproximation:   N. Hessian evaluations:       5
2019-03-04 20:45:04 INFO: TM.MonotonicIntegratedSquaredApproximation: Optimization terminated successfully
2019-03-04 20:45:04 INFO: TM.MonotonicIntegratedSquaredApproximation:   Function value:          1.009555
2019-03-04 20:45:04 INFO: TM.MonotonicIntegratedSquaredApproximation:   Norm of the Jacobian:    0.000000
2019-03-04 20:45:04 INFO: TM.MonotonicIntegratedSquaredApproximation:   Number of iterations:        14
2019-03-04 20:45:04 INFO: TM.MonotonicIntegratedSquaredApproximation:   N. function evaluations:     16
2019-03-04 20:45:04 INFO: TM.MonotonicIntegratedSquaredApproximation:   N. Jacobian evaluations:     29
2019-03-04 20:45:04 INFO: TM.MonotonicIntegratedSquaredApproximation:   N. Hessian evaluations:      14

......
......

Computing inverse transport map for 1000001 points took 27807.015720441937 seconds&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<category>usage</category>
<guid isPermaLink="true">https://transportmaps.mit.edu/qa/index.php?qa=105&amp;qa_1=inverse-map-computational-speed</guid>
<pubDate>Tue, 05 Mar 2019 16:57:15 +0000</pubDate>
</item>
<item>
<title>I got an error &quot;'NoneType' object has no attribute 'reset_counters'&quot;</title>
<link>https://transportmaps.mit.edu/qa/index.php?qa=99&amp;qa_1=got-error-nonetype-object-has-no-attribute-reset_counters</link>
<description>Hi:&lt;br /&gt;
&lt;br /&gt;
When I use TransportMaps for hidden Markov model, I got an error &amp;quot;AttributeError: 'NoneType' object has no attribute 'reset_counters'&amp;quot; when I run &amp;nbsp;push_R0_rho.minimize_kl_divergence(). The thing is that if all the observations are not missing value, then the error didn't appear. But when the observation has some missing value, for example, y[1] = None, then the error occur. Where is the problem?</description>
<category>usage</category>
<guid isPermaLink="true">https://transportmaps.mit.edu/qa/index.php?qa=99&amp;qa_1=got-error-nonetype-object-has-no-attribute-reset_counters</guid>
<pubDate>Sat, 09 Feb 2019 13:22:39 +0000</pubDate>
</item>
<item>
<title>import error and installation of scikit-sparse</title>
<link>https://transportmaps.mit.edu/qa/index.php?qa=85&amp;qa_1=import-error-and-installation-of-scikit-sparse</link>
<description>&lt;p&gt;&lt;span style=&quot;font-size:14px&quot;&gt;Hi there,&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size:14px&quot;&gt;I have installed TransportMaps on Mac (Mojave&amp;nbsp;+ Anaconda Python) but when I try to import it in Jupyter I get the error below.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size:14px&quot;&gt;I suspect the problem is with my installation: one of the errors in my installation was that&amp;nbsp;&lt;/span&gt;scikit-sparse&amp;nbsp;could not be installed due to &amp;quot;cholmod.h file not found&amp;quot;.&amp;nbsp;I solved that error via using &amp;quot;conda install -c conda-forge scikit-sparse&amp;quot; which apparently worked for installation of TM. (this solution was suggested here: https://github.com/scikit-sparse/scikit-sparse/issues/32 )&lt;/p&gt;&lt;p&gt;Now I see that the TM import error (at the bottom of log) relates to sksparse and cholmod.&lt;/p&gt;&lt;p&gt;Do you have any suggestions on how to get past this?&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;bests,&lt;/p&gt;&lt;p&gt;Hassan&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;pre&gt;============================================================================&lt;/pre&gt;&lt;pre&gt;ImportError                               Traceback (most recent call last)
&amp;lt;ipython-input-4-938b228a6841&amp;gt; in &amp;lt;module&amp;gt;()
----&amp;gt; 1 import TransportMaps as tm

....&lt;/pre&gt;&lt;pre&gt;/anaconda3/lib/python3.6/site-packages/TransportMaps-2.0b2-py3.6.egg/TransportMaps/Algorithms/SparsityIdentification/__init__.py in &amp;lt;module&amp;gt;()
      1 from . import SparsityIdentificationNonGaussian
      2 from .SparsityIdentificationNonGaussian import *
----&amp;gt; 3 from . import NodeOrdering
      4 from .NodeOrdering import *
      5 from . import GeneralizedPrecision

/anaconda3/lib/python3.6/site-packages/TransportMaps-2.0b2-py3.6.egg/TransportMaps/Algorithms/SparsityIdentification/NodeOrdering.py in &amp;lt;module&amp;gt;()
      3 import copy
      4 
----&amp;gt; 5 from sksparse.cholmod import cholesky
      6 from scipy.sparse import csc_matrix
      7 import itertools

ImportError: dlopen(/anaconda3/lib/python3.6/site-packages/sksparse/cholmod.cpython-36m-darwin.so, 2): Library not loaded: @rpath/libcholmod.3.0.11.dylib
  Referenced from: /anaconda3/lib/python3.6/site-packages/sksparse/cholmod.cpython-36m-darwin.so
  Reason: image not found&lt;/pre&gt;&lt;pre&gt;==================================================================&lt;/pre&gt;</description>
<category>installation</category>
<guid isPermaLink="true">https://transportmaps.mit.edu/qa/index.php?qa=85&amp;qa_1=import-error-and-installation-of-scikit-sparse</guid>
<pubDate>Fri, 09 Nov 2018 14:33:09 +0000</pubDate>
</item>
<item>
<title>Is the algorithm in 'Transport map accelerated Markov chain Monte Carlo' included?</title>
<link>https://transportmaps.mit.edu/qa/index.php?qa=54&amp;qa_1=algorithm-transport-accelerated-markov-chain-carlo-included</link>
<description>&lt;p&gt;Hi&lt;/p&gt;&lt;p&gt;I&amp;nbsp;was wondering if there is any tutorial&amp;nbsp;on how to set up a setting simialr to &amp;quot;Transport preconditioned MCMC&amp;#39;&amp;nbsp;similar to [1].&amp;nbsp;I checked the tutorial&amp;nbsp;but it doesn&amp;#39;t seem any of those are related.&lt;/p&gt;&lt;p&gt;f that setting is possible with &lt;a target=&quot;_blank&quot; rel=&quot;nofollow&quot; href=&quot;https://transportmaps.mit.edu/&quot;&gt;TransportMaps&lt;/a&gt;, I&amp;nbsp;would be thankful if you provide an&amp;nbsp;tutorial or some advice.&lt;/p&gt;&lt;p&gt;[1] Matthew Parno and Youssef Marzouk. Transport map accelerated Markov chain Monte Carlo.&amp;nbsp;&lt;em&gt;submitted&lt;/em&gt;, pages 1&amp;ndash;50, 2014.&amp;nbsp;&lt;/p&gt;</description>
<category>usage</category>
<guid isPermaLink="true">https://transportmaps.mit.edu/qa/index.php?qa=54&amp;qa_1=algorithm-transport-accelerated-markov-chain-carlo-included</guid>
<pubDate>Mon, 06 Aug 2018 13:46:10 +0000</pubDate>
</item>
<item>
<title>I got an error &quot;NameError: name 'mpl' is not defined&quot; when I ran the &quot;Diagnostics and unbiased sampling&quot; in tutorial</title>
<link>https://transportmaps.mit.edu/qa/index.php?qa=48&amp;qa_1=nameerror-defined-diagnostics-unbiased-sampling-tutorial</link>
<description>&lt;p&gt;&lt;span style=&quot;font-size:10px&quot;&gt;&lt;span style=&quot;font-family:Arial,Helvetica,sans-serif&quot;&gt;Hi,&lt;br&gt;&lt;br&gt;I ran the &amp;quot;Diagnostics and unbiased sampling&amp;quot; in tutorial but I got an error &amp;quot;NameError: name &amp;#39;mpl&amp;#39; is not defined&amp;quot; when I tried to implement the algorithm in [29] box.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size:10px&quot;&gt;&lt;span style=&quot;font-family:Arial,Helvetica,sans-serif&quot;&gt;The algorithm in [29] box:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;&lt;span style=&quot;font-size:10px&quot;&gt;&lt;span style=&quot;font-family:Arial,Helvetica,sans-serif&quot;&gt;fig = plt.figure(figsize=(6,6));
fig = DIAG.plotAlignedScatters(
    yt3[5000:7000,:], s=1, bins=50, vartitles=varstr,
    fig=fig, show_flag=False)&lt;/span&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre&gt;
&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span style=&quot;font-size:10px&quot;&gt;&lt;span style=&quot;font-family:Arial,Helvetica,sans-serif&quot;&gt;I would very appreciate if you can find some time to answer me.
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=&quot;font-size:10px&quot;&gt;&lt;span style=&quot;font-family:Arial,Helvetica,sans-serif&quot;&gt;Best,&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=&quot;font-size:10px&quot;&gt;&lt;span style=&quot;font-family:Arial,Helvetica,sans-serif&quot;&gt;Aaron&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;</description>
<category>usage</category>
<guid isPermaLink="true">https://transportmaps.mit.edu/qa/index.php?qa=48&amp;qa_1=nameerror-defined-diagnostics-unbiased-sampling-tutorial</guid>
<pubDate>Thu, 02 Aug 2018 07:15:42 +0000</pubDate>
</item>
<item>
<title>I got an error &quot;log_pdf() got an unexpected keyword argument 'cache'&quot; when I ran the tutorial</title>
<link>https://transportmaps.mit.edu/qa/index.php?qa=44&amp;qa_1=error-log_pdf-unexpected-keyword-argument-cache-tutorial</link>
<description>Hi,&lt;br /&gt;
&lt;br /&gt;
I ran the &amp;quot;Laplace approximation&amp;quot; in tutorial but I I got an error &amp;quot;log_pdf() got an unexpected keyword argument 'cache'&amp;quot;.</description>
<category>usage</category>
<guid isPermaLink="true">https://transportmaps.mit.edu/qa/index.php?qa=44&amp;qa_1=error-log_pdf-unexpected-keyword-argument-cache-tutorial</guid>
<pubDate>Wed, 01 Aug 2018 13:06:07 +0000</pubDate>
</item>
<item>
<title>Composition of maps and order adaptativity</title>
<link>https://transportmaps.mit.edu/qa/index.php?qa=36&amp;qa_1=composition-of-maps-and-order-adaptativity</link>
<description>Hi,&lt;br /&gt;
&lt;br /&gt;
I am using the TransportMaps library to solve sequential inference problems. One problem I'm facing is the adaptivity of map orders. I currently build the tranport maps by iteration on the maps order and monitoring of the variance diagnostic. However, I'm very interested in the composition of low-order maps described in ref [TM1] &amp;quot;Bayesian inference with optimal maps&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Hence, I have some questions about it:&lt;br /&gt;
&lt;br /&gt;
- How to set the progression of the noise covariance to build intermediate maps ?&lt;br /&gt;
- How to be sure that the first map is close to a normal distribution in order to have a low rank coupling ?&lt;br /&gt;
- If the map is unscaled due to a too large variance, should I also add a linear map ?&lt;br /&gt;
- Is this approach always efficient in terms of computation time in comparison to a direct map with high order degree (with non decomposable density) ?&lt;br /&gt;
&lt;br /&gt;
Best regards,&lt;br /&gt;
&lt;br /&gt;
Paul.</description>
<category>theory</category>
<guid isPermaLink="true">https://transportmaps.mit.edu/qa/index.php?qa=36&amp;qa_1=composition-of-maps-and-order-adaptativity</guid>
<pubDate>Wed, 20 Jun 2018 13:54:22 +0000</pubDate>
</item>
<item>
<title>I got an error &quot;NameError: free variable 'gfk' referenced before assignment in enclosing scope&quot;</title>
<link>https://transportmaps.mit.edu/qa/index.php?qa=29&amp;qa_1=nameerror-variable-referenced-before-assignment-enclosing</link>
<description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;&lt;p&gt;I am trying to use your TransportMaps library to&amp;nbsp;track an airplane using ground based radar. However, I got an error :&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap&quot;&gt;NameError: free variable &amp;#39;gfk&amp;#39; referenced before assignment in enclosing scope.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;I would very appreciate if you can find some time to answer me.&lt;/p&gt;&lt;p&gt;Best regards,&lt;/p&gt;&lt;p&gt;Jacks.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Here the python version information:&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;import sys, scipy, numpy,TransportMaps; print(scipy.__version__, numpy.__version__, sys.version_info,TransportMaps.__version__)
('1.0.0', '1.14.0', sys.version_info(major=2, minor=7, micro=12, releaselevel='final', serial=0), '1.1b2')&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&amp;nbsp;Here the python script I use:&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;import numpy as np
import TransportMaps.Distributions as DIST
import TransportMaps.Maps as MAPS
import TransportMaps as TM
import TransportMaps.Distributions.Decomposable as DISTDEC
import TransportMaps.Likelihoods as LKL
init_x = np.array([100, 200, 2000])
dt = 0.05
state_dim = 3
obs_dim = 1
F =  np.eye(3) + np.array([[0, 1, 0],
                       [0, 0, 0],
                       [0, 0, 0]]) * dt

Q =   np.eye(state_dim)
Q0 =  50 *np.eye(state_dim)
nu_x0 = DIST.GaussianDistribution(init_x, Q0)
nu_w = DIST.GaussianDistribution(np.zeros(state_dim), Q)
nsteps = 10
Z = np.zeros( (state_dim, nsteps+1) )
Z[:,0] = np.array([200, 100, 1000])
for i in range(nsteps):
    Z[:,i+1] = np.dot(F, Z[:,i])  + nu_w.rvs(1)[0,:]  
range_std = 5. 
R = np.diag([range_std**2])
nu_v = DIST.GaussianDistribution(np.zeros(obs_dim),  R)
Y = []
for i in range(nsteps+1):
    Y.append(np.sqrt(Z[2,i]**2+ Z[0,i]**2) + nu_v.rvs(1)[0,:] )

class NonlinearMap(MAPS.Map):
    def __init__(self):
        super(NonlinearMap, self).__init__(state_dim, obs_dim)
    def evaluate(self, x, *args, **kwargs):
        out = np.zeros((x.shape[0], self.dim_out))
        out[:,0] = (x[:,0]**2 + x[:,2]**2) ** 0.5 
        return out
    def grad_x(self, x, *args, **kwargs):
        out = np.zeros((x.shape[0], self.dim_out, self.dim_in))  # out.shape = (m x dy x dx)  
        horiz_dist = x[:,0]
        altitude = x[:,2]
        denom = np.sqrt(horiz_dist**2 + altitude**2) 
        out[:,0,0] = horiz_dist/denom
        out[:,0,2] = altitude/denom
        return out
    
    def hess_x(self, x, *args, **kwargs):
#         eq 3.83
        out = np.zeros((x.shape[0], self.dim_out, self.dim_in, self.dim_in)) # out.shape = (m x dy x dx x dx)
        horiz_dist = x[:,0]
        altitude = x[:,2]
        denom = np.sqrt(horiz_dist**2 + altitude**2)
        out[:,0,0,0] = altitude**2 /denom**3
        out[:,0,0,2] =  -1 * horiz_dist * altitude /denom**3
        out[:,0,2,0] = out[:,0,0,2]
        out[:,0,2,2] = horiz_dist**2 /denom**3
        return out

PhiMap = MAPS.LinearMap(np.zeros(state_dim), F)
pi_trans = DISTDEC.AR1TransitionDistribution(nu_w, PhiMap)
pi = DISTDEC.SequentialHiddenMarkovChainDistribution([], [])
for n in range(nsteps+1):
    Hmap = NonlinearMap()
    ll = LKL.AdditiveLogLikelihood(Y[n], nu_v, Hmap)
    if n == 0: pin = nu_x0
    else: pin = pi_trans
    pi.append(pin, ll)
lap = TM.laplace_approximation(pi)&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The whole Error information:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;pre&gt;NameError                                 Traceback (most recent call last)
&amp;lt;ipython-input-1-28eebd6a4657&amp;gt; in &amp;lt;module&amp;gt;()
     66     else: pin = pi_trans
     67     pi.append(pin, ll)
---&amp;gt; 68 lap = TM.laplace_approximation(pi)

/Users/junjie/anaconda/lib/python2.7/site-packages/TransportMaps/Routines.pyc in laplace_approximation(pi, params, x0, tol, ders, fungrad)
   1486                               method=&amp;#39;newton-cg&amp;#39;,
   1487                               tol=tol,
-&amp;gt; 1488                               options=options)
   1489     else:
   1490         raise ValueError(&amp;quot;ders parameter not valid. Chose between 0,1,2.&amp;quot;)

/Users/junjie/anaconda/lib/python2.7/site-packages/scipy/optimize/_minimize.pyc in minimize(fun, x0, args, method, jac, hess, hessp, bounds, constraints, tol, callback, options)
    482     elif meth == &amp;#39;newton-cg&amp;#39;:
    483         return _minimize_newtoncg(fun, x0, args, jac, hess, hessp, callback,
--&amp;gt; 484                                   **options)
    485     elif meth == &amp;#39;l-bfgs-b&amp;#39;:
    486         return _minimize_lbfgsb(fun, x0, args, jac, bounds,

/Users/junjie/anaconda/lib/python2.7/site-packages/scipy/optimize/optimize.pyc in _minimize_newtoncg(fun, x0, args, jac, hess, hessp, callback, xtol, eps, maxiter, disp, return_all, **unknown_options)
   1597             msg = (&amp;quot;Warning: CG iterations didn&amp;#39;t converge.  The Hessian is not &amp;quot;
   1598                    &amp;quot;positive definite.&amp;quot;)
-&amp;gt; 1599             return terminate(3, msg)
   1600 
   1601         pk = xsupi  # search direction is solution to system.

/Users/junjie/anaconda/lib/python2.7/site-packages/scipy/optimize/optimize.pyc in terminate(warnflag, msg)
   1517             print(&amp;quot;         Hessian evaluations: %d&amp;quot; % hcalls)
   1518         fval = old_fval
-&amp;gt; 1519         result = OptimizeResult(fun=fval, jac=gfk, nfev=fcalls[0],
   1520                                 njev=gcalls[0], nhev=hcalls, status=warnflag,
   1521                                 success=(warnflag == 0), message=msg, x=xk,

NameError: free variable &amp;#39;gfk&amp;#39; referenced before assignment in enclosing scope&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<category>usage</category>
<guid isPermaLink="true">https://transportmaps.mit.edu/qa/index.php?qa=29&amp;qa_1=nameerror-variable-referenced-before-assignment-enclosing</guid>
<pubDate>Fri, 06 Apr 2018 13:13:08 +0000</pubDate>
</item>
<item>
<title>Can't use a pulled distribution since the v1.1b0</title>
<link>https://transportmaps.mit.edu/qa/index.php?qa=25&amp;qa_1=cant-use-a-pulled-distribution-since-the-v1-1b0</link>
<description>&lt;p&gt;Hi,&lt;/p&gt;&lt;p&gt;Since the v1.1b0 I can&amp;#39;t use a pulled distribution. For example I can&amp;#39;t compute the grad_log_x of a pulled distribution as in the test code below. I use python 3.6.1.&lt;/p&gt;&lt;p&gt;Best regards,&lt;/p&gt;&lt;p&gt;Paul.&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;import logging
import warnings
import numpy as np
import scipy.stats as stats
import TransportMaps as TM
import TransportMaps.Maps as MAPS
warnings.simplefilter(&quot;ignore&quot;)
TM.setLogLevel(logging.INFO)

import TransportMaps.Distributions as DIST

class GumbelDistribution(DIST.Distribution):
    def __init__(self, mu, beta):
        super(GumbelDistribution,self).__init__(1)
        self.mu = mu
        self.beta = beta
        self.dist = stats.gumbel_r(loc=mu, scale=beta)
    def pdf(self, x, params=None):
        return self.dist.pdf(x).flatten()
    def log_pdf(self, x, params=None):
        return self.dist.logpdf(x).flatten()
    def grad_x_log_pdf(self, x, params=None):
        m = self.mu
        b = self.beta
        z = (x-m)/b
        return (np.exp(-z)-1.)/b
    def hess_x_log_pdf(self, x, params=None):
        m = self.mu
        b = self.beta
        z = (x-m)/b
        return (-np.exp(-z)/b**2.)[:,:,np.newaxis]

mu = -63.
beta = 3.
pi = GumbelDistribution(mu,beta)

x=np.linspace(0,10,100)[:,np.newaxis]

mu = np.array([-60])
sigma = np.array([[8]])

# Linear map
L = MAPS.LinearTransportMap(mu, sigma)

pull_L_pi = DIST.PullBackTransportMapDistribution(L,pi)
pull_L_pi.grad_x_log_pdf(x)&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<category>usage</category>
<guid isPermaLink="true">https://transportmaps.mit.edu/qa/index.php?qa=25&amp;qa_1=cant-use-a-pulled-distribution-since-the-v1-1b0</guid>
<pubDate>Thu, 15 Mar 2018 07:09:29 +0000</pubDate>
</item>
<item>
<title>I got an error &quot;undefined symbol: _gfortran_stop_numeric_f08&quot; when I import orthpol_light in Anaconda.</title>
<link>https://transportmaps.mit.edu/qa/index.php?qa=18&amp;qa_1=undefined-_gfortran_stop_numeric_f08-orthpol_light-anaconda</link>
<description>&lt;p&gt;Recently I have downloaded your TransportMaps package available at&amp;nbsp;&lt;a target=&quot;_blank&quot; rel=&quot;nofollow&quot; href=&quot;http://transportmaps.mit.edu/&quot;&gt;http://transportmaps.mit.edu/&lt;/a&gt;. However, when I try to import it through anaconda, I got the following issue:&lt;br&gt;&lt;br&gt;ImportError: /home/kclam/anaconda3/lib/python3.6/site-packages/&lt;a target=&quot;_blank&quot; rel=&quot;nofollow&quot; href=&quot;http://orthpol_light.cpython-36m-x86_64-linux-gnu.so/&quot;&gt;orthpol_light.cpython-36m-x86_64-linux-gnu.so&lt;/a&gt;: undefined symbol: _gfortran_stop_numeric_f08&lt;br&gt;&lt;br&gt;May i know if it is related to my gfortran version?&amp;nbsp;&lt;br&gt;My gfortran version is&lt;br&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;GNU Fortran (Ubuntu 5.4.0-6ubuntu1~16.04.5) 5.4.0 20160609&lt;/p&gt;&lt;p&gt;Copyright (C) 2015 Free Software Foundation, Inc.&lt;/p&gt;</description>
<category>installation</category>
<guid isPermaLink="true">https://transportmaps.mit.edu/qa/index.php?qa=18&amp;qa_1=undefined-_gfortran_stop_numeric_f08-orthpol_light-anaconda</guid>
<pubDate>Mon, 04 Dec 2017 21:45:46 +0000</pubDate>
</item>
<item>
<title>Why I can't build TM from non standard normal distribution to Gumbel distribution ?</title>
<link>https://transportmaps.mit.edu/qa/index.php?qa=5&amp;qa_1=cant-build-standard-normal-distribution-gumbel-distribution</link>
<description>&lt;p&gt;&lt;span style=&quot;color:#000000; font-family:helvetica; font-size:12px&quot;&gt;Hi,&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:#000000; font-family:helvetica; font-size:12px&quot;&gt;Thank you for your software and all the support provided.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;I am trying to use your TransportMaps library to solve some of my examples but I encounter some difficulties. I went back to a simple example which is not working.&lt;/p&gt;&lt;p&gt;I am trying to build a map between a gaussian distribution and a gumbel distribution (mu=-63, beta=3) (which is close to a posterior distribution I want to sample). When I use a standard normal gaussian distribution (rho) as reference distribution it&amp;rsquo;s working well. But when I use another gaussian distribution (mean=-60, stdd=8) (rho2) I can&amp;rsquo;t reach a good approximation building the map whatever the order of the map I use (see file attached). For me it will be easier to build the map between closer distributions. I can&amp;rsquo;t understand what I am doing wrong.&amp;nbsp;&lt;/p&gt;&lt;p&gt;I would very appreciate if you can find some time to answer me.&lt;/p&gt;&lt;p&gt;Best regards,&lt;/p&gt;&lt;p&gt;Paul.&lt;/p&gt;&lt;p&gt;Here the python script I use:&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;import logging
import warnings
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as stats
import SpectralToolbox.Spectral1D as S1D
import TransportMaps as TM
import TransportMaps.Functionals as FUNC
import TransportMaps.Maps as MAPS
import scipy.io
import scipy.linalg as scila
import SpectralToolbox.SpectralND as SND

warnings.simplefilter(&quot;ignore&quot;)
TM.setLogLevel(logging.INFO)

import TransportMaps.Distributions as DIST

    
class GumbelDistribution(DIST.Distribution):
    def __init__(self, mu, beta):
        super(GumbelDistribution,self).__init__(1)
        self.mu = mu
        self.beta = beta
        self.dist = stats.gumbel_r(loc=mu, scale=beta)
    def pdf(self, x, params=None):
        return self.dist.pdf(x).flatten()
    def log_pdf(self, x, params=None):
        return self.dist.logpdf(x).flatten()
    def grad_x_log_pdf(self, x, params=None):
        m = self.mu
        b = self.beta
        z = (x-m)/b
        return (np.exp(-z)-1.)/b
    def hess_x_log_pdf(self, x, params=None):
        m = self.mu
        b = self.beta
        z = (x-m)/b
        return (-np.exp(-z)/b**2.)[:,:,np.newaxis]

mu = -63.
beta = 3.
pi = GumbelDistribution(mu,beta)

M=np.array([[-50],[-70],[-60]])

xnew=np.linspace(-70,-50,201)[:,np.newaxis]

mu = np.array([-60])
sigma = np.array([[8]])

rho=DIST.StandardNormalDistribution(1)
rho2=DIST.GaussianDistribution(mu,sigma)

x = np.linspace(-70., -50., 100).reshape((100,1))

order=7
T = TM.Default_IsotropicIntegratedSquaredTriangularTransportMap(
    1, order, 'full')
T2 = TM.Default_IsotropicIntegratedSquaredTriangularTransportMap(
    1, order, 'full')

push_rho=DIST.PushForwardTransportMapDistribution(T,rho)
push_rho2=DIST.PushForwardTransportMapDistribution(T2,rho2)


qtype = 3      # Gauss quadrature
qparams =[20] # Quadrature order
reg = None     # No regularization
tol = 1e-10    # Optimization tolerance
ders = 2       # Use gradient and Hessian

log = push_rho.minimize_kl_divergence(
    pi, qtype=qtype, qparams=qparams, regularization=reg,
    tol=tol, ders=ders)

log = push_rho2.minimize_kl_divergence(
    pi, qtype=qtype, qparams=qparams, regularization=reg,
    tol=tol, ders=ders)

plt.figure()
plt.plot(x, push_rho.pdf(x),'b',label=r'$push rho$');
plt.plot(x, push_rho2.pdf(x),'r',label=r'$push rho2$');
plt.plot(x, pi.pdf(x),'g',label=r'$\pi$');
plt.legend();&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<category>theory</category>
<guid isPermaLink="true">https://transportmaps.mit.edu/qa/index.php?qa=5&amp;qa_1=cant-build-standard-normal-distribution-gumbel-distribution</guid>
<pubDate>Tue, 31 Oct 2017 16:30:12 +0000</pubDate>
</item>
</channel>
</rss>