2016-05-29 49 views
2

訪問冷凍配送的名稱

當創建從scipy.statsfrozen distribution,如何分配的名稱來訪問一次分配的實例被凍結?嘗試訪問.name屬性會產生錯誤,因爲它不再是rv變量的屬性。如何從spicy.stats獲取分配名稱。凍結分銷?

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' 

回答

3

的冷凍分佈rv_frozen

將冷凍的分佈,或者rv_frozen class創建初始化期間分配的一個實例,這被存儲在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 
相關問題