On Sat, May 1, 2010 at 15:36, Gökhan Sever <[email protected]> wrote:
> Hello,
>
> Is "b" an expected value? I am suspecting another floating point arithmetic
> issue.
>
> I[1]: a = np.arange(1.6, 1.8, 0.1, dtype='float32')
>
> I[2]: a
> O[2]: array([ 1.60000002, 1.70000005], dtype=float32)
>
> I[3]: b = np.arange(1.7, 1.8, 0.1, dtype='float32')
>
> I[4]: b
> O[4]: array([ 1.70000005, 1.79999995], dtype=float32)
>
> A bit conflicting with the np.arange docstring:
>
> " Values are generated within the half-open interval ``[start, stop)``
> (in other words, the interval including `start` but excluding `stop`). "
Not at all. 1.79999995 < 1.8 . However, also note this warning in the
arange() docs:
"""
For floating point arguments, the length of the result is
``ceil((stop - start)/step)``. Because of floating point overflow,
this rule may result in the last element of `out` being greater
than `stop`.
"""
You probably want linspace() instead.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion