tmt*_*prt 4 python random distribution scipy
从包创建冻结分发时,scipy.stats一旦分发实例被冻结,如何访问分发的名称?尝试访问.name属性会产生错误,因为它不再是rv变量的属性。
import scipy.stats as stats
# Get the name of the distribution
print 'gamma :', stats.norm.name
# Create frozen distribution
rv = stats.norm()
# Get the name of the frozen distribution
print 'rv :', rv.name
Run Code Online (Sandbox Code Playgroud)
gamma : norm
rv :
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
9
10 # Get the name of the frozen distribution
---> 11 print 'rv :', rv.name
AttributeError: 'rv_frozen' object has no attribute 'name'
Run Code Online (Sandbox Code Playgroud)
rv_frozen类冻结分布或rv_frozen类在初始化期间创建分布实例,并将其存储在self.dist属性中。要访问原始发行版的属性,请使用rv.dist.{attribute}.
import scipy.stats as stats
# Get the name of the distribution
print 'gamma :', stats.norm.name
# Create frozen distribution
rv = stats.norm()
# Get the name of the frozen distribution
print 'rv :', rv.dist.name
Run Code Online (Sandbox Code Playgroud)
gamma : norm
rv : norm
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1421 次 |
| 最近记录: |