-
Notifications
You must be signed in to change notification settings - Fork 270
Implement LeftCensoredDistribution and RightCensoredDistribution #2081
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I've removed the tutorial / notebook from this PR to chop up the work |
|
anyone up for a review? @juanitorduz @fehiepsi ? |
|
Great! I will take a look! In the meantime I think we need to add these distribution into the docs: https://github.com/pyro-ppl/numpyro/blob/master/docs/source/distributions.rst (you can use Also, I think @fehiepsi 's review is key ;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @vanAmsterdam ! This looks great! Here are some initial comments :)
Question:
This PR handles left and right censoring. Are there plans for interval censoring (where we know the event occurred in an interval [a, b])? Or can we add a uni-test so see if we can do this already from this implementation?
I've code for this on a branch that's now out of sync (see https://github.com/vanAmsterdam/numpyro/blob/95fd78dee8fe794d6e59517ad4e3c09804fcdc5a/numpyro/distributions/censored.py#L220) |
perfect! makes total sense 🙌 |
|
@vanAmsterdam I created a PR to your branch to try to fix the docstrings (it now works fine for me) vanAmsterdam#2 |
|
You can try ruining |
yes figured this one out a little too late :) but it's passing now so I think we're set for a review. thanks for the help! |
|
@fehiepsi I think this one is ready for your review :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @vanAmsterdam and @juanitorduz!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I have some minor comments.
numpyro/distributions/censored.py
Outdated
| def sample( | ||
| self, key: Optional[jax.dtypes.prng_key], sample_shape: tuple[int, ...] = () | ||
| ) -> ArrayLike: | ||
| return self.base_dist.sample(key, sample_shape) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need self.base_dict.expand(self.batch_shape).sample(...).
numpyro/distributions/censored.py
Outdated
| def sample( | ||
| self, key: Optional[jax.dtypes.prng_key], sample_shape: tuple[int, ...] = () | ||
| ) -> ArrayLike: | ||
| return self.base_dist.sample(key, sample_shape) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need self.base_dict.expand(self.batch_shape).sample(...). promote_shapes does not broadcast the parameters, it only adds some missing singleton dimensions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch; updated in newest commit and also added a test
Implements
LeftCensoredDistributionandRightCensoredDistributionThese distributions take any
base_distwith acdfmethod implemented and allow for handling left-or-right censored data. See Issue #1909.Current status