Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing tension statistics #333

Open
wants to merge 63 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
c0946bd
Added Will's example Class for tension calculator
DilyOng Aug 24, 2023
70c0aa4
Changed Version from 2.3.0 to 2.4.0
DilyOng Aug 24, 2023
ee1db5b
Added Class tension
DilyOng Aug 31, 2023
ffd5fae
Merge branch 'master' into tension
lukashergt Sep 30, 2023
a3d06b5
version bump to 2.5.0
lukashergt Sep 30, 2023
4a5d4b5
Created a function called tension_stats for tension statistics calcul…
DilyOng Oct 13, 2023
38d31c2
Added logLmax to the function anesthetic.examples.perfect_ns.correlat…
DilyOng Oct 13, 2023
932a201
Clean up old tension statistics files. Put the correlated guassian li…
DilyOng Oct 13, 2023
4046bc3
Merge branch 'tension' of github.com:handley-lab/anesthetic into tension
DilyOng Oct 13, 2023
de17f04
Updated logLmax
DilyOng Oct 13, 2023
6ab8e4f
remove DS_Store
AdamOrmondroyd Oct 14, 2023
3698669
Merge branch 'master' into tension
AdamOrmondroyd Oct 14, 2023
aa0c177
Added a file tension.py to anesthetic/anesthetic and it contains a fu…
DilyOng Oct 26, 2023
2f472b5
Updated the tests/test_tension_stats.py file for flake8 compliance. A…
DilyOng Oct 26, 2023
5209ad2
Updated tests/test_tension_stats.py
DilyOng Dec 5, 2023
6fb5fe0
Updated anesthetic/tests/test_tension_stats.py. Now it tests whether …
DilyOng Mar 4, 2024
151a91d
Merge branch 'master' into tension
williamjameshandley Mar 5, 2024
b0994b3
bump version to 2.9.0
williamjameshandley Mar 5, 2024
aec6a25
Deleted duplicate files.
DilyOng Mar 5, 2024
46ec095
Merge branch 'tension' of github.com:handley-lab/anesthetic into tension
DilyOng Mar 5, 2024
be72001
Merge branch 'master' into tension
williamjameshandley Mar 18, 2024
03b9b1c
Reorganised tests
williamjameshandley Mar 18, 2024
9dd5ca1
numpy linalg
williamjameshandley Mar 18, 2024
e82f125
For anesthetic.tension.tension_stats(), I 1) added docstrings, 2) add…
DilyOng Mar 20, 2024
979f621
Added docstring in public module.
DilyOng Mar 21, 2024
84c8e6e
Fixed pydocstyle issue.
DilyOng Mar 21, 2024
9909190
Fixed pydocstyle issue.
DilyOng Mar 21, 2024
6723f4c
In test_tension.py, 1) added a test for latex labels, and 2) changed …
DilyOng Apr 4, 2024
9739361
Changed V
DilyOng Apr 4, 2024
25ab2c1
typographical changes
williamjameshandley Apr 5, 2024
1691a02
both tests correct
williamjameshandley Apr 5, 2024
110029a
Correction to docstring kl
williamjameshandley Apr 5, 2024
89fab36
Further docstring updates
williamjameshandley Apr 5, 2024
8f2e60a
Corrected typo
williamjameshandley Apr 8, 2024
290f257
Merge branch 'master' into tension
lukashergt Apr 8, 2024
815a7e5
fix link in docstring
lukashergt Apr 8, 2024
ab2d14e
add anesthetic.read.csv module to documentation
lukashergt Apr 8, 2024
c11c5f6
add anesthetic.tension module to documentation
lukashergt Apr 8, 2024
d1f1c2a
fix links and some formatting issues in `tension.py` docstrings
lukashergt Apr 8, 2024
fbd733e
Merge branch 'master' into tension
williamjameshandley Apr 9, 2024
d4659bd
Merge branch 'master' into tension
lukashergt Apr 9, 2024
877d79d
Merge branch 'master' into tension
williamjameshandley Apr 9, 2024
e568bfd
Merge branch 'master' into tension
lukashergt Apr 9, 2024
4947c69
Updated the docstrings in anesthetic/tension.py.
DilyOng Apr 14, 2024
7a10785
Updated docstrings
williamjameshandley Sep 19, 2024
970f431
Merge branch 'master' into tension
williamjameshandley Sep 19, 2024
69c932a
Updated docstring to avoid Samples
williamjameshandley Sep 19, 2024
7e90ac5
replaced \\m
williamjameshandley Sep 19, 2024
75d3067
Further string corrections
williamjameshandley Sep 19, 2024
740eacf
Further debugging docstrings
williamjameshandley Sep 19, 2024
d236f34
Logarithmic -> Logarithm
williamjameshandley Sep 19, 2024
79838dd
Merge branch 'master' into tension
lukashergt Sep 27, 2024
73d6180
correct spelling of compatible
lukashergt Sep 27, 2024
5675e25
surround `@` by spaces
lukashergt Sep 27, 2024
a7b7fb5
remove occurences of missing leading 0, e.g. `.01`
lukashergt Sep 27, 2024
e3bf650
use `ln` rather than `log` for the latex labels
lukashergt Sep 27, 2024
9dae22f
streamline and speed up tension tests a bit
lukashergt Sep 27, 2024
8c70f2f
make tension docstring more readable
lukashergt Sep 27, 2024
88b7ec6
optionally allow for passing a pre-computed stats instance to tension…
lukashergt Sep 27, 2024
51c0975
simplify tension tests and add test for direct input of nested sampli…
lukashergt Sep 27, 2024
0649d53
Update README.rst
lukashergt Sep 27, 2024
6b07788
Update _version.py
lukashergt Sep 27, 2024
ce82e13
Merge branch 'master' into tension
lukashergt Sep 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
anesthetic: nested sampling post-processing
===========================================
:Authors: Will Handley and Lukas Hergt
:Version: 2.3.0
:Version: 2.4.0
:Homepage: https://github.com/handley-lab/anesthetic
:Documentation: http://anesthetic.readthedocs.io/

Expand Down
2 changes: 1 addition & 1 deletion anesthetic/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.3.0'
__version__ = '2.4.0'
48 changes: 48 additions & 0 deletions tension_calculator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
class tension_calculator(dict):
"""Class for computing tension metrics

Parameters
----------
samples : dict
Dictionary of NestedSamples
nsamples : int
Number of samples to use for computing statistics
"""
def __init__(self, samples, nsamples=1000):
for k, v in tqdm.tqdm(samples.items()):
self[k] = v.stats(nsamples)

def union(self, A, B):
A_ = set(A.split('_'))
B_ = set(B.split('_'))
return '_'.join(sorted(list(A_.union(B_))))

def intersection(self, A, B):
A_ = set(A.split('_'))
B_ = set(B.split('_'))
return '_'.join(sorted(list(A_.intersection(B_))))

def stat(self, A, B, stat):
union = self.union(A, B)
intersection = self.intersection(A, B)
return self[union][stat] - self[A][stat] - self[B][stat] + self[intersection][stat]

def logR(self, A, B):
return self.stat(A, B, 'logZ')

def logS(self, A, B):
return self.stat(A, B, 'logL_P')

def d(self, A, B):
return self.stat(A, B, 'd_G')
williamjameshandley marked this conversation as resolved.
Show resolved Hide resolved

def D_KL(self, A, B):
return self.stat(A, B, 'D_KL')

def p(self, A, B, d=None):
logS = self.logS(A, B)
if d is None:
d = self.d(A, B)
else:
d = np.ones_like(logS)*d
return scipy.stats.chi2.sf(d[d>0]-2*logS[d>0], d[d>0])
Loading