Exemplo n.º 1
0
    aggs = []

    for i in range(num_repetitions):
        job = rw_generator_isotropic(num_warmup, thin_step)
        logger.info("Repetition %d/%d, %s" %
                    (i + 1, num_repetitions, job.get_parameter_fname_suffix()))
        aggs += [engine.submit_job(job)]

    engine.wait_for_all()

    for i, agg in enumerate(aggs):
        agg.finalize()
        result = agg.get_final_result()
        agg.clean_up()

        if isinstance(engine, SerialComputationEngine):
            plot_mcmc_result(result, D1=0, D2=1)
            agg.store_fire_and_forget_result(folder="", job_name="")

        # print some summary stats
        accepted = result.accepted
        avg_ess = result.posterior_statistics["avg_ess"]

        time = result.time_taken_sampling
        time_set_up = result.time_taken_set_up

        logger.info("Repetition %d" % i)
        logger.info("Average acceptance probability: %.2f" % np.mean(accepted))
        logger.info("Average ESS: %.2f" % avg_ess)
        logger.info("Total time: %.2f" % (time + time_set_up))
Exemplo n.º 2
0
         accepted = result.accepted
         avg_ess = result.posterior_statistics["avg_ess"]
         min_ess = result.posterior_statistics["min_ess"]
         
         time = result.time_taken_sampling
         time_set_up = result.time_taken_set_up
     
         logger.info("Average acceptance probability: %.2f" % np.mean(accepted))
         logger.info("Average ESS: %.2f" % avg_ess)
         logger.info("Minimum ESS: %.2f" % min_ess)
         logger.info("Total time: %.2f" % (time + time_set_up))
         logger.info("Average ESS/s: %.2f" % (avg_ess / (time + time_set_up)))
         logger.info("Minimum ESS/s: %.2f" % (min_ess / (time + time_set_up)))
         
         if False:
             plot_mcmc_result(result, D1=1, D2=6)
     
     inds = np.arange(warmup, result.num_iterations, step=thin)
     for i in inds:
         samples += [result.samples[i]]
 
 samples = np.array(samples)
 samples = samples[np.random.permutation(len(samples))]
 logger.info("Extracted %d samples in dimension %d" % (samples.shape[0], samples.shape[1]))
 if True:
     with open("benchmark_samples.arr", 'w+') as f:
         np.save(f, samples)
 
 D_pairs = []
 
 for D1 in range(9):