コード例 #1
0
    def run_experiment(path: Path, custom_settings: dict):
        # 1. Initialize the experiment
        exp = Experiment()
        exp.load_config(config_file=path / 'config.json',
                        custom_settings=custom_settings)

        if exp.config['model']['n_areas'] == "TBD":
            exp.config['model']['n_areas'] = 2

        # 2. Simulate contact areas
        sim = Simulation(experiment=exp)
        sim.run_simulation()

        # 3. Define MCMC
        mc = MCMC(data=sim, experiment=exp)

        # 4. Warm-up sampler and 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.save_samples(run=0)
コード例 #2
0
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']
コード例 #3
0
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']
コード例 #4
0
ファイル: run_sim_exp2.py プロジェクト: noorefrat/sbayes
        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)