scipy.stats.uniform 对 `a` 和 `b` 属性的混淆
Confusion over `a` and `b` attributes from scipy.stats.uniform
考虑以下代码:
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)
看来,无论我为 loc
和 scale
提供的值如何,uniform
-函数 returns a=0,b=1
.
将其与例如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)
...这 returns 我所期望的。
所以我的问题变成了:这是 scipy
中的错误,还是我误解了什么? unif.args
值设置正确。
干杯!
据我了解,a
和 b
是内部参数,未在 scipy.stats.uniform
中使用,因为它们的正常功能基本上与 loc
重复和 scale
个参数。
如scipy.stats.uniform
documentation"This distribution is constant between loc
and loc
+ scale
."
所述
所以我不认为这是一个错误,因为 a
和 b
的值应该被视为实现细节而不是面向用户的功能。
与此相关的来源是here,略有删节:
class uniform_gen(rv_continuous):
"""A uniform continuous random variable.
This distribution is constant between `loc` and ``loc + scale``.
# ...
"""
def _rvs(self):
return self._random_state.uniform(0.0, 1.0, self._size)
# ....
uniform = uniform_gen(a=0.0, b=1.0, name='uniform')
因此 a
和 b
将分别始终为 0 和 1。
我猜你的困惑(我也偶尔用这个符号)是大多数教科书将均匀分布定义为说谎 between a and b. But in this case a
and b
are something a bit different 并且,正如@jakevdp 所说,
This distribution is constant between loc
and loc + scale
.
因此,将此与传统定义联系起来,将 a 视为 loc
,将 b 视为 loc + scale
.
(如果您有兴趣,父级 class rv_continuous
又被定义为 here。)
考虑以下代码:
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)
看来,无论我为 loc
和 scale
提供的值如何,uniform
-函数 returns a=0,b=1
.
将其与例如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)
...这 returns 我所期望的。
所以我的问题变成了:这是 scipy
中的错误,还是我误解了什么? unif.args
值设置正确。
干杯!
据我了解,a
和 b
是内部参数,未在 scipy.stats.uniform
中使用,因为它们的正常功能基本上与 loc
重复和 scale
个参数。
如scipy.stats.uniform
documentation"This distribution is constant between loc
and loc
+ scale
."
所以我不认为这是一个错误,因为 a
和 b
的值应该被视为实现细节而不是面向用户的功能。
与此相关的来源是here,略有删节:
class uniform_gen(rv_continuous):
"""A uniform continuous random variable.
This distribution is constant between `loc` and ``loc + scale``.
# ...
"""
def _rvs(self):
return self._random_state.uniform(0.0, 1.0, self._size)
# ....
uniform = uniform_gen(a=0.0, b=1.0, name='uniform')
因此 a
和 b
将分别始终为 0 和 1。
我猜你的困惑(我也偶尔用这个符号)是大多数教科书将均匀分布定义为说谎 between a and b. But in this case a
and b
are something a bit different 并且,正如@jakevdp 所说,
This distribution is constant between
loc
andloc + scale
.
因此,将此与传统定义联系起来,将 a 视为 loc
,将 b 视为 loc + scale
.
(如果您有兴趣,父级 class rv_continuous
又被定义为 here。)