From 71325d7ead7a14b2ee2291d43446f2331bf50409 Mon Sep 17 00:00:00 2001 From: dilyong Date: Wed, 5 Feb 2025 14:32:03 +0000 Subject: [PATCH] Redefined I = D_A + D_B - D_AB, and logS = logR - I, such that I is the previous log I, the logarithm is incorporated in I. Updated all relevant lines in anesthetic/tension.py and tests/test_tension.py. --- anesthetic/tension.py | 4 ++-- tests/test_tension.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/anesthetic/tension.py b/anesthetic/tension.py index 4eede72f..01538f52 100644 --- a/anesthetic/tension.py +++ b/anesthetic/tension.py @@ -17,7 +17,7 @@ def stats(A, B, AB, nsamples=None, beta=None): # noqa: D301 - ``I``: information ratio .. math:: - I = exp(D_{KL}^{A} + D_{KL}^{B} - D_{KL}^{AB}) + I = D_{KL}^{A} + D_{KL}^{B} - D_{KL}^{AB} - ``logS``: suspiciousness @@ -90,7 +90,7 @@ def stats(A, B, AB, nsamples=None, beta=None): # noqa: D301 samples['logR'] = statsAB['logZ'] - statsA['logZ'] - statsB['logZ'] samples.set_label('logR', r'$\ln\mathcal{R}$') - samples['I'] = np.exp(statsA['D_KL'] + statsB['D_KL'] - statsAB['D_KL']) + samples['I'] = statsA['D_KL'] + statsB['D_KL'] - statsAB['D_KL'] samples.set_label('I', r'$\mathcal{I}$') samples['logS'] = statsAB['logL_P'] - statsA['logL_P'] - statsB['logL_P'] diff --git a/tests/test_tension.py b/tests/test_tension.py index dc78231b..2425e9cc 100644 --- a/tests/test_tension.py +++ b/tests/test_tension.py @@ -46,10 +46,10 @@ def test_tension_stats_compatible_gaussian(): logS_exact = d / 2 - dmu_cov_dmu_AB / 2 assert s.logS.mean() == approx(logS_exact, abs=3*s.logS.std()) - I_exact = np.exp(logV - d / 2 - slogdet(2*np.pi*(covA+covB))[1] / 2) + I_exact = logV - d / 2 - slogdet(2*np.pi*(covA+covB))[1] / 2 assert s.I.mean() == approx(I_exact, abs=3*s.I.std()) - assert s.logS.mean() == approx(s.logR.mean() - np.log(s.I).mean(), + assert s.logS.mean() == approx(s.logR.mean() - s.I.mean(), abs=3*s.logS.std()) assert s.get_labels().tolist() == ([r'$\ln\mathcal{R}$', @@ -106,10 +106,10 @@ def test_tension_stats_incompatible_gaussian(): logS_exact = d / 2 - dmu_cov_dmu_AB / 2 assert s.logS.mean() == approx(logS_exact, abs=3*s.logS.std()) - I_exact = np.exp(logV - d / 2 - slogdet(2*np.pi*(covA+covB))[1] / 2) + I_exact = logV - d / 2 - slogdet(2*np.pi*(covA+covB))[1] / 2 assert s.I.mean() == approx(I_exact, abs=3*s.I.std()) - assert s.logS.mean() == approx(s.logR.mean() - np.log(s.I).mean(), + assert s.logS.mean() == approx(s.logR.mean() - s.I.mean(), abs=3*s.logS.std()) assert s.get_labels().tolist() == ([r'$\ln\mathcal{R}$',