[SciPy-dev] ticket 422 applies for other methods: vectorize and*args bugs
Per.Brodtkorb at ffi.no
Per.Brodtkorb at ffi.no
Fri Aug 29 05:46:45 EDT 2008
I think it is better to put the statements
self.veccdf.nin = self.numargs+1
self.vecfunc.nin = self.numargs+1
into the __init__ method of rv_continous class.
Per A.
-----Opprinnelig melding-----
Fra: scipy-dev-bounces at scipy.org [mailto:scipy-dev-bounces at scipy.org] På vegne av josef.pktd at gmail.com
Sendt: 29. august 2008 00:48
Til: SciPy Developers List
Emne: [SciPy-dev] ticket 422 applies for other methods: vectorize and*args bugs
I think I found more errors with vectorize (sdf) and *args in
scipy.stats.distributions:
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)
now,
print 'rice.cdf', stats.rice.cdf(5,1.5)
print 'rice.rvs',stats.rice.rvs([1.5])
works
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
Josef
for discrete distribution such as zipf, see my other email
_______________________________________________
Scipy-dev mailing list
Scipy-dev at scipy.org
http://projects.scipy.org/mailman/listinfo/scipy-dev
More information about the SciPy-Dev
mailing list