Skip to content
Snippets Groups Projects
Commit db20f82f authored by Jack Christopher Hutchinson Rolph's avatar Jack Christopher Hutchinson Rolph
Browse files

Update PeakOTron.py

parent 0c10e764
No related branches found
No related tags found
No related merge requests found
......@@ -62,9 +62,11 @@ class BandWidthOptimiser:
loss = np.log((self.N-1)*bw) - np.sum(np.log(y_kde))
return loss
except:
return np.nan
loss = np.log((self.N-1)*bw) + self.eps_inv
return loss
def _PPF(self, data):
""" Compute ECDF """
......@@ -89,6 +91,7 @@ class BandWidthOptimiser:
self.last_arg = None
self.func_code = FakeFuncCode(self._Dummy, dock=True)
self.eps = np.finfo(np.float64).eps * 10
self.eps_inv = 1/self.eps
def __call__(self, *arg):
......@@ -493,14 +496,9 @@ class PeakOTron:
minuit_kde.migrad(ncall= self._n_call_minuit,
iterate =self._n_iterations_minuit)
if(minuit_kde.valid):
bw = minuit_kde.values["bw"]
if(self._verbose):
print("KDE Bandwidth optimised to: {0}".format(bw))
else:
if(self._verbose):
print("KDE Bandwidth optimisation failed. Defaulting to Improved Sheather Jones.")
bw = "ISJ"
except:
if(self._verbose):
print("KDE Bandwidth optimisation failed. Defaulting to Improved Sheather Jones.")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment