Beispiel #1
0
    def invert(self,
               data,
               input=None,
               mask=None,
               tag=None,
               clip=np.array([0.0, 1.0])):
        #         yhat = self.link(np.clip(data, .1, np.inf))
        if self.bin_size < 1:
            yhat = smooth(data, 20)

        xhat = self.link(np.clip(yhat, 0.01, np.inf))
        xhat = self._invert(xhat, input=input, mask=mask, tag=tag)
        xhat = smooth(xhat, 10)

        if self.bin_size < 1:
            # xhat = np.clip(xhat, -0.9, 0.9)
            xhat = np.clip(xhat, -1.02, 1.02)
        # for t in range(xhat.shape[0]):
        #     if np.all(xhat[np.max([0,t-2]):t+3]>0.99) and t>2:
        #     # if np.median(xhat[np.max([0,t-2]):t+3])>0.99 and t>0:
        #         xhat[np.minimum(0,t-2):] = 1.01*np.ones(np.shape(xhat[np.minimum(0,t-2):]))
        #         xhat[:np.maximum(0,t-2)] = 0.0*np.ones(np.shape(xhat[:np.maximum(0,t-2)]))
        #         break
        #     if np.all(xhat[np.max([0,t-2]):t+3]<-0.99) and t>2:
        #     # if np.median(xhat[np.max([0,t-2]):t+3])>0.99 and t>0:
        #         xhat[np.minimum(0,t-2):] = -1.01*np.ones(np.shape(xhat[np.minimum(0,t-2):]))
        #         xhat[:np.maximum(0,t-2)] = 0.0*np.ones(np.shape(xhat[:np.maximum(0,t-2)]))
        #         break

        if np.abs(xhat[0]).any() > 1.0:
            xhat[0] = 0.05 * npr.randn(1, self.D)
        return xhat
Beispiel #2
0
 def invert(self,
            data,
            input=None,
            mask=None,
            tag=None,
            clip=np.array([0.0, 1.0])):
     yhat = smooth(data, 20)
     xhat = self.link(np.clip(yhat, 0.01, np.inf))
     xhat = self._invert(xhat, input=input, mask=mask, tag=tag)
     num_pad = 10
     xhat = smooth(np.concatenate((np.zeros((num_pad, self.D)), xhat)),
                   10)[num_pad:, :]
     xhat = np.clip(xhat, -1.1, 1.1)
     if np.abs(xhat[0]).any() > 1.0:
         xhat[0] = 0.1 * npr.randn(1, self.D)
     return xhat
Beispiel #3
0
    def invert(self, data, input=None, mask=None, tag=None):
        yhat = smooth(data,20)
        xhat = self.link(np.clip(yhat, 0.01, np.inf))
        xhat = self._invert(xhat, input=input, mask=mask, tag=tag)
        for t in range(xhat.shape[0]):
            if np.all(xhat[np.max([0,t-2]):t+3]>0.99) and t>2:
                xhat[np.minimum(0,t-2):] = 1.01*np.ones(np.shape(xhat[np.minimum(0,t-2):]))
                xhat[:np.maximum(0,t-2)] = np.clip(xhat[:np.maximum(0,t-2)], -0.5,0.95)

        if np.abs(xhat[0])>1.0:
                xhat[0] = 0.5 + 0.01*npr.randn(1,np.shape(xhat)[1])
        return xhat
Beispiel #4
0
    def invert(self,
               data,
               input=None,
               mask=None,
               tag=None,
               clip=np.array([0.0, 1.0])):
        #         yhat = self.link(np.clip(data, .1, np.inf))
        if self.bin_size < 1:
            yhat = smooth(data, 20)

        xhat = self.link(np.clip(yhat, 0.01, np.inf))
        xhat = self._invert(xhat, input=input, mask=mask, tag=tag)
        xhat = smooth(xhat, 10)

        if self.bin_size < 1:
            xhat = np.clip(xhat, -0.95, 0.95)

        # in all models, x starts in between boundaries at [-1,1]
        if np.abs(xhat[0]).any() > 1.0:
            xhat[0] = 0.05 * npr.randn(1, self.D)
        return xhat