-
Notifications
You must be signed in to change notification settings - Fork 60
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
Allow inclusive bounds in Adapter.constrain()
#338
Conversation
thank you! looks good. Question: Why would you make the lower bound inclusive but the upper exclusive by default? |
@paul-buerkner In my opinion, the most common case for double-bounded variables is uniform distribution. This is typically in the half-open interval |
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
|
In statistics, we do not treat upper and lower bounds differently, specifically if variables are continuous (which they need to be for now if we use them as parameters in generative neural networks). I would treat upper and lower boundaries the same. So probably |
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.
Looks good except for my suggestion for symmetric default values that I added as direct comment to the issue.
@LarsKue do i have permission to edit this PR in the direction I mentioned aboved? |
@paul-buerkner yes. I do feel like it could be a bit opaque to new users though, since most randomly generated numbers are in open or half-open intervals, regardless of the statistical interpretation of the bounds. |
Is there even a difference for continuous distributions? I mean, the probability of sampling exactly from the boundary is zero. So I am confused by your statement that intervals would ever be half open in software. For discrete variables perhaps but those are not our main concern in the adapter transformations. |
Just to add one thought. Our point here is not to determine whether a null-set is included in an interval or not, but to ensure numerical stability. And for the latter, we need the epsilon, i.e., both inclusive bounds. |
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.
From my side, the PR is ready now. I change the default inclusive to "both" and added some tests. During testing, I also noticed that epsilon 1e-16 is too small to ensure finite outputs if the input is exactly at the upper boundary. So I changed it to 1e-15 which seems to work well.
I further extended the tests to now hopefully cover all relevant cases. Will merge now. |
Simply adds a small value to bounds that are specified as inclusive.