[SciPy-user] bug in scipy.stats ?

Hoyt Koepke hoytak@gmail....
Sat Apr 19 22:00:27 CDT 2008


Been playing around with scipy.stats a little bit and noticed some
puzzling behavior with the gamma function.  Is this a bug?

In [1]: import scipy.stats as st

In [2]: g = st.gamma(a=1, b=1)

In [3]: g.rvs()
---------------------------------------------------------------------------
<type 'exceptions.TypeError'>             Traceback (most recent call last)

/home/hoytak/<ipython console> in <module>()

/opt/sysroot/lib/python2.5/site-packages/scipy/stats/distributions.py
in rvs(self, size)
    115         kwds = self.kwds
    116         kwds.update({'size':size})
--> 117         return self.dist.rvs(*self.args,**kwds)
    118     def sf(self,x):
    119         return self.dist.sf(x,*self.args,**self.kwds)

/opt/sysroot/lib/python2.5/site-packages/scipy/stats/distributions.py
in rvs(self, *args, **kwds)
    444             size = (size,)
    445
--> 446         vals = reshape(self._rvs(*args),size)
    447         if scale == 0:
    448             return loc*ones(size,'d')

<type 'exceptions.TypeError'>: _rvs() takes exactly 2 arguments (1 given)

In [4]: g.rvs(0.1)
---------------------------------------------------------------------------
<type 'exceptions.TypeError'>             Traceback (most recent call last)

/home/hoytak/<ipython console> in <module>()

/opt/sysroot/lib/python2.5/site-packages/scipy/stats/distributions.py
in rvs(self, size)
    115         kwds = self.kwds
    116         kwds.update({'size':size})
--> 117         return self.dist.rvs(*self.args,**kwds)
    118     def sf(self,x):
    119         return self.dist.sf(x,*self.args,**self.kwds)

/opt/sysroot/lib/python2.5/site-packages/scipy/stats/distributions.py
in rvs(self, *args, **kwds)
    444             size = (size,)
    445
--> 446         vals = reshape(self._rvs(*args),size)
    447         if scale == 0:
    448             return loc*ones(size,'d')

<type 'exceptions.TypeError'>: _rvs() takes exactly 2 arguments (1 given)

In [5]: g.rvs(0.1, 0.1)
---------------------------------------------------------------------------
<type 'exceptions.TypeError'>             Traceback (most recent call last)

/home/hoytak/<ipython console> in <module>()

<type 'exceptions.TypeError'>: rvs() takes at most 2 arguments (3 given)


At the very least, this is quite confusing.  There's no obvious way to
get around either _rvs() or rvs() raising an exception.  Am I missing
something?

Thanks!
--Hoyt


-- 
+++++++++++++++++++++++++++++++++++
Hoyt Koepke
UBC Department of Computer Science
http://www.cs.ubc.ca/~hoytak/
hoytak@gmail.com
+++++++++++++++++++++++++++++++++++


More information about the SciPy-user mailing list