-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
MAINT: stats: frozen distribution attributes a and b should consider parameters #13228
Conversation
…dering loc and scale
Looks like it might be intentional for |
@pvanmulbregt I was hoping to get your opinion on this because in this change it looks like you intended for @rlucas7 @ev-br I'd appreciate your thoughts, too, as you added/reviewed the test in gh-11092 that is changed here. Previously, @glemaitre You reported gh-11089 initially, so I wanted to make sure this change wouldn't throw a wrench into things for scikit-learn. |
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.
@mdhaber the approach seems reasonable but I left a question/suggestion it might help to clarify in the PR.
@@ -308,15 +308,17 @@ def check_pickling(distfn, args): | |||
|
|||
def check_freezing(distfn, args): | |||
# regression test for gh-11089: freezing a distribution fails | |||
# if loc and/or scale are specified | |||
# if loc and/or scale are specified. Modified to resolve gh-13225; | |||
# loc and scale _should_ affect `a` and `b` |
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 can't tell from the diff in this page alone; is this effecting a change if the distribution is not frozen?
NOTE: I'm assuming this should only impact the frozen distributions.
Would it make sense to confirm with a test (either in the test in this PR or a new one, either is fine to me) the uniform case as given by the associated issue (e.g. check it impacts frozen and doesn't imact non-frozen)?
Also, the comment is a bit confusing on clarifying this, suggest to rephrase comment to make it explicit if this works on (a) only frozen, (b) frozen and non-frozen.
@@ -437,7 +437,7 @@ def __init__(self, dist, *args, **kwds): | |||
self.dist = dist.__class__(**dist._updated_ctor_param()) | |||
|
|||
shapes, _, _ = self.dist._parse_args(*args, **kwds) | |||
self.a, self.b = self.dist._get_support(*shapes) | |||
self.a, self.b = self.dist.support(*self.args, **self.kwds) |
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.
parse_args call above is no longer needed, I suspect
EDIT: to clarify, it's not needed if calling .support, and is needed for _get_support
@mdhaber I'm actually not in favor of encouraging use of
|
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.
With a
bit of digging, here is where these attributes went in #4340
I think there was not much thought other than making it rv.a == rv.dist.a
etc. This PR is a then a backcompat break, but probably a mild one, and only need a release note (but let's be prepared to revert if there are complaints).
Whether .a and .b should indeed coincide with the internal .dist attributes or reflect shifting and scaling, I'm not sure. Can be either, I suppose, but should be documented.
Removing them altogether, as Paul suggests is probably too much churn.
All in all, I'd leave them be and direct people to using .support, but if anyone feels like changing it, fine, I'm +0.
Upon further reflection, I don't see the value to the user, nor to the stats codebase. The Encouraging an approach which works in many simple cases, but doesn't work with more complicated distributions is a source of confusion. Using |
Ok. My only goal here was to close gh-13225. Shall we just close that then, explaining to the user that |
I just wanted to check about:
This PR only changes the So if I understand correctly, this would make the Why does doing this implicitly make them public? Or is the concern that making |
Making the change in response to gh-13225 is implicitly accepting the use case there, namely referencing Having a meaning of
+1. |
OK. I'll close these. |
Reference issue
Closes gh-13225
What does this implement/fix?
The
a
andb
attributes of frozen distributions currently hold the lower and upper bounds of the support of the unscaled, unshifted distribution. It seems that they should hold the support of the distribution considering the location, scale, and shape parameters.