hanning python

Steven D'Aprano steven at REMOVE.THIS.cybersource.com.au
Wed Sep 9 00:24:56 CEST 2009


On Tue, 08 Sep 2009 11:12:18 -0700, sturlamolden wrote:

> On 8 Sep, 15:08, pdpi <pdpinhe... at gmail.com> wrote:
> 
>> Come, come. I think it's a good rule that, where available, a vendor-
>> supplied implementation is the preferable choice until proven
>> otherwise.
> 
> Even for the simplest of equations?

A decent vendor-supplied implementation will include error checking that 
you otherwise would need to implement yourself, so yes.

Also, given the oddities of floating point, a decent vendor-supplied 
implementation is likely to work successfully on all the corner cases 
where floats act bizarrely, or at least fail less disastrously than a 
naive implementation will.

Third, it's very easy to use the wrong formula, especially for something 
like the Hann window function which is known by two different names and 
is commonly expressed as three different versions, two of which fail for 
a window width of 1.

http://en.wikipedia.org/wiki/Window_function#Hann_window
http://en.wikipedia.org/wiki/Hann_function
http://mathworld.wolfram.com/HanningFunction.html


And finally, no matter how simple the equation, why re-invent the wheel?


-- 
Steven



More information about the Python-list mailing list