From b72e3949e0de63059ec5a789eaf8b1124550c3f9 Mon Sep 17 00:00:00 2001 From: tlatorre Date: Mon, 27 Jul 2020 11:58:46 -0500 Subject: update how the negative log likelihood ratio is calculated I found a really simple form for the log likelihood ratio of a Poisson and multinomial likelihood. --- utils/sddm/stats.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'utils') diff --git a/utils/sddm/stats.py b/utils/sddm/stats.py index 593c888..5324eea 100644 --- a/utils/sddm/stats.py +++ b/utils/sddm/stats.py @@ -29,11 +29,7 @@ def nllr(samples,expected): p_samples /= p_samples.sum(-1)[:,np.newaxis] p_expected = expected.astype(np.double) + 1e-10 p_expected /= p_expected.sum() - # For some reason multinomial.logpmf([0,0,...],0,p) returns nan - mask = n == 0 - rv = poisson.logpmf(n,N) - poisson.logpmf(n,n) - rv[~mask] += multinomial.logpmf(samples[~mask],n[~mask],p_expected) - multinomial.logpmf(samples[~mask],n[~mask],p_samples[~mask]) - return -2*rv.squeeze()[()] + return 2*(N - n + (samples*np.log(np.where(samples == 0,1,samples)/expected)).sum(axis=-1)).squeeze()[()] def get_mc_hist_posterior(hist, data, norm): """ -- cgit