diff options
author | tlatorre <tlatorre@uchicago.edu> | 2020-08-17 11:52:51 -0500 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2020-08-17 11:52:51 -0500 |
commit | 1e3e7ffe1e233b7a58cbd3b7245f39446868b3b2 (patch) | |
tree | 8071e408b9e3aa1aa197db3fb260d5300c5245a3 /utils/chi2 | |
parent | ed8e1cd3c1a88649f50449f5c64e305463f001a8 (diff) | |
download | sddm-1e3e7ffe1e233b7a58cbd3b7245f39446868b3b2.tar.gz sddm-1e3e7ffe1e233b7a58cbd3b7245f39446868b3b2.tar.bz2 sddm-1e3e7ffe1e233b7a58cbd3b7245f39446868b3b2.zip |
simplify likelihood calculation in chi2
Diffstat (limited to 'utils/chi2')
-rwxr-xr-x | utils/chi2 | 13 |
1 files changed, 5 insertions, 8 deletions
@@ -110,14 +110,11 @@ def make_nll(data, mc_hists): nll = 0 for id in data_hists: - N = data_hists[id].sum() - nll -= poisson.logpmf(N,mc_hists[id].sum()*x[0]) - if N > 0: - p = mc_hists[id]/mc_hists[id].sum() - # Fix a bug in scipy(). See https://github.com/scipy/scipy/issues/8235 (I think). - p += 1e-10 - p /= p.sum() - nll -= multinomial.logpmf(data_hists[id],N,p) + oi = data_hists[id].sum() + ei = mc_hists[id] + EPSILON + N = oi.sum() + n = ei.sum() + nll -= -N - np.sum(gammaln(oi+1)) + np.sum(oi*np.log(ei)) return nll - norm.logpdf(x[1],ENERGY_SCALE_MEAN,ENERGY_SCALE_UNCERTAINTY) return nll |