Skip to content

Commit

Permalink
Redefined I = D_A + D_B - D_AB, and logS = logR - I, such that I is t…
Browse files Browse the repository at this point in the history
…he previous log I, the logarithm is incorporated in I. Updated all relevant lines in anesthetic/tension.py and tests/test_tension.py.
  • Loading branch information
DilyOng committed Feb 5, 2025
1 parent 7717b04 commit 71325d7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions anesthetic/tension.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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']
Expand Down
8 changes: 4 additions & 4 deletions tests/test_tension.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}$',
Expand Down Expand Up @@ -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}$',
Expand Down

0 comments on commit 71325d7

Please sign in to comment.