def run_experiment(experiment, data, run, initial_sample=None): mcmc = MCMC(data=data, experiment=experiment) mcmc.log_setup() # Sample mcmc.sample(initial_sample=initial_sample) # Save samples to file mcmc.log_statistics() mcmc.save_samples(run=run) # Use the last sample as the new initial sample return mcmc.samples['last_sample']
def run_experiment(experiment, data, run): mcmc = MCMC(data=data, experiment=experiment) mcmc.log_setup() # Warm-up mcmc.warm_up() # Sample from posterior mcmc.sample() # Save samples to file mcmc.log_statistics() mcmc.save_samples(run=run) # Use the last sample as the new initial sample return mcmc.samples['last_sample']
exp = Experiment() exp.load_config( config_file='experiments/simulation/sim_exp2/config.json', custom_settings={'model': { 'INHERITANCE': IN }}) exp.log_experiment() # 2. Simulate contact areas sim = Simulation(experiment=exp) sim.run_simulation() sim.log_simulation() # 3. Define MCMC mc = MCMC(data=sim, experiment=exp) mc.log_setup() # Rerun experiment to check for consistency for run in range(exp.config['mcmc']['N_RUNS']): # 4. Sample from posterior mc.warm_up() mc.sample() # 5. Evaluate ground truth mc.eval_ground_truth() # 6. Log sampling statistics and save samples to file mc.log_statistics() mc.save_samples(run=run)