From 45a8fda9e85a66baf5db5ffc4a3da623622e9e84 Mon Sep 17 00:00:00 2001 From: Ronald Kam Date: Fri, 1 Dec 2023 11:51:08 -0800 Subject: [PATCH 1/3] Update sampling efficiency Normalize by number of samples saved, not total number of MC iterations --- smol/moca/sampler/container.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/smol/moca/sampler/container.py b/smol/moca/sampler/container.py index 1603f5cbf..054c81551 100644 --- a/smol/moca/sampler/container.py +++ b/smol/moca/sampler/container.py @@ -134,9 +134,12 @@ def traced_values(self): return self._trace.names def sampling_efficiency(self, discard=0, flat=True): - """Return the sampling efficiency for chains.""" + """Return the sampling efficiency for chains. If the sampling is thinned + by > 1, this value becomes only an estimate for the true sampling efficiency, + as we do not know the efficiency of the discarded samples.""" + total_accepted = self._trace.accepted[discard:].sum(axis=0) - efficiency = total_accepted / (self._total_steps - discard) + efficiency = total_accepted / (self._nsamples - discard) if flat: efficiency = efficiency.mean() return efficiency From 55c0316a0342bc1c9356ea36bab1a9d850978191 Mon Sep 17 00:00:00 2001 From: Ronald Kam Date: Fri, 1 Dec 2023 11:55:46 -0800 Subject: [PATCH 2/3] Fix docstring --- smol/moca/sampler/container.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/smol/moca/sampler/container.py b/smol/moca/sampler/container.py index 054c81551..7d940fe10 100644 --- a/smol/moca/sampler/container.py +++ b/smol/moca/sampler/container.py @@ -134,9 +134,12 @@ def traced_values(self): return self._trace.names def sampling_efficiency(self, discard=0, flat=True): - """Return the sampling efficiency for chains. If the sampling is thinned - by > 1, this value becomes only an estimate for the true sampling efficiency, - as we do not know the efficiency of the discarded samples.""" + """Return the sampling efficiency for chains. + + If the sampling is thinned by > 1, this value becomes only an estimate for the + true sampling efficiency, as we do not know the efficiency of the discarded + samples. + """ total_accepted = self._trace.accepted[discard:].sum(axis=0) efficiency = total_accepted / (self._nsamples - discard) From 2bf521bd6209f6fc72ea098d265421a025ebed2d Mon Sep 17 00:00:00 2001 From: Ronald Kam Date: Fri, 1 Dec 2023 11:58:40 -0800 Subject: [PATCH 3/3] Fix docstring again --- smol/moca/sampler/container.py | 1 - 1 file changed, 1 deletion(-) diff --git a/smol/moca/sampler/container.py b/smol/moca/sampler/container.py index 7d940fe10..2cf9b5b88 100644 --- a/smol/moca/sampler/container.py +++ b/smol/moca/sampler/container.py @@ -140,7 +140,6 @@ def sampling_efficiency(self, discard=0, flat=True): true sampling efficiency, as we do not know the efficiency of the discarded samples. """ - total_accepted = self._trace.accepted[discard:].sum(axis=0) efficiency = total_accepted / (self._nsamples - discard) if flat: