From 431ac4e3d99e1cdcea0b5ba3c5f89b99ad15648e Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Sat, 5 Sep 2026 10:11:19 +0200 Subject: [PATCH] symmetry: the systematic-b fit divides by its degrees of freedom, as its own chi2 does Each deviation is taken from a mean fitted on its own orbit, so one degree of freedom per orbit is spent: dof = sum(n-1) = N - G, the divisor chi2_under a few lines above already uses. Dividing by N understated the reduced chi^2 and so overstated the b that brings it to 1 - unevenly, because a low-multiplicity parent loses a larger fraction of its dof than the higher-multiplicity candidate it is compared against, and the difference landed on the b RATIO the gates read. Measured three times independently on disjoint corpora: median ratio inflation +23.7%, +23.7% and +23.8%, with the corrected ratio lower in 42 of 42 promotions, so the error pushed toward over-calling. Expect no verdict to move: the b veto has not been observed to fire on any corpus it has been measured over, and refused_by=b fired zero times in 25 refusals. The bounds are left at 1.78 / 2.00 / 0.05 rather than rescaled. They were calibrated in the old convention, but re-measured on the corrected statistic against independent space groups they still separate: the genuine maximum is 1.640 and the nearest false step 3.208, so both bounds sit inside the only clean gap the corrected distribution offers. A second derivation from population medians argues for 1.38 / 1.56 / 0.07 instead; that is a calibration question for a battery, not a condition of fixing the arithmetic. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01EFEJG6WBQv8th4UJFNe53N --- image_analysis/scale_merge/SearchSpaceGroup.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/image_analysis/scale_merge/SearchSpaceGroup.cpp b/image_analysis/scale_merge/SearchSpaceGroup.cpp index d4d4f4df8..de1790b91 100644 --- a/image_analysis/scale_merge/SearchSpaceGroup.cpp +++ b/image_analysis/scale_merge/SearchSpaceGroup.cpp @@ -731,6 +731,10 @@ SearchSpaceGroupResult SearchSpaceGroup( // floor a-dependent, on a quantity that has no a. Leave it alone. auto merge_systematic_b = [&](const Orbits& orb) -> double { std::vector> obs; // I, sigma, deviation-from-orbit-mean + long n_orbits = 0; // orbits contributing, for the degrees of freedom + for (const Acc& g : orb.acc) + if (g.n >= 2) + ++n_orbits; for (size_t i = 0; i < n; ++i) { if (orb.orbit[i] < 0) continue; @@ -739,13 +743,19 @@ SearchSpaceGroupResult SearchSpaceGroup( continue; obs.push_back({I[i], Sigma[i], I[i] - g.swI / g.sw}); } - if (obs.size() < 20) + // Each deviation is taken from a mean fitted on its own orbit, so one degree of freedom per + // orbit is spent: dof = sum(n-1) = N - G, the same denominator chi2_under uses above. Dividing + // by N instead understates the reduced chi^2 and so overstates the b that brings it to 1, and + // it does so unevenly - a low-multiplicity parent loses a larger fraction of its dof than the + // higher-multiplicity candidate, which inflates the b RATIO the gates read. + const double dof = static_cast(obs.size()) - static_cast(n_orbits); + if (obs.size() < 20 || dof <= 0.0) return 0.0; auto reduced_chi2 = [&](double b) { double s = 0.0; for (const auto& o : obs) s += o[2] * o[2] / (o[1] * o[1] + (b * o[0]) * (b * o[0])); - return s / static_cast(obs.size()); + return s / dof; }; if (reduced_chi2(0.0) <= 1.0) return 0.0;