[SciPy-User] Some thing wrong in scipy reference

Ralf Gommers ralf.gommers@googlemail....
Sat Jul 21 10:09:30 CDT 2012


On Sat, Jul 21, 2012 at 4:59 PM, Warren Weckesser <
warren.weckesser@enthought.com> wrote:

>
>
> On Sat, Jul 21, 2012 at 9:39 AM, Ralf Gommers <ralf.gommers@googlemail.com
> > wrote:
>
>>
>>
>> On Sat, Jul 21, 2012 at 1:26 PM, Warren Weckesser <
>> warren.weckesser@enthought.com> wrote:
>>
>>>
>>>
>>> On Sat, Jul 21, 2012 at 3:02 AM, Ralf Gommers <
>>> ralf.gommers@googlemail.com> wrote:
>>>
>>>>
>>>>
>>>> 2012/7/21 王瑞期 <shahuwang@qq.com>
>>>>
>>>>>
>>>>> http://docs.scipy.org/doc/scipy/reference/generated/scipy.cluster.vq.whiten.html#scipy.cluster.vq.whiten
>>>>>
>>>>>  In the bottom of this page,the result of the whiten function is wrong.
>>>>>
>>>>
>>>> You're right, the current output as documented is off by a constant
>>>> factor:
>>>> >>> res = whiten(features)
>>>> >>> res * 3.41250074 / res[0, 0]  # reproduce docstring output
>>>> array([[ 3.41250074,  2.20300046,  5.88897275],
>>>>        [ 2.69407953,  2.39456571,  7.62102356],
>>>>        [ 1.43684242,  0.57469577,  5.88897275]])
>>>>
>>>> Does anyone know why, and is this result correct?
>>>>
>>>> Ralf
>>>>
>>>>
>>>
>>> whiten(obs) returns (in effect) obs / obs.std(axis=0).  It appears that
>>> the docstring shows obs / obs.std(axis=0, ddof=1):
>>>
>>> In [14]: obs
>>> Out[14]:
>>> array([[ 1.9,  2.3,  1.7],
>>>        [ 1.5,  2.5,  2.2],
>>>        [ 0.8,  0.6,  1.7]])
>>>
>>> In [15]: vq.whiten(obs)
>>> Out[15]:
>>> array([[ 4.17944278,  2.69811351,  7.21248917],
>>>        [ 3.29956009,  2.93273208,  9.33380951],
>>>        [ 1.75976538,  0.7038557 ,  7.21248917]])
>>>
>>> In [16]: obs / obs.std(axis=0)
>>> Out[16]:
>>> array([[ 4.17944278,  2.69811351,  7.21248917],
>>>        [ 3.29956009,  2.93273208,  9.33380951],
>>>        [ 1.75976538,  0.7038557 ,  7.21248917]])
>>>
>>> In [17]: obs / obs.std(axis=0, ddof=1)
>>> Out[17]:
>>> array([[ 3.41250074,  2.20300046,  5.88897275],
>>>        [ 2.69407953,  2.39456571,  7.62102355],
>>>        [ 1.43684242,  0.57469577,  5.88897275]])
>>>
>>>
>>> The whiten function has not changed in a long time.  Has the
>>> default value of ddof in the numpy std() method changed in
>>> the last five (or more) years?
>>>
>>
>> Four years ago, in 62e99493, a ddof kw was added. But that looks like a
>> backwards-compatible commit to me.  I'll change the output in the whiten
>> docstring.
>>
>> Ralf
>>
>>
> While you're at it, could you fix the spelling mistake ("devation") in the
> description of the return value?   Thanks!
>

Sure, done.

Ralf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20120721/05027f81/attachment-0001.html 


More information about the SciPy-User mailing list