Skip to content

Handle zero-probability decision contexts#83

Open
yfflood wants to merge 2 commits into
causalincentives:masterfrom
yfflood:master
Open

Handle zero-probability decision contexts#83
yfflood wants to merge 2 commits into
causalincentives:masterfrom
yfflood:master

Conversation

@yfflood

@yfflood yfflood commented Jun 27, 2026

Copy link
Copy Markdown

Fixes issue #80
The change keeps conditional expectations on impossible events undefined by default, but lets the solver explicitly provide a neutral fallback for unreachable decision contexts.

Changes

  • Add zero_prob_value fallback parameter to expected_value().
  • Detect all-NaN and zero-mass query factors before normalization.
  • Raise a RuntimeError for ordinary zero-probability conditional expectations.
  • Use zero_prob_value=0.0 only while constructing optimal decision rules, where unreachable contexts do not affect expected utility.

@RyanCarey RyanCarey left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks and sounds like making pycid more gracefully handle an edge case.

@yfflood

yfflood commented Jun 27, 2026

Copy link
Copy Markdown
Author

Added a little specification to make sure the fix only targets the case of 0-probability context. Other unexpected causes of nan will still raise RuntimeErrors.

@yfflood

yfflood commented Jun 29, 2026

Copy link
Copy Markdown
Author

@RyanCarey thanks for the review! It looks like there's a workflow awaiting maintainer approval before this can be merged :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error evaluating ev conditioning on a 0-probability event

2 participants