Exemplo n.º 1
0
 def construct_proposal(self, y):
     assert(len(shape(y)) == 1)
     m = MixtureDistribution(self.distribution.dimension, self.num_eigen)
     m.mixing_proportion = Discrete((self.eigvalues + 1) / (sum(self.eigvalues) + self.num_eigen))
     # print "current mixing proportion: ", m.mixing_proportion.omega
     for ii in range(self.num_eigen):
         L = sqrt(self.dwscale[ii] * self.eigvalues[ii]) * reshape(self.eigvectors[:, ii], (self.distribution.dimension, 1))
         m.components[ii] = Gaussian(y, L, is_cholesky=True, ell=1)
     # Z=m.sample(1000).samples
     # Visualise.plot_data(Z)
     return m
Exemplo n.º 2
0
    def construct_proposal(self, y):
        """
        proposal is a mixture of normals,
        centred at y and with covariance gamma^2 I + nu^2 MHaa'HM',
        where a are the eigenvectors of centred kernel matrix Kc=HKH
        """
        assert len(shape(y)) == 1
        m = MixtureDistribution(self.distribution.dimension, self.num_eigen)
        m.mixing_proportion = Discrete((self.eigvalues + 1) / (sum(self.eigvalues) + self.num_eigen))
        # print "current mixing proportion: ", m.mixing_proportion.omega
        M = 2 * self.kernel.gradient(y, self.Z)
        H = Kernel.centring_matrix(len(self.Z))

        for ii in range(self.num_eigen):
            Sigma = self.gamma ** 2 * eye(len(y)) + self.nu2 * (M.T).dot(
                H.dot(outer(self.eigvectors[:, ii], self.eigvectors[:, ii]).dot(H.dot(M)))
            )
            m.components[ii] = Gaussian(y, Sigma)
        return m
Exemplo n.º 3
0
    def construct_proposal(self, y):
        """
        proposal is a mixture of normals,
        centred at y and with covariance gamma^2 I + nu^2 MHaa'HM',
        where a are the eigenvectors of centred kernel matrix Kc=HKH
        """
        assert (len(shape(y)) == 1)
        m = MixtureDistribution(self.distribution.dimension, self.num_eigen)
        m.mixing_proportion = Discrete(
            (self.eigvalues + 1) / (sum(self.eigvalues) + self.num_eigen))
        # print "current mixing proportion: ", m.mixing_proportion.omega
        M = 2 * self.kernel.gradient(y, self.Z)
        H = Kernel.centring_matrix(len(self.Z))

        for ii in range(self.num_eigen):
            Sigma = self.gamma ** 2 * eye(len(y)) + \
            self.nu2 * (M.T).dot(H.dot(outer(self.eigvectors[:, ii], self.eigvectors[:, ii]).dot(H.dot(M))))
            m.components[ii] = Gaussian(y, Sigma)
        return m