Add HMM missing-observation support and an HMM missingness tutorial#252
Open
mattlevine22 wants to merge 17 commits into
Open
Add HMM missing-observation support and an HMM missingness tutorial#252mattlevine22 wants to merge 17 commits into
mattlevine22 wants to merge 17 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends dynestyx’s exact HMM filtering path to support NaN-based missing observations by reusing (and centralizing) the masked observation log-probability machinery already used for simulator-side conditioning. It also adds regression tests and a new tutorial entry documenting supported missingness workflows (MVN and Independent(..., 1)).
Changes:
- Add shared missing-observation preprocessing (safe observation values + masks) and reuse it across HMM filtering and simulator conditioning paths.
- Extend exact HMM emission scoring to treat fully-missing rows as neutral updates and marginalize partially-missing rows for supported observation families.
- Add missingness-focused test coverage for HMMs and discrete simulator conditioning error paths; update docs/config checker behavior accordingly.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
tests/missingness/test_hmm.py |
Adds comprehensive regression tests for HMM missingness (full-row + partial) including categorical cases and traced MCMC paths. |
tests/missingness/test_discrete_simulator.py |
Adds simulator missingness/MCMC smoke coverage and a clearer error for categorical conditioning under DiscreteTimeSimulator. |
dynestyx/simulators.py |
Threads precomputed observation views through simulator paths; adds categorical-conditioning rejection and improved missingness handling for Dirac observations. |
dynestyx/ops.py |
Introduces a new ops module with a second _sample_intp/HandlesSelf definition (currently duplicative vs handlers.py). |
dynestyx/observation_missingness.py |
Refactors missingness logic into reusable helpers (prepare_observation_mask, masked_observation_log_prob, distribution contract probing). |
dynestyx/inference/hmm_filters.py |
Updates HMM emission scoring to use masked log-prob and reuse precomputed safe obs/masks. |
dynestyx/inference/filters.py |
Plumbs preprocessed observation views through batched filter dispatch; records HMM filtered/log-filtered states for plated cases. |
dynestyx/inference/filter_configs.py |
Updates HMMConfig docs to describe supported NaN-based missingness (including categorical encoding). |
dynestyx/inference/checkers.py |
Removes prior blanket prohibition on NaNs for HMM filtering. |
dynestyx/handlers.py |
Adds _prepare_observation_views to precompute safe observations/masks once and pass them to handlers. |
docs/tutorials/gentle_intro/00_index.ipynb |
Adds a link to the new “Part 11c” HMM missingness tutorial. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds NaN-based missing-observation support to the exact HMM filter by reusing the shared masked observation log-probability machinery already used on the simulator side. Fully missing rows now act as neutral observation updates, and partial missingness is supported for exact-marginalizable HMM observation families such as MultivariateNormal and factorizable Independent(..., 1) observations. Internally, the prepared observation mask/safe-value views are computed once and reused across filtering and simulator paths rather than being recomputed downstream.
It also adds regression coverage for the supported and unsupported HMM missingness cases, updates the HMMConfig docs/checker behavior, and introduces a new Part 11c tutorial showing the two clean built-in HMM missingness workflows: multivariate Gaussian observations and independent categorical observations. The tutorial index is updated to link to the new notebook.