Ejemplo n.º 1
0
    distribution = Banana(dimension=8, bananicity=0.03, V=100)
    sigma = GaussianKernel.get_sigma_median_heuristic(
        distribution.sample(1000).samples)
    sigma = 10
    print "using sigma", sigma
    kernel = GaussianKernel(sigma=sigma)

    burnin = 20000
    num_iterations = 40000

    mcmc_sampler = KameleonWindowLearnScale(distribution,
                                            kernel,
                                            stop_adapt=burnin)
    mean_est = zeros(distribution.dimension, dtype="float64")
    cov_est = 1.0 * eye(distribution.dimension)
    cov_est[0, 0] = distribution.V
    #mcmc_sampler = AdaptiveMetropolisLearnScale(distribution, mean_est=mean_est, cov_est=cov_est)
    #mcmc_sampler = AdaptiveMetropolis(distribution, mean_est=mean_est, cov_est=cov_est)
    #mcmc_sampler = StandardMetropolis(distribution)

    start = zeros(distribution.dimension, dtype="float64")
    mcmc_params = MCMCParams(start=start,
                             num_iterations=num_iterations,
                             burnin=burnin)

    mcmc_chain = MCMCChain(mcmc_sampler, mcmc_params)
    mcmc_chain.append_mcmc_output(StatisticsOutput())

    experiment = SingleChainExperiment(mcmc_chain, experiment_dir)
    experiment.run()
Ejemplo n.º 2
0
                                         cov_est=cov_est))
        mcmc_samplers.append(
            AdaptiveMetropolis(distribution,
                               mean_est=mean_est,
                               cov_est=cov_est))
        #
        #        num_eigen = distribution.dimension
        #        mcmc_samplers.append(AdaptiveMetropolisPCA(distribution, num_eigen=num_eigen, mean_est=mean_est, cov_est=cov_est))
        #
        mcmc_samplers.append(StandardMetropolis(distribution))

        start = zeros(distribution.dimension, dtype="float64")
        mcmc_params = MCMCParams(start=start,
                                 num_iterations=num_iterations,
                                 burnin=burnin)

        mcmc_chains = [
            MCMCChain(mcmc_sampler, mcmc_params)
            for mcmc_sampler in mcmc_samplers
        ]
        for mcmc_chain in mcmc_chains:
            mcmc_chain.append_mcmc_output(StatisticsOutput())

        experiments = [
            SingleChainExperiment(mcmc_chain, experiment_dir)
            for mcmc_chain in mcmc_chains
        ]

        for experiment in experiments:
            ClusterTools.submit_experiment(experiment)
    KameleonWindowLearnScale
from kameleon_mcmc.mcmc.samplers.StandardMetropolis import StandardMetropolis


if __name__ == '__main__':
    experiment_dir = str(os.path.abspath(sys.argv[0])).split(os.sep)[-1].split(".")[0] + os.sep
    
    distribution = Flower(amplitude=6, frequency=6, variance=1, radius=10, dimension=8)
    sigma = 5
    kernel = GaussianKernel(sigma=sigma)
    
    
    burnin = 60000
    num_iterations = 120000
    
    #mcmc_sampler = KameleonWindowLearnScale(distribution, kernel, stop_adapt=burnin)
    mean_est = zeros(distribution.dimension, dtype="float64")
    cov_est = 1.0 * eye(distribution.dimension)
    #mcmc_sampler = AdaptiveMetropolisLearnScale(distribution, mean_est=mean_est, cov_est=cov_est)
    #mcmc_sampler = AdaptiveMetropolis(distribution, mean_est=mean_est, cov_est=cov_est)
    mcmc_sampler = StandardMetropolis(distribution)
        
    start = zeros(distribution.dimension, dtype="float64")
    mcmc_params = MCMCParams(start=start, num_iterations=num_iterations, burnin=burnin)
    
    mcmc_chain = MCMCChain(mcmc_sampler, mcmc_params)
    mcmc_chain.append_mcmc_output(StatisticsOutput())
    
    experiment = SingleChainExperiment(mcmc_chain, experiment_dir)
    experiment.run()
Ejemplo n.º 4
0
    print "using sigma", sigma
    kernel = GaussianKernel(sigma=sigma)
    
    for i in range(n):
        
        mcmc_samplers = []
        
        burnin=50000
        num_iterations=500000
        
        #mcmc_samplers.append(KameleonWindowLearnScale(distribution, kernel, stop_adapt=burnin))
        
        #mean_est = zeros(distribution.dimension, dtype="float64")
        #cov_est = 1.0 * eye(distribution.dimension)
        #cov_est[0, 0] = distribution.V
        #mcmc_samplers.append(AdaptiveMetropolisLearnScale(distribution, mean_est=mean_est, cov_est=cov_est))
        #mcmc_samplers.append(AdaptiveMetropolis(distribution, mean_est=mean_est, cov_est=cov_est))
        mcmc_samplers.append(StandardMetropolis(distribution))
        
        start = zeros(distribution.dimension, dtype="float64")
        mcmc_params = MCMCParams(start=start, num_iterations=num_iterations, burnin=burnin)
        
        mcmc_chains = [MCMCChain(mcmc_sampler, mcmc_params) for mcmc_sampler in mcmc_samplers]
        for mcmc_chain in mcmc_chains:
            mcmc_chain.append_mcmc_output(StatisticsOutput())
        
        experiments = [SingleChainExperiment(mcmc_chain, experiment_dir) for mcmc_chain in mcmc_chains]
        
        for experiment in experiments:
            ClusterTools.submit_experiment(experiment)