def stat_sum(self): """Total likelihood given the current model parameters.""" counts, npred = self._counts_data, self.npred().data if self.mask is not None: return cash_sum_cython(counts[self.mask.data], npred[self.mask.data]) else: return cash_sum_cython(counts.ravel(), npred.ravel())
def f_cash(x, counts, background, model): """Wrapper for cash statistics, that defines the model function. Parameters ---------- x : float Model amplitude. counts : `~numpy.ndarray` Count image slice, where model is defined. background : `~numpy.ndarray` Background image slice, where model is defined. model : `~numpy.ndarray` Source template (multiplied with exposure). """ return cash_sum_cython(counts.ravel(), (background + x * FLUX_FACTOR * model).ravel())
def test_cash_sum_cython(test_data): counts = np.array(test_data["n_on"], dtype=float) npred = np.array(test_data["mu_sig"], dtype=float) stat = stats.cash_sum_cython(counts=counts, npred=npred) ref = stats.cash(counts, npred).sum() assert_allclose(stat, ref)
def stat_sum(self, norm): """Stat sum""" return cash_sum_cython(self.counts.ravel(), self.npred(norm).ravel())