Skip to content

Add the absolute-increment rule for the Hessian - #7

Merged
remislp merged 1 commit into
masterfrom
ekdist-hessian-delta-l
Sep 8, 2026
Merged

remislp merged 1 commit into
masterfrom
ekdist-hessian-delta-l

Conversation

@remislp

@remislp remislp commented Sep 8, 2026

Copy link
Copy Markdown
Member

What this adds

ApproximateSD has always sized one relative increment, chosen so that moving every parameter together changes the function by 0.5% of its own value.

Colquhoun, Hatton & Hawkes (2003) J Physiol 547:699–728, p. 702, describe a different rule, and it is the one their Tables 2 and 3 were made with: find the increment for each parameter separately that changes the log likelihood by a specified absolute amount, and where no such increment exists, omit that parameter's row and column from the Hessian before inverting it.

delta_L selects that rule.

Why the per-parameter part matters

Sizing one step by moving every parameter at once walks along the diagonal ridge that an anisotropic likelihood has — the direction in which the function barely changes. The step that comes out is therefore far too large for the directions across the ridge, which are the ones the curvature is wanted for.

The interface

kept and dropped say which parameters survived.

  • hessian and covariance cover the survivors only;
  • sd and correlations stay the full size of theta, with nan in the dropped places.

So sd[i] always refers to theta[i], and a table of results cannot silently misalign — which is the failure mode worth designing against here, because it produces a plausible table rather than an error.

A function that raises where it cannot be evaluated is treated as too large a step rather than propagating the error.

The default path is untouched

Verified rather than asserted: the existing pinned Hessian, covariance, SD and correlation values in test_errors.py are unchanged, and that file still passes.

Tests

10 new, on quadratics whose Hessian is known exactly, so a failure means the estimator is wrong rather than that a reference value drifted:

test_both_rules_recover_a_known_hessian
test_absolute_rule_gives_the_right_correlation
test_each_increment_produces_the_requested_change
test_increments_differ_between_parameters
test_insensitive_parameter_is_dropped
test_dropping_leaves_the_others_exact
test_dropped_entries_are_nan_and_indexed_by_parameter
test_the_flat_case_is_what_the_default_rule_cannot_do
test_a_function_that_raises_is_treated_as_too_large_a_step
test_zero_valued_parameter_does_not_give_a_zero_increment

test_the_flat_case_is_what_the_default_rule_cannot_do records the case that motivated the whole thing.

Suite goes from 48 to 60 passed.

Provenance

Written on 2 September during the reproduction of CHH 2003, committed to a local master and never pushed. This is that work rebased onto origin/master as a single commit, with the merge commit flattened out. Nothing in the module or its tests references the reproduction; it needs no new dependency.

🤖 Generated with Claude Code

ApproximateSD has always sized a single relative increment so that moving every
parameter together changes the function by 0.5% of its own value. Colquhoun,
Hatton & Hawkes (2003) J Physiol 547:699-728, p. 702, describe a different rule,
and it is the one their Tables 2 and 3 were made with: find the increment for
each parameter separately that changes the log likelihood by a specified
absolute amount, and where no such increment exists, omit that parameter's row
and column from the Hessian before inverting it.

delta_L selects that rule. The per-parameter part is what matters: sizing one
step by moving every parameter together moves along the diagonal ridge that an
anisotropic likelihood has, where the function changes slowly, so the step that
results is far too large for the directions across the ridge.

kept and dropped say which parameters survived; hessian and covariance cover
those only, while sd and correlations stay the full size of theta with nan in
the dropped places, so sd[i] always refers to theta[i] and a table of results
cannot silently misalign. A function that raises where it cannot be evaluated is
treated as too large a step rather than propagating the error.

The default path is untouched: the existing pinned Hessian, covariance, SD and
correlation values are unchanged.

12 new tests, on quadratics whose Hessian is known exactly, so that a failure
means the estimator is wrong rather than that a reference value drifted. One of
them records that the flat-parameter case is precisely what the default rule
cannot do. The suite goes from 36 to 48 passed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@remislp
remislp merged commit d4842fb into master Sep 8, 2026
6 checks passed
@remislp
remislp deleted the ekdist-hessian-delta-l branch September 8, 2026 15:07
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.

1 participant