Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
def _chi2_like(y, yerr, expectation):

    chi2_ = half_chi2(y, yerr, expectation)

    assert np.all(np.isfinite(chi2_))

    return np.sum(chi2_) * (-1)
Exemplo n.º 3
0
    def get_current_value(self):
        chi2_ = half_chi2(self._spectrum_plugin.current_observed_counts,
                          self._spectrum_plugin.current_observed_count_errors,
                          self._spectrum_plugin.get_model())

        assert np.all(np.isfinite(chi2_))

        return np.sum(chi2_) * (-1), None
Exemplo n.º 4
0
    def get_current_value(self):
        chi2_ = half_chi2(self._spectrum_plugin.current_observed_counts,
                          self._spectrum_plugin.current_observed_count_errors,
                          self._spectrum_plugin.get_model())

        assert np.all(np.isfinite(chi2_))

        return np.sum(chi2_) * (-1), None
Exemplo n.º 5
0
    def get_current_value(self, precalc_fluxes: Optional[np.array]=None):
        
        model_counts = self._spectrum_plugin.get_model(precalc_fluxes=precalc_fluxes)

        chi2_ = half_chi2(
            self._spectrum_plugin.current_observed_counts,
            self._spectrum_plugin.current_observed_count_errors,
            model_counts,
        )

        assert np.all(np.isfinite(chi2_))

        return nb_sum(chi2_) * (-1), None
Exemplo n.º 6
0
    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)