Skip to content

The constant model in dose_response uses a second optimizer for the same likelihood #85

Closed

Description

@timtreis

Problem

tl/_dose.py maximises the same Student-t likelihood with two different optimizers.
_fit_maximum_likelihood runs Nelder-Mead over a model's parameters plus the error scale, and
_fit_maximum_likelihood_constant runs minimize_scalar(method="bounded") over the error scale alone, with a
hand-picked upper bound of std * 100 that nothing else in the file uses.

The constant model is the zero-response model once the baseline is subtracted, so it is the same objective with
an empty parameter vector. Making it a third entry in _winning_model's model set would delete the function,
the minimize_scalar import, the bounds heuristic, and the if constant is None branch in _hitcall.

Expected behaviour

One optimizer for one likelihood.

Note this is not a pure refactor: bounded Brent and Nelder-Mead will not land on bit-identical optima, so the
P1 term of every hitcall moves in the last digits. It needs the dose tests re-run and the tutorial 11 outputs
regenerated, which is why it was left out of the cleanup that introduced the dataclass.

Related

  • The _Fit dataclass added in 337dbcb already carries what a "constant" entry would need: a name, a parameter
    vector whose last element is the error scale, and a predict.

Activity

  1. added a commit that references this issue on Sep 21, 2026
    edb0322
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions