Skip to content

fix(core): normalize Q statistics by residual count - #315

Open
dnncha wants to merge 2 commits into
GeoStat-Framework:mainfrom
dnncha:fix/q-statistics-denominator
Open

dnncha wants to merge 2 commits into
GeoStat-Framework:mainfrom
dnncha:fix/q-statistics-denominator

Conversation

@dnncha

@dnncha dnncha commented Sep 30, 2026

Copy link
Copy Markdown

Why

calcQ1 and calcQ2 divide their sums by one fewer epsilon residual than they receive. This inflates Q1, Q2, and cR. It also makes one-residual inputs divide by zero. Divide by the residual count so the functions calculate the absolute mean and the mean square defined by the diagnostics.

Fixes #314.

Scope

  • Make calcQ1 and calcQ2 use epsilon.shape[0].
  • Add direct regression coverage for two residuals and one residual.

Blast Radius

This changes Q1, Q2, and cR diagnostics. It does not change epsilon residuals or kriging predictions. A controlled variogram comparison changed which Q2 value was closer to the documented target of 1, but no changed published conclusion was established. This correction has not received independent human scientific review.

Verification

  • .venv/bin/python -m pytest -q tests/test_core.py passed all 53 tests.
  • The public OrdinaryKriging(..., enable_statistics=True) reproducer changed reported Q2 values from 0.875 and 1.375 to their definition-level values 0.7 and 1.1.
  • The focused regression failed before the fix with Q1 2.0 instead of 1.0 and one-residual Q1 inf instead of 0.5; it passed after the fix.

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.

Q1 and Q2 variogram diagnostics divide by one fewer residual

1 participant