Skip to content

Commit 9d02732

Browse files
modified lmax code
1 parent df290b1 commit 9d02732

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

smodels/statistics/analysesCombinations.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ def fun(mu):
173173
pass
174174
hessian = invh[0][0]
175175
nll_ = o.fun
176-
if hessian > 0.0 and nll_ < 998.0 and o.success: # found a maximum. all good.
176+
#removed if condition: "and nll_ < 998.0", because sometimes nll_ > 998.0. Not necessarily a bad thing?
177+
#However lmax = np.exp(-nll_) for large nll -> 0
178+
if hessian > 0.0 and o.success: # found a maximum. all good. #and nll_ < 998.0
177179
break
178180
# the hessian is negative meaning we found a maximum, not a minimum
179181
if hessian <= 0.0:
@@ -183,7 +185,7 @@ def fun(mu):
183185
)
184186
mu_hat = o.x[0]
185187
lmax = np.exp(-o.fun) # fun is *always* nll
186-
if hessian < 0.0 or nll_ > 998.0:
188+
if hessian < 0.0: #or nll_ > 998.0: again remove nll_ cut
187189
logger.error(
188190
"tried with several starting points to find maximum, always ended up in minimum. "
189191
"bailing out."
@@ -196,7 +198,7 @@ def fun(mu):
196198
retllh = lmax
197199
if return_nll:
198200
retllh = nll_
199-
ret = {"muhat": mu_hat, "sigma_mu": sigma_mu, "lmax": retllh}
201+
ret = {"muhat": mu_hat, "sigma_mu": sigma_mu, "lmax": retllh} #return nll_ too in the dictionary?
200202
return ret
201203

202204
def getUpperLimitOnMu(self, expected=False, allowNegativeSignals = False ):

0 commit comments

Comments
 (0)