def get_log_like(self): """ Return the value of the log-likelihood with the current values for the parameters """ expectation = self._get_total_expectation() if self._is_poisson: # Poisson log-likelihood return np.sum( poisson_log_likelihood_ideal_bkg(self._y, np.zeros_like(self._y), expectation)) else: # Chi squared chi2_ = half_chi2(self._y, self._yerr, expectation) assert np.all(np.isfinite(chi2_)) return np.sum(chi2_) * (-1)
def get_current_value(self): # In this likelihood the background becomes part of the model, which means that # the uncertainty in the background is completely neglected model_counts = self._spectrum_plugin.get_model() loglike, _ = poisson_log_likelihood_ideal_bkg(self._spectrum_plugin.current_observed_counts, self._spectrum_plugin.current_scaled_background_counts, model_counts) return np.sum(loglike), None
def get_current_value(self, precalc_fluxes: Optional[np.array]=None): # In this likelihood the background becomes part of the model, which means that # the uncertainty in the background is completely neglected model_counts = self._spectrum_plugin.get_model(precalc_fluxes=precalc_fluxes) loglike, _ = poisson_log_likelihood_ideal_bkg( self._spectrum_plugin.current_observed_counts, self._spectrum_plugin.current_scaled_background_counts, model_counts, ) return nb_sum(loglike), None
def get_current_value(self): # In this likelihood the background becomes part of the model, which means that # the uncertainty in the background is completely neglected model_counts = self._spectrum_plugin.get_model() # we scale the background model to the observation background_model_counts = self._spectrum_plugin.get_background_model() * self._spectrum_plugin.scale_factor loglike, _ = poisson_log_likelihood_ideal_bkg(self._spectrum_plugin.current_observed_counts, background_model_counts, model_counts) bkg_log_like = self._spectrum_plugin.background_plugin.get_log_like() total_log_like = np.sum(loglike) + bkg_log_like return total_log_like, None
def get_log_like(self): """ Return the value of the log-likelihood with the current values for the parameters """ expectation = self._get_total_expectation() if self._is_poisson: # Poisson log-likelihood return np.sum(poisson_log_likelihood_ideal_bkg(self._y, np.zeros_like(self._y), expectation)) else: # Chi squared chi2_ = half_chi2(self._y, self._yerr, expectation) assert np.all(np.isfinite(chi2_)) return np.sum(chi2_) * (-1)
def _poisson_like(y, zeros, expectation): return np.sum( poisson_log_likelihood_ideal_bkg( y, zeros, expectation )[0] )