<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>TransportMaps Q&amp;A - Recent questions and answers</title>
<link>https://transportmaps.mit.edu/qa/index.php?qa=qa</link>
<description>Powered by Question2Answer</description>
<item>
<title>Answered: 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&amp;show=504#a504</link>
<description>&lt;p&gt;Hi Patrick,&amp;nbsp;&lt;/p&gt;&lt;p&gt;Thank you very much for your question! Given a marginal random field (MRF), the sparsity of the inverse transport map (i.e., the active variables set in the code you referenced)&amp;nbsp;can be extracted from&amp;nbsp;a variable elimination algorithm applied to the graph. We have implemented this code as part of our &lt;a rel=&quot;nofollow&quot; href=&quot;https://transportmaps.mit.edu/docs/example-inverse-sparsity-identification.html&quot;&gt;SING algorithm&lt;/a&gt; for learning the structure of graphical models from data, which alternates using&amp;nbsp;a sparse map to learn the adjacency of the graph with extracting&amp;nbsp;the map sparsity from the adjacency matrix.&amp;nbsp;&lt;/p&gt;&lt;p&gt;The code block to extract the active variables as a list&amp;nbsp;given a matrix A encoding the edges of the MRF is:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;# Variable elimination moving from highest node (dim-1) to node 2 (at most)
dim = A.shape[0]
ALower = np.tril(A)
for i in range(dim-1,1,-1):
    non_zero_ind  = np.where(ALower[i,:i] != 0)[0]
    if len(non_zero_ind) &amp;gt; 1:
        co_parents = list(itertools.combinations(non_zero_ind,2))
        for j in range(len(co_parents)):
            row_index = max(co_parents[j])
            col_index = min(co_parents[j])
            ALower[row_index, col_index] = 1.0

# Find list of active_vars
active_vars = []
for i in range(dim):
    actives = np.where(ALower[i,:] != 0)
    active_list = list(set(actives[0]) | set([i]))
    active_list.sort(key=int)
    active_vars.append(active_list)&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Please let us know if you have any other questions!&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Best,&lt;/p&gt;&lt;p&gt;Ricardo&lt;/p&gt;</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&amp;show=504#a504</guid>
<pubDate>Sun, 12 Feb 2023 00:33:50 +0000</pubDate>
</item>
<item>
<title>Answered: 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&amp;show=256#a256</link>
<description>&lt;p&gt;Hello Peng,&lt;/p&gt;&lt;p&gt;There are mainly two lines of work regarding filtering/smoothing/parameter estimation (or more in general data assimilation):&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The first one is along the lines of &lt;strong&gt;variational&lt;/strong&gt; filters/smoothers and is presented in&amp;nbsp;&lt;a rel=&quot;nofollow&quot; href=&quot;http://jmlr.org/papers/v19/17-747.html&quot;&gt;&amp;quot;Inference via low-dimensional couplings&amp;quot;&lt;/a&gt;. It is already implemented in TransportMaps 2.0, in the version described in the paper.&lt;/li&gt;&lt;li&gt;The second one is along the lines of &lt;strong&gt;ensemble&lt;/strong&gt; filters/smoothers and is presented in &lt;a rel=&quot;nofollow&quot; href=&quot;https://arxiv.org/abs/1907.00389&quot;&gt;&amp;quot;Coupling techniques for nonlinear ensemble filtering&amp;quot;&lt;/a&gt; . The lead in this case is Ricardo Baptista, and you should contact him for more details. These versions of filters are not included in the code yet (I know Ricardo has some software for it). It might be included in future releases of TransportMaps.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;On both fornts there are many open questions and new challenges which we could discuss off-line.&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;Best,&lt;/div&gt;&lt;div&gt;&amp;nbsp; Daniele&lt;/div&gt;</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&amp;show=256#a256</guid>
<pubDate>Fri, 16 Aug 2019 15:32:26 +0000</pubDate>
</item>
<item>
<title>Answered: 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&amp;show=232#a232</link>
<description>&lt;p&gt;Hi Saad, your question got cut out for some reasons, but I imagine you are referring to the rescaling done by the map \(L\), which (practically) takes the original sample and scales it to get a mean 0 and variance 0 sample. This is done because the map \(S\) is going to use polynomials orthogonal with respect ot \(N(0,1)\), which implies that they are mostly &amp;quot;accurate&amp;quot; on the bulk of \(N(0,1)\).&lt;/p&gt;&lt;p&gt;This question is similar to the issue described &lt;a rel=&quot;nofollow&quot; href=&quot;https://transportmaps.mit.edu/qa/index.php?qa=5&amp;amp;qa_1=cant-build-standard-normal-distribution-gumbel-distribution&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&lt;p&gt;I hope this helps,&lt;/p&gt;&lt;p&gt;&amp;nbsp;Daniele&lt;/p&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&amp;show=232#a232</guid>
<pubDate>Tue, 23 Jul 2019 15:43:39 +0000</pubDate>
</item>
<item>
<title>Answered: 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&amp;show=122#a122</link>
<description>&lt;p&gt;Hi Hassan, I think that the documentation is lacking some explanation here.&lt;/p&gt;&lt;p&gt;When solving the problem \(\min_T \mathcal{D}_{\text{KL}}\left( T_\sharp \pi \Vert \rho \right) \) , where \( \pi \) is your target from which you have samples and \( \rho \) is the Sandard Normal, the code will:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;flip the problem to solve \( \arg\min_T \mathcal{D}_{\text{KL}}\left( \pi \Vert T^\sharp \rho \right) = \arg\min_T \mathbb{E}_{\pi} \left[ -\log T^\sharp \rho \right] \approx&amp;nbsp;\arg\min_T \sum_{i=1}^n -\log T^\sharp \rho({\bf x}_i) \). This is done in &lt;a rel=&quot;nofollow&quot; href=&quot;https://transportmaps.mit.edu/docs/_modules/TransportMaps/Distributions/TransportMapDistributions.html#PushForwardTransportMapDistribution.minimize_kl_divergence&quot;&gt;PushForwardTransportMapDistribution.minimize_kl_divergence&lt;/a&gt; .&lt;/li&gt;&lt;li&gt;Then it will call &lt;a rel=&quot;nofollow&quot; href=&quot;https://transportmaps.mit.edu/docs/api-TransportMaps-Maps.html#TransportMaps.Maps.MonotonicTriangularTransportMap.minimize_kl_divergence&quot;&gt;MonotonicTriangularTransportMap.minimize_kl_divergence&lt;/a&gt; .&lt;/li&gt;&lt;li&gt;If the distribution \(\rho\) is&amp;nbsp; a product distribution (as the Standard Normal is), the map will be learned componentwise (see Section 4.2 of &lt;a rel=&quot;nofollow&quot; href=&quot;https://rd.springer.com/content/pdf/10.1007%2F978-3-319-11259-6_23-1.pdf&quot;&gt;Marzouk et al.&lt;/a&gt;)&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;Since usually the first components are not computationally expensive (few parameters), one can provide a list of \(d\) elements (\(d\) being the number of components of the map/dimension of the problem), where each element is either &lt;span style=&quot;font-family:Courier New,Courier,monospace&quot;&gt;None&lt;/span&gt;&lt;span style=&quot;font-family:Arial,Helvetica,sans-serif&quot;&gt; or an &lt;/span&gt;&lt;span style=&quot;font-family:Courier New,Courier,monospace&quot;&gt;mpi_pool&lt;/span&gt;&lt;span style=&quot;font-family:Arial,Helvetica,sans-serif&quot;&gt;. &lt;/span&gt;The point being that there is a tradeoff between using a single process or multiple processes: if one uses multiple processes gets the benefit of a faster function/gradient evaluations, at the expense of a fixed communication cost. This communication cost sometimes is higher than the actual functional/gradient evaluation costs (e.g. for the first components) and therefore it does not make sense to use parallelism for them.&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;I hope this clarifies it a little bit.&lt;/div&gt;&lt;div&gt;Daniele&lt;/div&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&amp;show=122#a122</guid>
<pubDate>Thu, 21 Mar 2019 13:53:50 +0000</pubDate>
</item>
<item>
<title>Answered: Inverse map computational speed</title>
<link>https://transportmaps.mit.edu/qa/index.php?qa=105&amp;qa_1=inverse-map-computational-speed&amp;show=106#a106</link>
<description>&lt;p&gt;Hello Hassan,&lt;/p&gt;&lt;p&gt;yes computing the inverse of a map is in general more expensive than evaluating the map. The evaluation of a generic non-linear map \(S\) is given by:&lt;/p&gt;&lt;p&gt;$$ S({\bf x})=\left[\begin{array}{l}&lt;br&gt;S_1(x_1)\\&lt;br&gt;S_2(x_1, x_2)\\&lt;br&gt;\;\vdots\\&lt;br&gt;S_d(x_1,\ldots,x_d)&lt;br&gt;\end{array}\right]$$&lt;/p&gt;&lt;p&gt;The inverse instead requires \(d\) rootfinding to be computed, one for each component \(S_i\):&lt;/p&gt;&lt;p&gt;$$ S^{-1}({\bf y})=\left[\begin{array}{l}&lt;br&gt;S_1^{-1}(y_1)\\&lt;br&gt;S_2^{-1}(S_1^{-1}(y_1), \cdot)(y_2)\\&lt;br&gt;\;\vdots\\&lt;br&gt;S_d^{-1}(S_1^{-1}(y_1),\ldots,\cdot)(y_d)&lt;br&gt;\end{array}\right]$$&lt;/p&gt;&lt;p&gt;where each rootfinding is done along the last dimension (you can see the monotonicity constraint coming handy when doing these rootfidings). The class InverseTransportMap is just a wrapper around \(S\), so it wouldn&amp;#39;t help.&lt;/p&gt;&lt;p&gt;In order to speed-up the computation of the inverse there are two available routes:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Use MPI: the computation can be performed for each point separately. You can take a look at the &lt;a rel=&quot;nofollow&quot; href=&quot;https://transportmaps.mit.edu/docs/mpi-usage.html&quot;&gt;MPI section&lt;/a&gt; of the tutorial.&lt;/li&gt;&lt;li&gt;The alternative (if you really have to use this inverse again and again) is to solve the regression problem&lt;br&gt;$$ T = \arg\min_{T} \Vert T({\bf x}) - S^{-1}({\bf x}) \Vert_{\mathcal{N}(0,{\bf I})} $$&lt;br&gt;You can look for the &lt;a rel=&quot;nofollow&quot; href=&quot;https://transportmaps.mit.edu/docs/api-TransportMaps-Maps.html#TransportMaps.Maps.TransportMap.regression&quot;&gt;API documentation of the regression function&lt;/a&gt;.&lt;br&gt;Once the map \(T\) is found, then you can just evaluate it on all your points and that should be way faster.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Let me know if you have any additional doubt and I can write down a couple of working examples.&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&amp;show=106#a106</guid>
<pubDate>Thu, 07 Mar 2019 02:08:05 +0000</pubDate>
</item>
<item>
<title>Answered: 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&amp;show=100#a100</link>
<description>&lt;p&gt;Hi, sorry for the long delay. Let me try to reproduce the problem. Are you working on any example provided with the software or your own?&lt;/p&gt;&lt;p&gt;I just run step by step the code provided &lt;a rel=&quot;nofollow&quot; href=&quot;https://transportmaps.mit.edu/docs/example-sequential-stocvol-6d.html&quot;&gt;here&lt;/a&gt; with TransportMaps version 2.0b2 and it works also with missing observations.&lt;/p&gt;&lt;p&gt;Please let me know which version you are using and a minimum working example.&lt;/p&gt;&lt;p&gt;Thanks.&lt;/p&gt;</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&amp;show=100#a100</guid>
<pubDate>Sat, 09 Feb 2019 13:24:27 +0000</pubDate>
</item>
<item>
<title>Answered: 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&amp;show=87#a87</link>
<description>&lt;p&gt;Hi&amp;nbsp;Hassan,&amp;nbsp;&lt;/p&gt;&lt;p&gt;Thank you very much for your question!&amp;nbsp;&lt;/p&gt;&lt;p&gt;To follow up on the previous suggestion, I think you may be missing the sparse Cholesky factorization library, &amp;nbsp;CHOMOD. The library is used by scikit-sparse and I believe it&amp;nbsp;does not come with the conda-forge package. The easiest&amp;nbsp;approach may be&amp;nbsp;to download the &lt;a rel=&quot;nofollow&quot; href=&quot;http://faculty.cse.tamu.edu/davis/suitesparse.html&quot;&gt;suitesparse package&lt;/a&gt;&amp;nbsp;that contains several sparse matrix methods, including CHOLMOD, and to reinstall scikit-sparse. I&amp;#39;ve tested it on Mojave with Anaconda Python 3.6 and it seems to be working.&lt;/p&gt;&lt;p&gt;Please let us know if this fixes the import error&amp;nbsp;on your end, and if not we are glad to&amp;nbsp;investigate further!&lt;/p&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&amp;show=87#a87</guid>
<pubDate>Sat, 10 Nov 2018 23:31:01 +0000</pubDate>
</item>
<item>
<title>Answered: 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&amp;show=58#a58</link>
<description>&lt;p&gt;The transport preconditioned MCMC can be coded using TransportMaps. There is not a tutorial page for that yet, but the idea is to construct (inverse) maps from MCMC samples to then precondition new chains. The package TransportMaps provides very few Markov Chain samplers (standard ones like &lt;a rel=&quot;nofollow&quot; href=&quot;https://transportmaps.mit.edu/docs/api-TransportMaps-Samplers.html?highlight=metropolis&quot;&gt;Metropolis-Hastings and some Gibbs variations&lt;/a&gt;). More samplers are available through &lt;a rel=&quot;nofollow&quot; href=&quot;http://muq.mit.edu/&quot;&gt;MUQ&lt;/a&gt;, which also implements the construction of transport maps from samples (only polynomial ones which don&amp;#39;t enforce monotonicity everywhere though). I will push to include a tutorial on this technique once I&amp;#39;m back.&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&amp;show=58#a58</guid>
<pubDate>Wed, 08 Aug 2018 09:54:32 +0000</pubDate>
</item>
<item>
<title>Answered: 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&amp;show=51#a51</link>
<description>&lt;p&gt;The error should be fixed in the version 2.0b2. Just do&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;pip install --upgrade TransportMaps&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;to upgrade to the new version.&lt;/p&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&amp;show=51#a51</guid>
<pubDate>Thu, 02 Aug 2018 22:22:30 +0000</pubDate>
</item>
<item>
<title>Answered: 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&amp;show=46#a46</link>
<description>&lt;p&gt;It appears to be a leftover bug in the documentation. Thanks for point it out.&lt;/p&gt;&lt;p&gt;The functions log_pdf, grad_x_log_pdf and hess_x_log_pdf now can take additional arguments and the Gumbel example provided in the tutorial is still coding an old interface. The correct code for the definition of the GumbelDistribution is as follows.&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;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, *args, **kwargs):
        return self.dist.pdf(x).flatten()
    def log_pdf(self, x, params=None, *args, **kwargs):
        return self.dist.logpdf(x).flatten()
    def grad_x_log_pdf(self, x, params=None, *args, **kwargs):
        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, *args, **kwargs):
        m = self.mu
        b = self.beta
        z = (x-m)/b
        return (-np.exp(-z)/b**2.)[:,:,np.newaxis]&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;I&amp;#39;m in the process of updating the tutorial in any place where this bug appear.&lt;/p&gt;&lt;p&gt;Thanks again,&lt;/p&gt;&lt;p&gt;&amp;nbsp;Daniele&lt;/p&gt;</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&amp;show=46#a46</guid>
<pubDate>Wed, 01 Aug 2018 13:35:22 +0000</pubDate>
</item>
<item>
<title>Answered: 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&amp;show=37#a37</link>
<description>&lt;p&gt;Hi Paul,&lt;/p&gt;&lt;p&gt;I don&amp;#39;t have personal experience with the approach described in [TM1] &amp;quot;Bayesian inference with optimal maps&amp;quot;, but here are my insights with regard to map composition and tempering. In the following I assume that you have whitened the posterior, so that the prior distribution is a Standard Normal and tempering is applied to the whitened likelihood (either by noise covariance progression, data injection or forward accuracy).&lt;/p&gt;&lt;ul&gt;&lt;li&gt;I would say that the progression of the noise covariance should be slow enough so that at each step the map is able to capture most of the relation between reference (Standard Normal) and the tempered posterior. You should measure this using the variance diagnostic.&lt;/li&gt;&lt;li&gt;Regarding computational cost: if the maps are simple enough (at least order two or three for accuracy) then the approach can result in something more efficient than directly computing a transport map of high-order. You can think to the final map as many layer of a neural network with each layer corresponding to a map in the composition. This can help explain the expressivity of the representation. On the upside, of using compositions of monotone triangular maps is that the transformation is invertible (a property sometimes needed).&lt;/li&gt;&lt;li&gt;The composition of maps should take the prior/reference \(\nu_\rho\) to posterior \(\nu_\pi\) progressively, but it should not result in the &amp;quot;optimal composition&amp;quot; due to the inherent sequential construction. One could correct the maps in a final sweep over the maps to improve them, e.g. solving the \(n\) problems:&lt;br&gt;\[ T_i = \arg\min_{T\in \mathcal{T}_&amp;gt;} \mathcal{D}_{\text{KL}}\left( (T_1\circ T_{i-1})_\sharp \nu_\rho \middle\Vert T^\sharp (T_{i+1}\circ T_n)^\sharp \nu_\pi \right) \]&lt;br&gt;warm started at the \(T_i\) already learned through the tempering procedure.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;Can you clarify what you mean with &amp;quot;first map to get low-rank coupling&amp;quot;? Do you mean to find the rotation such that the next maps become the identity almost everywhere (like Likelihood Informed sub-spaces or Active sub-spaces)?&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;Also what do you mean with &amp;quot;unscaled&amp;quot;? Usually the scaling problem can arise when one tries to find &lt;a target=&quot;_blank&quot; rel=&quot;nofollow&quot; href=&quot;https://transportmaps.mit.edu/docs/examples-transport-from-samples.html&quot;&gt;maps from samples&lt;/a&gt; not when constructing &lt;a target=&quot;_blank&quot; rel=&quot;nofollow&quot; href=&quot;https://transportmaps.mit.edu/docs/examples-direct-transport.html&quot;&gt;maps from densities &lt;/a&gt;. So using a linear map at the beginning is not strictly necessary, but it shouldn&amp;#39;t hurt either.&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;I hope to have addressed some of your questions.&lt;/div&gt;&lt;div&gt;I will try to gather more insights from my collegues in the coming days.&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;Best,&lt;/div&gt;&lt;div&gt;&amp;nbsp;Daniele&lt;/div&gt;</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&amp;show=37#a37</guid>
<pubDate>Fri, 22 Jun 2018 10:02:17 +0000</pubDate>
</item>
<item>
<title>Answered: 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&amp;show=30#a30</link>
<description>&lt;p&gt;Hi Jack, you are trying to solve the following problem, right?&lt;/p&gt;&lt;p&gt;\[ \nu_{Z_0}=\mathcal{N}(0, Q_0) \;, \quad \nu_w = \mathcal{N}(0,Q) \;,\quad \nu_v=\mathcal{N}(0,R) \]&lt;/p&gt;&lt;p&gt;\[ Z_{t+1} = F Z_{t} + \varepsilon \;, \quad \varepsilon \sim \nu_{w} \]&lt;/p&gt;&lt;p&gt;\[ Y_t&amp;nbsp; = \sqrt{Z_{2,t}^2 + Z_{0,t}^2} + \delta \;, \quad \delta\sim\nu_v \]&lt;/p&gt;&lt;p&gt;I just tried to run your code and I run on a different error, namely&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;Traceback (most recent call last):
  File &quot;script.py&quot;, line 68, in &amp;lt;module&amp;gt;
    lap = TM.laplace_approximation(pi)
  File &quot;/home/dabi/VC-Projects/Software/Mine/Current/transportmaps-private/TransportMaps/Routines.py&quot;, line 1664, in laplace_approximation
    x0 = pi.prior.rvs(1).flatten()
  File &quot;/home/dabi/VC-Projects/Software/Mine/Current/transportmaps-private/TransportMaps/Distributions/DistributionBase.py&quot;, line 68, in rvs
    raise NotImplementedError(&quot;The method is not implemented for this distribution&quot;)
NotImplementedError: The method is not implemented for this distribution&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This means that the random sampler for the prior \( \nu_Z \) distribution is not implelemented (now that I know it, I will do it soon). If this is not implemented, then you need to provide a starting point for the optimization used to find the MAP point for the Laplace approximation. For example, if you wanted to use the generating states as a starting point, you would do&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;lap = TM.laplace_approximation(pi, x0=Z)&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This way the code runs on my machine. Let me know whether you are still having the same problem and I can dig more into it.&lt;/p&gt;&lt;p&gt;Best,&lt;/p&gt;&lt;p&gt;&amp;nbsp;Daniele&lt;/p&gt;&lt;p&gt;PS: Also, if you want to see whether the optimization worked fine, you can lower the logging level to the INFO level (20) or to the debug level (10):&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;TM.logger.setLevel(20)&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=29&amp;qa_1=nameerror-variable-referenced-before-assignment-enclosing&amp;show=30#a30</guid>
<pubDate>Fri, 06 Apr 2018 20:16:32 +0000</pubDate>
</item>
<item>
<title>Answered: 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&amp;show=26#a26</link>
<description>Hi Paul,&lt;br /&gt;
&lt;br /&gt;
yes, I'm aware of the bug in version 1.1b0. Try to update to 1.1b2&lt;br /&gt;
&lt;br /&gt;
https://pypi.python.org/pypi/TransportMaps/1.1b2&lt;br /&gt;
&lt;br /&gt;
I run the code on this version and it was working ok.&lt;br /&gt;
&lt;br /&gt;
Best,&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;Daniele</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&amp;show=26#a26</guid>
<pubDate>Thu, 15 Mar 2018 15:39:11 +0000</pubDate>
</item>
<item>
<title>Answered: 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&amp;show=20#a20</link>
<description>&lt;p&gt;I was able to reproduce the error. Anaconda uses by default python3.6. For some reason compiling &lt;span style=&quot;font-family:Courier New,Courier,monospace&quot;&gt;orthpol_light&lt;/span&gt; against the libgfortran provided by anaconda raises that undefined symbol error.&lt;/p&gt;&lt;p&gt;A workaround is to use python3.5 (which is the version supported by Ubuntu16.04). To do so you can create a new environment in conda (which is anyway advised in order to keep things tided):&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;$ conda create -n tm python=3.5 numpy scipy&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;then activate the newly created environment&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;$ source activate tm&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;and installing orthpol_light through pip&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;$ pip install orthpol_light&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;I will dig into figuring out whether the problem with python3.6 is only related to anaconda or more general.&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&amp;show=20#a20</guid>
<pubDate>Tue, 05 Dec 2017 02:46:53 +0000</pubDate>
</item>
<item>
<title>Answered: 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&amp;show=7#a7</link>
<description>&lt;p&gt;Hi Paul, Youssef&amp;#39;s comment is spot on. Here is the code implementing his suggestion:&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as stats
import TransportMaps as TM
import TransportMaps.Functionals as FUNC
import TransportMaps.Maps as MAPS

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)

# Linear map
L = MAPS.LinearTransportMap(mu, sigma)
# New target (pullback of pi through L)
pull_L_pi = DIST.PullBackTransportMapDistribution(L, pi)

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

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

push_rho=DIST.PushForwardTransportMapDistribution(T,rho)


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

# Solve D_KL(T_\sharp \rho || L^\sharp \pi)
log = push_rho.minimize_kl_divergence(
    pull_L_pi, qtype=qtype, qparams=qparams, regularization=reg,
    tol=tol, ders=ders)

# Obtain \pi \approx L_\sharp T_\sharp \rho
push_LT_rho = DIST.PushForwardTransportMapDistribution(L, push_rho)

plt.figure()
plt.plot(x, push_LT_rho.pdf(x),'b',label=r'pushrho');
plt.plot(x, pi.pdf(x),'g',label=r'π');
plt.legend();

&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;To know more on composition of maps, you can see &lt;a target=&quot;_blank&quot; rel=&quot;nofollow&quot; href=&quot;http://transportmaps.mit.edu/docs/example-beta-1d.html&quot;&gt;this&lt;/a&gt; page of the tutorial.&lt;/p&gt;&lt;p&gt;Best,&lt;/p&gt;&lt;p&gt;&amp;nbsp;Daniele&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&amp;show=7#a7</guid>
<pubDate>Fri, 03 Nov 2017 15:26:16 +0000</pubDate>
</item>
</channel>
</rss>