[SciPy-dev] ticket 422 applies for other methods: vectorize and *args bugs

josef.pktd@gmai... josef.pktd@gmai...
Thu Aug 28 17:47:54 CDT 2008

I think I found more errors with vectorize (sdf) and *args in

When I try with scipy 0.6.0
print 'rice.cdf', stats.rice.cdf(5,1.5)

raise ValueError, "mismatch between python function inputs"\
ValueError: mismatch between python function inputs and received arguments

if I add in class rv_continuous

    def _cdf(self, x, *args):
+        self.veccdf.nin = self.numargs+1  #JP
        return self.veccdf(x,*args)

I also needed to add

    def _cdf_single_call(self, x, *args):
 +       import scipy.integrate  #JP
        return scipy.integrate.quad(self._pdf, self.a, x, args=args)[0]

then the error is gone:
>>> print 'rice.cdf', stats.rice.cdf(5,1.5)
rice.cdf 0.999557350428

in order to get rice.rvs(1.5) to work, I did also

    def _ppf(self, q, *args):
+        self.vecfunc.nin = self.numargs+1  #JP
        return self.vecfunc(q,*args)

    def _isf(self, q, *args):
+        self.vecfunc.nin = self.numargs+1  #JP
        return self.vecfunc(1.0-q,*args)

print 'rice.cdf', stats.rice.cdf(5,1.5)
print 'rice.rvs',stats.rice.rvs([1.5])


but this does not
print 'rice.rvs',stats.rice.rvs([1.5])
print 'rice.cdf', stats.rice.cdf(5,1.5)

cdf needs to be called before rvs. So my changes are not in the right
position, the cdf needs to be initialized before, I can call rvs.

But somewhere along these lines, it should be possible to make the
generic methods function correctly.

This was with scipy 0.60, but I haven't seen any relevant changes in
the current trunk


for discrete distribution such as zipf, see my other email

More information about the Scipy-dev mailing list