def __init__(
        self, distribution, kernel, nu2=0.1, gamma=None, sample_discard=500, num_samples_Z=1000, stop_adapt=20000
    ):

        Kameleon.__init__(self, distribution, kernel, Z=None, nu2=nu2, gamma=gamma)

        assert stop_adapt > sample_discard
        assert num_samples_Z > 0

        self.sample_discard = sample_discard
        self.num_samples_Z = num_samples_Z
        self.stop_adapt = stop_adapt
 def __init__(self, distribution, kernel, Z, nu2=0.1, gamma=0.1, num_eigen=10):
     Kameleon.__init__(self, distribution, kernel, Z, nu2, gamma)
     self.num_eigen = num_eigen
     if Z is None:
         self.Kc = None
         self.eigvalues = None
         self.eigvectors = None
     else:
         K = self.kernel.kernel(Z)
         H = Kernel.centring_matrix(len(self.Z))
         self.Kc = H.dot(K.dot(H))
         u, s, _ = svd(self.Kc)
         self.eigvalues = s[0 : self.num_eigen]
         self.eigvectors = u[:, 0 : self.num_eigen]
    def __init__(self, distribution, kernel, nu2=0.1, gamma=None, \
                 sample_discard=500, num_samples_Z=1000, stop_adapt=20000):

        Kameleon.__init__(self,
                          distribution,
                          kernel,
                          Z=None,
                          nu2=nu2,
                          gamma=gamma)

        assert (stop_adapt > sample_discard)
        assert (num_samples_Z > 0)

        self.sample_discard = sample_discard
        self.num_samples_Z = num_samples_Z
        self.stop_adapt = stop_adapt
 def __str__(self):
     s = self.__class__.__name__ + "=["
     s += "sample_discard=" + str(self.sample_discard)
     s += ", num_samples_Z=" + str(self.num_samples_Z)
     s += ", stop_adapt=" + str(self.stop_adapt)
     s += ", " + Kameleon.__str__(self)
     s += "]"
     return s
 def __str__(self):
     s = self.__class__.__name__ + "=["
     s += "sample_discard=" + str(self.sample_discard)
     s += ", num_samples_Z=" + str(self.num_samples_Z)
     s += ", stop_adapt=" + str(self.stop_adapt)
     s += ", " + Kameleon.__str__(self)
     s += "]"
     return s
Exemple #6
0
 def plot_proposal(self, ys):
     # evaluate density itself
     Visualise.visualise_distribution(self.distribution, Z=self.Z, Xs=self.Xs, Ys=self.Ys)
     
     # precompute constants of proposal
     mcmc_hammer = Kameleon(self.distribution, self.kernel, self.Z, \
                              self.nu2, self.gamma)
     
     # plot proposal around each y
     for y in ys:
         mu, L_R = mcmc_hammer.compute_constants(y)
         gaussian = Gaussian(mu, L_R, is_cholesky=True)
         
         hold(True)
         Visualise.contour_plot_density(gaussian)
         hold(False)
         draw()
Exemple #7
0
 def __init__(self,
              distribution,
              kernel,
              Z,
              nu2=0.1,
              gamma=0.1,
              num_eigen=10):
     Kameleon.__init__(self, distribution, kernel, Z, nu2, gamma)
     self.num_eigen = num_eigen
     if Z is None:
         self.Kc = None
         self.eigvalues = None
         self.eigvectors = None
     else:
         K = self.kernel.kernel(Z)
         H = Kernel.centring_matrix(len(self.Z))
         self.Kc = H.dot(K.dot(H))
         u, s, _ = svd(self.Kc)
         self.eigvalues = s[0:self.num_eigen]
         self.eigvectors = u[:, 0:self.num_eigen]
Exemple #8
0
def main():
    distribution = Banana(dimension=8)

    sigma = 5
    print "using sigma", sigma
    kernel = GaussianKernel(sigma=sigma)

    mcmc_sampler = Kameleon(distribution, kernel,
                            distribution.sample(100).samples)

    start = zeros(distribution.dimension)
    mcmc_params = MCMCParams(start=start, num_iterations=20000)
    chain = MCMCChain(mcmc_sampler, mcmc_params)

    chain.append_mcmc_output(StatisticsOutput(plot_times=True))
    chain.run()
 def init(self, start):
     Kameleon.init(self, start)
     self.Z = None
 def init(self, start):
     Kameleon.init(self, start)
     self.Z = None