Skip to content

Multi-model NG log-likelihood is ~0.02 lower and more variable than Fortran #51

Closed

Description

@neuromechanist

Surfaced by the #27 distributional-equivalence validation (PR #49).

Finding

Running N=20 fits per implementation on the real sample EEG (n_models=2, 100 iters), the partition distributions are statistically equivalent (NG-vs-Fortran cross-corr indistinguishable from Fortran-vs-Fortran; Mann-Whitney p=0.97, TOST equivalent within ±0.05). But the log-likelihood distributions differ:

mean LL (per sample-channel) sd
Fortran -3.3545 0.003
NG -3.3738 0.040

KS p ~ 1e-5. NG is ~0.019 lower on average and ~13x more variable; one seed converged to ~-3.55 (a stuck run) which drives most of the variance. Fortran reaches essentially the same LL every run despite landing in different (near-degenerate) partitions.

See .context/issue-27/multimodel_distributional_equivalence.md and multimodel_ensemble_distributions.png.

This is optimizer quality, not a correctness bug

The per-block sufficient statistics and one M-step are bit-exact vs Fortran (~1e-15), so the M-step equations are right. The inflated variance (not a uniform mean shift) points to "some seeds settle into slightly worse local optima," i.e. a schedule/convergence issue, not a wrong term.

Candidate causes / next steps

  • Iteration cap: re-run the ensemble with larger max_iter and see if NG's LL distribution closes onto Fortran's (tests "stopped short").
  • Schedule mismatch: align NG's lrate ratchet / numdecs / Newton ramp more tightly to Fortran's, re-run ensemble.
  • Stuck-run tail: characterize the low-LL seeds (does Newton fall back? does a mixture component collapse?) and consider a restart-on-stall (the NumPy backend already has a restart path; NG does not).

Acceptance

NG multi-model LL distribution statistically equivalent to Fortran's (TOST on mean, and comparable variance) on the sample data ensemble. Parent: #27 / epic #9.

Activity

  1. added
    enhancement
    on Jul 6, 2026
  2. added 2 commits that reference this issue on Jul 7, 2026
  3. added a commit that references this issue on Sep 1, 2026
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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions