コード例 #1
0
ファイル: KameleonTest.py プロジェクト: mgong2/kameleon-mcmc
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()
コード例 #2
0
ファイル: GFunction.py プロジェクト: mgong2/kameleon-mcmc
 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()