如何从spicy.stats 中获取发行版名称。冻结分布?

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)

tmt*_*prt 5

冷冻分销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)