Skip to content

Use ci_prob for the tail ESS in pareto_khat, power_scale_lw and thin_factor - #498

Open
kojikojikojikoji wants to merge 1 commit into
arviz-devs:mainfrom
kojikojikojikoji:tail-ess-ci-prob
Open

kojikojikojikoji wants to merge 1 commit into
arviz-devs:mainfrom
kojikojikojikoji:tail-ess-ci-prob

Conversation

@kojikojikojikoji

Copy link
Copy Markdown
Contributor

Follow up to #490. @aloctavodia and @jordandeklerk agreed to use rcParams["stats.ci_prob"] for the tail ESS everywhere (#490 (comment), #490 (comment)).

Three places still used a fixed 5%/95%:

  • _pareto_khat, when r_eff is not given. This is used by pareto_khat, pareto_min_ss, the min_ss column of summary and the k-hat in loo_expectations.
  • _power_scale_lw. This is used by psense, psense_summary and power_scale_dataset.
  • The array thin_factor used prob=0.95. The DataArray thin_factor already used ci_prob. The two could return different factors for the same draws.

How prob is passed:

  • The DataArray functions pareto_khat, pareto_min_ss and power_scale_lw take prob=None and resolve it with validate_ci_prob, like ess does.
  • The array functions pareto_khat, pareto_min_ss, power_scale_lw and thin_factor take prob with a default of 0.89. The array layer does not read rcParams. Existing array calls keep working. They give the same result as the DataArray functions with the default rcParams.
  • An explicit r_eff still takes priority in pareto_khat.

Values that change (centered_eight posterior and tests/univariate_normal.nc):

Value Before After
pareto_khat, mu -0.060 -0.110
pareto_khat, theta[0] 0.025 -0.002
pareto_khat, theta[3] 0.241 0.168
pareto_min_ss, theta[0] 10.61 10.00
pareto_min_ss, theta[3] 20.74 15.93
array thin_factor, mu 9 10 (same as DataArray)
psense prior, mu / sigma 0.40427 / 0.29286 0.40435 / 0.29299
psense likelihood, mu / sigma 0.57623 / 0.53569 0.57625 / 0.53571

tau does not change because it uses the n_draws / 5 branch for the tail length. The psense_summary output is the same after rounding. The reference values in tests/test_psense.py did not need updating.

k-hat values now differ a little from posterior::pareto_khat, which computes r_eff from ess_tail with the 5% and 95% quantiles.

Tests added in tests/base/test_stats.py:

  • pareto_khat and pareto_min_ss on a DataArray follow stats.ci_prob set with rc_context, and give the same values as the array functions called with the same prob.
  • The same check for the Pareto k returned by power_scale_lw.
  • The array and DataArray thin_factor now return the same value for centered_eight mu.

Should prob be required in these array functions, like it is for ess(method="tail"), instead of defaulting to 0.89? I kept the default so existing array calls do not break. I can change it.

…factor

The tail ESS used for r_eff in pareto_khat, pareto_min_ss and power_scale_lw
and the one in the array thin_factor were fixed to 5%/95%. They now follow
stats.ci_prob like ess(method="tail"), see arviz-devs#490.

Signed-off-by: Koji Miyazawa <24467062+kojikojikojikoji@users.noreply.github.com>
@codecov-commenter

codecov-commenter commented Oct 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.64%. Comparing base (90b594d) to head (23ab291).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #498   +/-   ##
=======================================
  Coverage   84.63%   84.64%           
=======================================
  Files          48       48           
  Lines        6978     6981    +3     
=======================================
+ Hits         5906     5909    +3     
  Misses       1072     1072           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
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.

2 participants