Skip to content

Use the reference's single-precision density constants #344

Closed

Description

@neuromechanist

Symptom

The reference writes several density normalizing constants as default-kind (single-precision) Fortran literals promoted to double, for example log(dble(2.506628274)) in the Gaussian branch (amica15.f90:1331-1333), which the generalized Gaussian family also takes when rho reaches exactly 2. The default maxrho=2 clamp makes that common, so it is not confined to non-default settings. pamica's torch, NumPy and MLX backends use the double value of the same decimal literal (_LOG_SQRT_2PI = math.log(2.506628274), and likewise _LOG_NORM_COSH_SUB/_LOG_NORM_COSH_SUP), so their log normalizers differ from the reference's by the float32 rounding of the literal. Found by epic #324 Phase 8 (#334, PR #342) while building a merged-state native oracle. It was confirmed exactly for rho == 2: 3.0e-8 in the log term and 2.8e-9 in the log-likelihood. The pdftype 2, 4 and 1 families should differ by 3.7e-10, 2.0e-8 and -2.1e-8 respectively (computed from the literals, not yet measured against the binary). The comments that claim bit-for-bit agreement for these constants overstate it.

Fix

Adopt the reference's values exactly, i.e. the float32 rounding of each literal promoted to float64 (float(np.float32(2.506628274)) and so on), in all three backends through one shared definition. Pin each constant against the literal's float32 rounding in an always-on test. Add a gated native oracle at rho == 2 (no maxrho=1.99 workaround) that shows the 3.0e-8 term gone. Record the (tiny) change to default trajectories in the changelog, and remove the corresponding differences-guide row once it is fixed.

Part of epic #324.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions