diff options
author | tlatorre <tlatorre@uchicago.edu> | 2020-07-27 11:58:46 -0500 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2020-07-27 11:58:46 -0500 |
commit | b72e3949e0de63059ec5a789eaf8b1124550c3f9 (patch) | |
tree | 45f109a2b112dbef980de6c5cdce31b49bc87428 /utils | |
parent | 51f7458944d0b3a84ab051e7f11437e1a352e638 (diff) | |
download | sddm-b72e3949e0de63059ec5a789eaf8b1124550c3f9.tar.gz sddm-b72e3949e0de63059ec5a789eaf8b1124550c3f9.tar.bz2 sddm-b72e3949e0de63059ec5a789eaf8b1124550c3f9.zip |
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.
Diffstat (limited to 'utils')
-rw-r--r-- | utils/sddm/stats.py | 6 |
1 files changed, 1 insertions, 5 deletions
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): """ |