Skip to content

Handle NaN likelihoods by treating as -inf while preserving NaN for user #22

@williamjameshandley

Description

@williamjameshandley

Priority: Medium

Issue Description:
The slice sampler can get stuck when encountering NaN values in likelihood calculations. This contributes to the infinite loop problem reported in #20.

Proposed by: @williamjameshandley (Will Handley)
Context: Related to debugging stuck runs with @zwei-beiner (Namu Kroupa) and @yallup (David Yallup)

Proposed Solution:

  • Treat NaN likelihood values as -inf internally for sampler logic
  • Preserve the original NaN value for user purposes (logging, debugging, etc.)
  • This prevents the sampler from hanging on NaN values while still allowing users to detect when their likelihood function produces NaN

Implementation Details:

  • Add NaN detection in likelihood evaluation
  • Convert NaN to -inf for internal sampling decisions
  • Maintain separate record of original NaN values for user access
  • Consider adding warning/logging when NaN values are encountered

Benefits:

  1. Robustness: Prevents sampler hangs due to NaN values
  2. Debugging: Users can still identify when their likelihood produces NaN
  3. Continuity: Sampling can continue even with occasional NaN evaluations
  4. Transparency: Clear handling of edge cases in likelihood evaluation

Related Issues:

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