Skip to content

Phase 2: Isolated correctness fixes (3 math bugs) #11

Closed

Description

@neuromechanist

Part of epic #9. Depends on Phase 1 gate.

Scope (each with a regression test vs Fortran)

  1. Per-source mixture factorization: compute sum_i log sum_k alpha_{k,i} f_k(y_{i,t}), not sum-over-sources-then-logsumexp. Fix _compute_gg_log_pdf_vectorized / compute_log_likelihood in amica_torch.py (and v2 fallback).
  2. Per-source alpha: use alpha[k, :] per source, not alpha_k.mean() (amica_torch.py:187, amica_torch_v2.py:259).
  3. LL normalization: divide by n_samples * nw and drop the extra n_samples*log_det_W term to match Fortran units (amica17.f90:1866).

Done when

All three fixes land with tests locking them to Fortran values; Phase 1 baseline report shows improved per-channel LL scale (~ -3.4 range) and no regression in correlation.

Activity

  1. added
    feature
    on Jul 2, 2026
  2. neuromechanist commented on Jul 2, 2026

    @neuromechanist
    MemberAuthor

    Lead from Phase 1 review (PR #14): the legacy-NumPy Newton NaN (behind test_amica.py::test_full_amica and test_pyAMICA.py::test_full_pipeline) traces to a divide-by-zero at pyAMICA/pyAMICA.py:747 and :751 (dmu = updates['dmu'] / updates['dalpha'], dbeta = ... / updates['dalpha']) when a mixture component's dalpha collapses to zero. Looks like a clean guard/clamp fix in Phase 2 scope (Fortran floors these with epsilon), not something needing the Phase 3 rewrite. Add a regression test that exercises the collapse case.

  3. neuromechanist commented on Jul 3, 2026

    @neuromechanist
    MemberAuthor

    Phase 2 (isolated correctness fixes) delivered via epic #9, on main in PR #28. Closing.

  4. added a commit that references this issue on Jul 4, 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

    feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions