[Numpy-discussion] arange and floating point arguments
Anne Archibald
peridot.faceted@gmail....
Sat Sep 15 00:34:22 CDT 2007
On 15/09/2007, Christopher Barker <Chris.Barker@noaa.gov> wrote:
> Oh, and could someone post an actual example of a use for which FP
> arange is required (with fudges to try to accommodate decimal to binary
> conversion errors), and linspace won't do?
Well, here's one: evaluating a function we know to be bandlimited to N
harmonics and positive trying to bracket a maximum. We know it doesn't
change much faster than T/N, so I might use
xs = arange(0,T,1/float(4*N))
and then evaluate the function there.
Of course, I don't care how many points there are, so no fudges
please. But floating-point arange is certainly useful here; to use
linspace or integer arange I'd have to write it in a much clumsier
way. (Okay, a little clumsier.)
In fact, reluctant as I am to provide arguments in favour of godawful
floating-point fudges, if I have the harmonics I can use irfft to
evaluate my function. I'll then have to carefully calculate the
x-values where irfft evaluates, and an off-by-one problem is going to
cause my program to fail. I would use integer arange and scale as
appropriate, but there's something to be said for using floating-point
arange. linspace(...,endpoint=False) is fine, though.
Anne
More information about the Numpy-discussion
mailing list