-
-
Notifications
You must be signed in to change notification settings - Fork 984
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
Add CensoredDistribution
#1489
Add CensoredDistribution
#1489
Conversation
e154c8b
to
3444642
Compare
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.
Can you please add some tests? It's fine to add a new file tests/distributions/test_censored.py.
def rsample(self, sample_shape=torch.Size()): | ||
x = self.base_dist.sample(sample_shape) | ||
x[x > self.upper_lim] = self.upper_lim | ||
x[x < self.lower_lim] = self.lower_lim |
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.
return x
and add a test that would have caught this.
cc @alicanb who prototyped |
Thanks @fritzo ! I will get on and write some tests |
Hey @ae-foster, can you point me to some references where Censored Distribution was required? |
I'm going to close this PR unmerged. And it's not because I'm too lazy to write the test (ok it's partly that). The main reason is that I didn't use this code as it stands in For details of my new approach, see https://github.com/ae-foster/pyro/blob/oed-master/pyro/distributions/censored_sigmoid_normal.py |
We currently have
TransformedDistribution
which works with invertible transformations of random variables. The newCensoredDistribution
, added here, makes the following non-invertible transformationThe new pdf uses the
log(cdf)
values atupper_lim
andlower_lim
, and the original pdf elsewhere. This is a valid probability density function, albeit with respect to a new base measure.These distributions find applications in
contrib.oed
work (they make interesting OED problems because censoring leads to lower / zero information gain)