[SciPy-dev] PEP: Improving the basic statistical functions in Scipy
Eric Firing
efiring@hawaii....
Fri Feb 27 17:01:29 CST 2009
Pierre GM wrote:
> On Feb 27, 2009, at 4:52 PM, josef.pktd@gmail.com wrote:
>> For most of the current statistical functions, with the exception of
>> different tie handling, I think that we can expand the _chk_asarray to
>> do the necessary preprocessing.
>
> Mmh. _chk_asarray will always return a MA. Is it what you want? Are you
>
> An idea is then to use the 'usemask' parameter I was talking about
> earlier:
> * if usemask is False (default), return a ndarray
> * If usemask is True, return a MA
> * if the input is a MA (w/ or w/o missing values), set usemask to
> True, and mask the NaNs/Infs first w/ ma.fix_invalid.
This may not be appropriate for scipy, but for my own purposes I
included a third option for the similar "masked" kwarg in a simple stats
class:
http://currents.soest.hawaii.edu/hg/hgwebdir.cgi/pycurrents/file/7b4103d34cc8/num/stats.py#l1
masked='auto' makes the output masked if and only if the input is masked.
Eric
>
> That way, we need only one function. If we really need it, we can have
> duplicate functions in scipy.mstats where usemask is set to True by
> default.
>
> Now, for the actual implementation:
> * usemask=False and some NaNs: return NaN
> * usemask=True: use the ma implementation.
>
>
>
>>>>> stats.mstats.moment(np.ma.fix_invalid(np.ma.column_stack([x,x])),
>>>>> 1) #inconsistent return type
>> array([ 0., 0.])
>
> That's a bug, we should have a MA.
>
> _______________________________________________
> Scipy-dev mailing list
> Scipy-dev@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-dev
More information about the Scipy-dev
mailing list