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

Update mcse_sd calculation to not use normality assumption. #2167

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

ahartikainen
Copy link
Contributor

@ahartikainen ahartikainen commented Nov 19, 2022

Fixes #2005

See https://github.com/stan-dev/posterior/pull/233/files

Description

Checklist

  • Follows official PR format
  • Includes a sample plot to visually illustrate the changes (only for plot-related functions)
  • New features are properly documented (with an example if appropriate)?
  • Includes new or updated tests to cover the new feature
  • Code style correct (follows pylint and black guidelines)
  • Changes are listed in changelog

aloctavodia
aloctavodia previously approved these changes Dec 6, 2022
@OriolAbril
Copy link
Member

It looks like tests are running against posterior 0.1.2, can this be updated to latest posterior?

@@ -732,8 +732,8 @@ def _ess_sd(ary, relative=False):
ary = np.asarray(ary)
if _not_valid(ary, shape_kwargs=dict(min_draws=4, min_chains=1)):
return np.nan
ary = _split_chains(ary)
return min(_ess(ary, relative=relative), _ess(ary**2, relative=relative))
ary = abs(ary - ary.mean())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on benchmarks, posterior just switched to this form (see stan-dev/posterior#266):

Suggested change
ary = abs(ary - ary.mean())
ary = (ary - ary.mean())**2

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I will add this. Need to go through loo to make sure we have the latest changes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By fixing the tests I realized that change should have been done to mcse_sd not to ess_sd. With the changes I just pushed we are back to 100% match with posterior

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the slack discussion, posterior should also be using the change in ess_sd (see stan-dev/posterior#388), so I suggest we revert that change.

@OriolAbril OriolAbril dismissed stale reviews from sethaxen and aloctavodia December 19, 2024 18:10

Review no longer applies

Copy link

codecov bot commented Dec 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.72%. Comparing base (adb2fef) to head (77a71a6).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2167   +/-   ##
=======================================
  Coverage   86.72%   86.72%           
=======================================
  Files         124      124           
  Lines       12908    12914    +6     
=======================================
+ Hits        11194    11200    +6     
  Misses       1714     1714           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better mcse_sd
4 participants