-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Refactor basic Distributions #4508
Refactor basic Distributions #4508
Conversation
@kc611 can you rebase on the latest |
Actually there still seems to be some precision issue with the tests ( the distributions give values as expected but they don't match exactly with the values expected by the tests ) which is causing even the initially refactored @brandonwillard might know more about this. |
We should merge the changes in this PR #4497 to the V4 branch In that PR we changed the check_logcdf precision of the normal distribution as we found it was not passing on all possible values in float32 runs. In addition, to ensure a deterministic behavior we should set the However we cannot do this to any of the tests mentioned in #4420, or else the runs will take way too long to complete. Alternatively we can temporarily re-seed the TestMatchesScipy class, temporarily reverting the effect of this PR #4461 |
Which ones exactly? In a few of the tests I went through that involved sampling, some had issues caused by implicit expectations regarding test values. The root of this difference is the logic in |
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 try (re)enabling the tests for our currently converted Distribution
s in pymc3.tests.test_distributions_random
?
The ones in
Looks like the module you specified is not yet updated according to the latest RV changes. The main testing functions and classes will need to updated accordingly before we can actually run those tests. |
Yes, it's a whole other task, but it's a critical one, because we need to reinstate the tests so that we can demonstrate—to ourselves and others—which things are and aren't working in |
In The other two methods |
Those tests are almost necessarily doing the same thing as the tests in |
pymc3/distributions/continuous.py
Outdated
# beta = draw_values([self.beta], point=point, size=size)[0] | ||
# return generate_samples(self._random, beta, dist_shape=self.shape, size=size) | ||
@_logp.register(HalfCauchyRV) | ||
def half_cauchy_logp(op, value, beta, alpha): |
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'm a bit sceptical as for why this function over here requires the extra alpha
input argument even though it does not use it. I assumed it was something related to HalfCauchy
being a special case of the above Cauchy
distribution. The argument passed over here was a TensorVariable
with a constant value of {1}
during running of the test_distribution
.
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.
Where do you find it requires alpha
?
Is it possible it's coming from the new random method? The scipy method allows for loc and scale, but we only used scale in pymc3. We should make sure the alpha / beta is not being confused in the random calls, since beta corresponds to the second optional argument in the scipy version (the scale): https://github.com/pymc-devs/aesara/blob/b852bd24472e13ae2a405b36eaad462830c89228/aesara/tensor/random/basic.py#L228
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.
On running the test in test_distribution
with only beta parameter, the log_p
method got 4 parameters instead of 3. I assumed that had something to do with the mathematics involved. So I put in an extra argument. Strangely the value of beta
is being passed first. The other one (fourth argument) always remains a constant.
Is it possible it's coming from the new random method?
Probably not, since the random
method is doesn't have any say as to what happens in the log_p
. The RV's just exist for dispatch purposes in case of log_p
.
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.
Still it seems that if a single variable is passed to the random op it will take it as a loc parameter, while the logp will take it as a scale parameter given the order of the arguments in the aesara op, no?
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.
Not to distract from the extra parameter, which is certainly a problem.
I've added a commit to this PR that allows for a much simpler If the relevant |
This PR refactors a few distributions according to the new
RandomVariable
class setup.Refactored the following distributions :