[Numpy-discussion] numpy.spacing question

Alok Singhal alok at edgestreamlp.com
Thu Dec 4 20:23:15 EST 2014


On Thu, Dec 4, 2014 at 4:25 PM, Ryan Nelson <rnelsonchem at 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 positive number that can be added to x to
get a number that's different from x.

> My expectation is that the first logical test should give an output array
> where all of the results are the same. But it is also very likely that I
> don't have any idea what's going on. Can someone provide some clarification?

For 1e-10, np.spacing() is 1.2924697071141057e-26.  1e-10 * eps is
2.2204460492503132e-26, which, when added to 1e-10 rounds to the
closest number that can be represented in a 64-bit floating-point
representation.  That happens to be 2*np.spacing(1e-10), and not
1*np.spacing(1e-10).

-- 
The information transmitted is intended only for the person(s) or entity to 
which it is addressed and may contain confidential and/or privileged 
material. Any review, retransmission, dissemination or other use of, or 
taking of any action in reliance upon, this information by persons or 
entities other than the intended recipient is prohibited. If you received 
this in error, please contact the sender and delete the material from any 
computer. Email transmission cannot be guaranteed to be secure or 
error-free.

-- 

This information is not intended and should not be construed as investment, 
tax or legal advice or an offer or solicitation to buy or sell any 
security. Any offer or solicitation for any private investment fund advised 
by Edgestream Partners, L.P. or any of its affiliates may only be made by 
delivery of its confidential offering documents to qualified investors.



More information about the NumPy-Discussion mailing list