-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Problem
The right-truncation tutorial (docs/tutorials/right_truncation.qmd) demonstrates the key behavioral property of right-truncation: when two otherwise identical observation processes are sampled — one with and one without a right_truncation_rv — their predicted values agree for early timepoints and diverge for recent ones. This is the property that matters most for correctness: right-truncation is a multiplicative adjustment that leaves fully-reported timepoints untouched while depressing recent ones proportionally to the reporting delay CDF.
The existing unit tests in TestRightTruncation (test/test_observation_counts.py) do not test this comparative property. They check absolute predicted values at specific positions using a trivial single-element delay PMF ([1.0]), which bypasses the delay convolution entirely. There is no test that:
- Uses a multi-element delay PMF (so the delay convolution is exercised).
- Constructs both a truncated and non-truncated
Countsprocess with the same parameters. - Samples both with the same seed and infections.
- Asserts that early predicted values are identical between the two.
- Asserts that recent predicted values in the truncated process are strictly less.
- Verifies that the ratio of truncated to non-truncated predicted values equals the proportion already reported from
compute_prop_already_reported.
Proposed test
Create a test that mirrors the tutorial's comparison: construct two Counts processes sharing the same delay PMF, ascertainment rate, and noise model, differing only in right_truncation_rv. Sample both with the same infections array. Assert:
- Early agreement: for timepoints where
prop_already_reported == 1.0, the predicted values match exactly. - Late divergence: for recent timepoints, the truncated predicted values are strictly less.
- Correct ratio:
predicted_truncated / predicted_non_truncated == prop_already_reportedfor all post-initialization timepoints.