Consider the following code:
import scipy
print(scipy.__version__) # gives 0.19.1
# Scipy.stats.uniform
unif = scipy.stats.uniform(1, 2)
print(unif.a, unif.b, unif.args) # gives a=0, b=1, args=(1,2)
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. randint
:
# Scipy.stats.randint
randi = scipy.stats.randint(1, 10)
print(randi.a, randi.b, randi.args) # gives a=1, b=9, args=(1,10)
...which returns what I would expect.
So my question becomes: is this a bug in scipy
, or have I misunderstood something? The unif.args
value is set correctly though.
Cheers!
It is my understanding that the
a
andb
are internal parameters, are not used inscipy.stats.uniform
, because their normal functionality is basically duplicative of theloc
andscale
parameters.As mentioned in the
scipy.stats.uniform
documentation "This distribution is constant betweenloc
andloc
+scale
."So I don't think this is a bug, because the values of
a
andb
should be treated as an implementation detail rather than a user-facing feature.The relevant source on this is here, abridged a bit:
So
a
andb
will always be 0 and 1, respectively.I'm guessing your confusion (mine too occascionally with this notation) is that most textbooks will define uniform distributions as lying between a and b. But in this case
a
andb
are something a bit different and, as @jakevdp said,So relating this back to the traditional definition, think of a as
loc
and b asloc + scale
.(The parent class
rv_continuous
in turn is defined here if you're interested.)