question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect values for .a and .b (min and max) for scipy.stats.uniform with non-default args

See original GitHub issue

My issue is about the definition of the attributes a and b (corresponding to min and max) for the scipy.stats.uniform distribution. These appear to always return 0 and 1 respectively, corresponding to the default values, regardless of the arguments.

Reproducing code example:

import scipy.stats as ss
x = ss.uniform(loc=5, scale=5)
print(x.a)  # 0.0
print(x.b)  # 1.0

The correct values should be 5.0 and 10.0.

Scipy/Numpy/Python version information:

1.5.4 1.18.2 sys.version_info(major=3, minor=6, micro=5, releaselevel='final', serial=0)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
mdhabercommented, Dec 27, 2020

@reinhold-willcox it sounds like a and b were really supposed to be private attributes used only by developers. Since the intended behavior is not actually documented, and because the way they work now is acceptable to the developers, the proposed fix in gh-13228 is not going to be merged, so I will close this issue, too. Sorry I couldn’t be of more help! Please use the support method in new code.

1reaction
mdhabercommented, Dec 11, 2020

The funny thing is that the initializer of the frozen distribution calls:

class rv_frozen(object):

    def __init__(self, dist, *args, **kwds):
        self.args = args
        self.kwds = kwds

        # create a new instance
        self.dist = dist.__class__(**dist._updated_ctor_param())

        shapes, _, _ = self.dist._parse_args(*args, **kwds)
        self.a, self.b = self.dist._get_support(*shapes)

but

    def _get_support(self, *args):
        """Return the support of the (unscaled, unshifted) distribution.

I wonder if this is intentional to call _get_support or if it should be calling support, e.g.

self.a, self.b = self.dist.support(*self.args, **self.kwds)

Well, I’ll submit a PR and see what the pros think.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Confusion over `a` and `b` attributes from scipy.stats.uniform
It seems, regardless of the value I provide for loc and scale , the uniform -function returns a=0,b=1 . Compare that to e.g....
Read more >
scipy.stats.uniform — SciPy v1.9.3 Manual
A uniform continuous random variable. In the standard form, the distribution is uniform on [0, 1] . Using the parameters loc and scale...
Read more >
Imports from a custom module
When specifying a uniform distribution using the scipy.stats module the loc argument is the lower limit ($a$) and the scale argument is the...
Read more >
GAMS — A User's Guide
contexts are very different. A direct assignment gives a desired value to a parameter before the solver is called. An equation definition also...
Read more >
All my Homeworks
Then there is a problem of dublicate reference, which I am sure are ... where A and B are the parameters determined by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found