Commit 824a2c09 authored by Frank Dondelinger's avatar Frank Dondelinger
Browse files

Added line to calculate effective sample size at the end of MCMC run. Also fixed yaml warning.

parent 297fe828
......@@ -35,8 +35,9 @@ if __name__ == '__main__':
parser.add_option("--config", "-c", dest="config", default="ode_config.yaml",
help="configuration file")
options, args = parser.parse_args()
with open(options.config, 'r') as ymlfile:
config = yaml.load(ymlfile)
config = yaml.safe_load(ymlfile)
param = sanitise_parameter(config['parameter'])
settings = sanitise_settings(config['settings'])
......@@ -133,6 +134,7 @@ if __name__ == '__main__':
step_start = time.perf_counter()
samples, results = sample(num_final_samples,
init_state=joint_posterior[-1, :], scale=scale,)
joint_posterior = tf.concat([joint_posterior, samples], axis=0)
step_end = time.perf_counter()
print(f'Sampling step time {step_end - step_start}')
......@@ -147,6 +149,7 @@ if __name__ == '__main__':
print(f"Posterior mean: {np.mean(joint_posterior, axis=0)}")
print(f"ESS: {tfp.mcmc.effective_sample_size(samples)}")
with open('pi_beta_2020-03-29.pkl', 'wb') as f:
pkl.dump(joint_posterior, f)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment