如何从Spicy.stats获取发行名称.冻结分配? [英] How to get the distribution name from a spicy.stats. frozen distribution?

查看:111
本文介绍了如何从Spicy.stats获取发行名称.冻结分配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建 冻结分发(来自 scipy.stats 包,冻结分发实例后如何访问该分发的名称?尝试访问.name属性会产生错误,因为它不再是rv变量的属性.

When creating a frozen distribution from the scipy.stats package, how can the distribution's name be accessed once the distribution instance is frozen? Trying to access the .name attribute produces an error since it is no longer an attribute of the rv variable.

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_frozen

冻结发行版,或 rv_frozen在初始化期间创建分发的实例,并将其存储在

The Frozen Distribution rv_frozen Class

The frozen distribution, or rv_frozen class creates an instance of the distribution during initialization and this is stored in the self.dist attribute. To access attributes of the original distribution, use 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

这篇关于如何从Spicy.stats获取发行名称.冻结分配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆