From 031683be76a85265512c81081d8ae03b96fd1342 Mon Sep 17 00:00:00 2001 From: Oliver Majersky Date: Mon, 22 Jul 2019 11:10:58 +0200 Subject: [PATCH 1/3] Add configurable option for sampler initialization --- fbu/PyFBU.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fbu/PyFBU.py b/fbu/PyFBU.py index 8cf0ac4..86061aa 100644 --- a/fbu/PyFBU.py +++ b/fbu/PyFBU.py @@ -22,6 +22,7 @@ def __init__(self,data=[],response=[],background={}, self.nCores = 1 # number of CPU threads to utilize self.nChains = 2 # number of Markov chains to sample self.nuts_kwargs = None + self.init_method = 'jitter+adapt_diag' self.discard_tuned_samples = True # whether to discard tuning steps from posterior self.lower = lower # lower sampling bounds self.upper = upper # upper sampling bounds @@ -156,9 +157,6 @@ def unfold(): from datetime import timedelta init_time = time.time() - print(self.nuts_kwargs) - - if self.mode: map_estimate = mc.find_MAP(model=model, method=self.MAP_method) print (map_estimate) @@ -169,6 +167,7 @@ def unfold(): trace = mc.sample(self.nMCMC,tune=self.nTune,cores=self.nCores, chains=self.nChains, nuts_kwargs=self.nuts_kwargs, + init=self.init_method, n_init=200000, discard_tuned_samples=self.discard_tuned_samples, progressbar=self.sampling_progressbar) finish_time = time.time() From 6ab66fd84d7d2117b36697ebaaaffd0e3809ff2a Mon Sep 17 00:00:00 2001 From: Oliver Majersky Date: Thu, 15 Aug 2019 16:01:50 +0200 Subject: [PATCH 2/3] Print MAP minimization steps in verbose mode. --- fbu/PyFBU.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fbu/PyFBU.py b/fbu/PyFBU.py index 86061aa..3d76497 100644 --- a/fbu/PyFBU.py +++ b/fbu/PyFBU.py @@ -158,7 +158,8 @@ def unfold(): init_time = time.time() if self.mode: - map_estimate = mc.find_MAP(model=model, method=self.MAP_method) + map_estimate = mc.find_MAP(model=model, method=self.MAP_method, + options={'disp':self.verbose}) print (map_estimate) self.MAP = map_estimate self.trace = [] From 35219c944fbdfd6f96f85bb6459f748b872e774c Mon Sep 17 00:00:00 2001 From: Oliver Majersky Date: Thu, 3 Oct 2019 10:19:14 +0200 Subject: [PATCH 3/3] Accesible PyMC summary of trace and actual trace object. --- fbu/PyFBU.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fbu/PyFBU.py b/fbu/PyFBU.py index 3d76497..df1b7be 100644 --- a/fbu/PyFBU.py +++ b/fbu/PyFBU.py @@ -178,7 +178,8 @@ def unfold(): )) self.trace = [trace['truth%d'%bin][:] for bin in range(truthdim)] - #self.trace = [copy.deepcopy(trace['truth%d'%bin][:]) for bin in range(truthdim)] + self.__trace__ = trace # for full access + self.trace_summary = mc.summary(trace) self.nuisancestrace = {} if nbckg>0: for name,err in zip(backgroundkeys,backgroundnormsysts):