如何从 spicy.stats 中获取分发名称。冷冻配送?

How to get the distribution name from a spicy.stats. frozen distribution?

访问冻结分发的名称

创建 frozen distribution from the 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

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'

冻结分布rv_frozenClass

冻结分配,或rv_frozen class creates an instance of the distribution during initialization and this is stored in the 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

gamma : norm
rv    : norm