Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Use the internal representation (see the Parameter class)
parameter._set_internal_value(trial_values[i])
# Now profile out nuisance parameters and compute the new value
# for the likelihood
summed_log_likelihood = 0
for dataset in list(self._data_list.values()):
try:
this_log_like = dataset.inner_fit()
except ModelAssertionViolation:
# This is a zone of the parameter space which is not allowed. Return
# a big number for the likelihood so that the fit engine will avoid it
custom_warnings.warn(
"Fitting engine in forbidden space: %s" % (trial_values,),
custom_exceptions.ForbiddenRegionOfParameterSpace,
)
return minimization.FIT_FAILED
except:
# Do not intercept other errors
raise
def _log_like(self, trial_values):
"""Compute the log-likelihood"""
# Get the value of the log-likelihood for this parameters
try:
# Loop over each dataset and get the likelihood values for each set
log_like_values = [ dataset.get_log_like() for dataset in self._data_list.values() ]
# log_like_values = map(lambda dataset: dataset.get_log_like(), self._data_list.values())
except ModelAssertionViolation:
# Fit engine or sampler outside of allowed zone
return -np.inf
except:
# We don't want to catch more serious issues
raise
# Sum the values of the log-like
log_like = np.sum(log_like_values)
if not np.isfinite(log_like):