 # arange

Hi

I've a machine where I used Numeric until now. Does the following behaviour also occur with numpy?

In : Numeric.__version__
Out: '23.8'

In : a = arange(0, 0.005, 0.00001); len(a)
Out: 500

In : a = arange(0, 0.005, 0.000001); len(a)
Out: 5001

Shouldn't len(a)%10 == 0 in these cases?

cheers,
steve

···

--
Random number generation is the art of producing pure gibberish as quickly as possible.

Steve Schmerler wrote:

Hi

I've a machine where I used Numeric until now. Does the following
behaviour also occur with numpy?

In : Numeric.__version__
Out: '23.8'

In : a = arange(0, 0.005, 0.00001); len(a)
Out: 500

In : a = arange(0, 0.005, 0.000001); len(a)
Out: 5001

Shouldn't len(a)%10 == 0 in these cases?

Yes. Floating point is weird.

http://projects.scipy.org/scipy/numpy/ticket/8

Use numpy.linspace() for reliable results. I think matplotlib exposes
linspace(), too.

···

--
Robert Kern
robert.kern@...287...

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter

Use numpy.linspace:

linspace(start, stop, num=50, endpoint=True, retstep=False)
Return evenly spaced numbers.

Return 'num' evenly spaced samples from 'start' to 'stop'. If
'endpoint' is True, the last sample is 'stop'. If 'retstep' is
True then return the step value used.

Cheers,
Alan Isaac

···

On Tue, 28 Feb 2006, Steve Schmerler apparently wrote:

In : a = arange(0, 0.005, 0.00001); len(a) Out:
500
In : a = arange(0, 0.005, 0.000001); len(a)
Out: 5001
Shouldn't len(a)%10 == 0 in these cases?