scipy.stats.norm
의 하위 클래스로 추가 기능이 포함 된 고정 된 배포 (즉, 특정 수단/분산) 인스턴스를 가질 수 있습니다. 그러나 인스턴스를 작성하는 첫 번째 단계는 지나갈 수 없습니다.scipy.stats.norm을 서브 클래 싱하는 방법은 무엇입니까?
편집 : 여기에 내 문제를 보여줍니다 대화 형 세션의 사본입니다
In [1]: import scipy.stats
In [2]: class A(scipy.stats.norm):
...: def __init__(self):
...: super(A, self).__init__()
...:
...:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/home/Dave/src/python2.7/density_estimation/<ipython console> in <module>()
/usr/lib64/python2.7/site-packages/scipy/stats/distributions.pyc in __init__(self, momtype, a, b, xa, xb, xtol, badvalue, name, longname, shapes, extradoc)
958
959 if longname is None:
--> 960 if name[0] in ['aeiouAEIOU']:
961 hstr = "An "
962 else:
TypeError: Error when calling the metaclass bases
'NoneType' object is not subscriptable
내가 norm
은을이다 scipy.stats
이 이상한 것은 일종의을하고있는 것을 볼 수있다 (아무것도까지 내 소매 없다) 특정 인스턴스 (뭔가?),하지만 그것은 일반적인 클래스 정의가 아니므로, 나는 그것에 대한 생성자를 호출하는 방법을 볼 수 없습니다.
편집 # 2 : scipy 버전이 적합 할 수 있습니다.
In [19]: scipy.__version__
Out[19]: '0.9.0'
왜'rv_frozen' 대신'rv_continuous'를 하위 클래스로 만들지 않겠습니까? –
import 명령은 다음과 같습니다 :'from scipy.stats.distributions import rv_frozen' 그리고 초기 호출은'super (className, self) .__ init __ (norm, normprop1, normprop1 ...)'과 같습니다. –