The TransportMap support team will be happy to help you out with questions ranging from theory on transport maps, to the installation and usage of the software TransportMaps.

Can't use a pulled distribution since the v1.1b0

0 votes

Hi,

Since the v1.1b0 I can't use a pulled distribution. For example I can't compute the grad_log_x of a pulled distribution as in the test code below. I use python 3.6.1.

Best regards,

Paul.

import logging
import warnings
import numpy as np
import scipy.stats as stats
import TransportMaps as TM
import TransportMaps.Maps as MAPS
warnings.simplefilter("ignore")
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)

 

asked Mar 15, 2018 in usage by PaulB (17 points)

1 Answer

0 votes
 
Best answer
Hi Paul,

yes, I'm aware of the bug in version 1.1b0. Try to update to 1.1b2

https://pypi.python.org/pypi/TransportMaps/1.1b2

I run the code on this version and it was working ok.

Best,

 Daniele
answered Mar 15, 2018 by dabi (307 points)
selected Mar 16, 2018 by PaulB
Thanks for the support it works!

`best,

paul.
...