[SciPy-dev] stats confusion
Neal Becker
ndbecker2@gmail....
Wed Jun 17 08:27:04 CDT 2009
josef.pktd@gmail.com wrote:
> On Wed, Jun 17, 2009 at 8:23 AM, Neal Becker<ndbecker2@gmail.com> wrote:
>> I'm still finding stats usage confusing. The doc
>>
(http://docs.scipy.org:80/doc/scipy/reference/generated/scipy.stats.chi2.html?highlight=chi2#scipy.stats.chi2)
>>
>> says:
>>
>> chi2.cdf(x,df,loc=0,scale=1) :
>>
>> And even has an example:
>> prb = chi2.cdf(x,df)
>>
>> But if df is given as keyword:
>> scipy.stats.chi2.cdf(1, df=2)
>> ERROR: An unexpected error occurred while tokenizing input
>> The following traceback may be corrupted or invalid
>> The error message is: ('EOF in multi-line statement', (1331, 0))
>>
>>
---------------------------------------------------------------------------
>> TypeError Traceback (most recent call
>> last)
>>
>> /home/nbecker/globalstar/<ipython console> in <module>()
>>
>> /usr/lib64/python2.6/site-packages/scipy/stats/distributions.pyc in
>> cdf(self, x, *args, **kwds)
>> 623 if any(cond): #call only if at least 1 entry
>> 624 goodargs = argsreduce(cond, *((x,)+args))
>> --> 625 place(output,cond,self._cdf(*goodargs))
>> 626 if output.ndim == 0:
>> 627 return output[()]
>>
>> TypeError: _cdf() takes exactly 3 arguments (2 given)
>>
>> What's going on here? Do stats not accept keyword args as per normal
>> python usage?
>>
>
> As the signature indicates df is a positional argument and not a
> keyword argument
The doc says:
chi2.cdf(x,df,loc=0,scale=1)
A python user would then expect chi2.cdf (x=0, df=1) to work. Isn't there a
problem with that doc? Is it not feasible to fix this so these functions
behave as a naive python user would expect?
More information about the Scipy-dev
mailing list