New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] rint() or round() #1402

Closed
nilgoyette opened this Issue Jan 16, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@nilgoyette
Contributor

nilgoyette commented Jan 16, 2018

Any tracking experts can help me but this is mostly a question for @matthew-brett and @omarocegueda I opened this issue because they are not active on gitter.

My original question was: why do you use rint instead of round? I thought there was a mathematical or anatomical advantage but I couldn't guess what it was. At 0.5, rint prefers the left voxel and round prefers the right voxel. Both are "wrong", or equally right.

@matthew-brett told me that there's only a technical advantage: it was simpler to code. Can you confirm this? There's no other good reason to do this?

My real question is more: will my results be equally valid if I change rint to round?

@matthew-brett

This comment has been minimized.

Member

matthew-brett commented Jan 19, 2018

I guess your results will change, sure, but I guess also they won't change very much, and it will be difficult to detect which is "correct".

I believe the 'round' behavior (round to even) reduces bias, but I'm no expert.

To me, it looks as if dpy_rint is actually rounding to even - so I guess we'll have different behavior depending on whether we get a real rint function or the dpy_rint version.

We copied this from numpy - see: https://github.com/numpy/numpy/blob/master/numpy/core/src/npymath/npy_math_internal.h.src#L290

I've just sent an email to the list to ask for clarification.

@matthew-brett

This comment has been minimized.

Member

matthew-brett commented Jan 19, 2018

Chuck Harris replied that numpy sets the FPU to do round-to-even for rint as well, so I think that means that rint and round are interchangeable for our purposes. I mean, rint and round will give the same answers.

@nilgoyette

This comment has been minimized.

Contributor

nilgoyette commented Jan 24, 2018

Thank you @matthew-brett! Thanks to your investigation, we were able to take a well-informed decision here at my work.

@nilgoyette nilgoyette closed this Jan 24, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment