Re: [Numpy-discussion] numpy.spacing question

2014-12-05 Thread Ryan Nelson
Alok Singhal edgestreamlp.com> writes: > > On Thu, Dec 4, 2014 at 4:25 PM, Ryan Nelson gmail.com> wrote: > > > > I guess I'm a little confused about how the spacing values are calculated. > > np.spacing(x) is basically the same as np.nextafter(x, np.inf) - x, > i.e., it returns the minimum p

Re: [Numpy-discussion] numpy.spacing question

2014-12-04 Thread Alok Singhal
On Thu, Dec 4, 2014 at 4:25 PM, Ryan Nelson wrote: > > I guess I'm a little confused about how the spacing values are calculated. np.spacing(x) is basically the same as np.nextafter(x, np.inf) - x, i.e., it returns the minimum positive number that can be added to x to get a number that's differen

Re: [Numpy-discussion] numpy.spacing question

2014-12-04 Thread Nathaniel Smith
It looks to me like spacing is calculating the 1ulp precision for each of your numbers, while x*eps is suffering from a tidge of rounding error and giving you 1-or-2 ulp precisions. Notice that the x*eps values are either equal to or twice the values returned by spacing. -n On Fri, Dec 5, 2014 at

[Numpy-discussion] numpy.spacing question

2014-12-04 Thread Ryan Nelson
Hello everyone, I was working through the example usage for the test function `assert_array_almost_equal_nulp`, and it brought up a question regarding the function `spacing`. Here's some example code: import numpy as np from numpy.testing import assert_array_almost_equal_nulp np.set_printopt