-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun_NS_NestedSampleIt_Builder_dimerization_model.py
39 lines (35 loc) · 1.6 KB
/
run_NS_NestedSampleIt_Builder_dimerization_model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'''
Generated by nestedsample_it
Gleipnir NS run script for dimerization_model.py
'''
from dimerization_model_builder import builder
import numpy as np
from gleipnir.pysb_utilities import NestedSampleIt
if __name__ == '__main__':
# Initialize PySB solver object for running simulations.
# Simulation timespan should match experimental data.
tspan = np.linspace(0,1, num=51)
# USER must add commands to import/load any experimental
# data for use in the likelihood function!
experiments_avg = np.load('dimerization_model_dimer_data.npy')
experiments_sd = np.load('dimerization_model_dimer_sd.npy')
# Setup the Nested Sampling run
population_size = 100
observable_data = dict()
time_idxs = list(range(len(tspan)))
observable_data['A_dimer'] = tuple((experiments_avg, experiments_sd, time_idxs))
# Initialize the NestedSampleIt instance with the model details.
sample_it = NestedSampleIt(builder.model, observable_data, tspan, builder=builder)
# Now build the NestedSampling object. -- All inputs are
# optional keyword arguments.
nested_sampler = sample_it(ns_version='built-in',
ns_population_size=population_size,
ns_kwargs=dict(),
log_likelihood_type='snlpdf')
print(len(nested_sampler.sampled_parameters))
# Then you can run the nested sampler.
log_evidence, log_evidence_error = nested_sampler.run(verbose=True)
# Retrieve the evidence
evidence = nested_sampler.evidence
print("evidence: ",evidence)
print("log_evidence: ", np.log(evidence))