-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
quantile chokes on integral vectors if it has to interpolate #1333
Comments
Oo. This is a bit of a tough call. If it rounds to a float then you'd want the answer to always be a float, which is kind of a bummer. |
Yep. Boost gives several options, defaulting to using ceiling for quantiles I do agree that the type of the argument should be preserved, so that float On Wed, Oct 3, 2012 at 11:25 PM, Stefan Karpinski
|
Since we've implemented quantile variant #7, i think by definition we have to return 2.5. |
The problem is that "variant 7" as described by R doesn't apply in a On Thu, Oct 4, 2012 at 11:37 AM, Mike Nolta [email protected]:
|
What? Sure it does. It's just math.
That's just too weird and magical. If we want quantile to return the same type as the input, we should switch to variant 1 (like Mathematica) or variant 3. |
Would it make sense for quantile to return variant 1 for Integer arguments On Thu, Oct 4, 2012 at 12:07 PM, Mike Nolta [email protected]:
|
Wait, what?
|
Someone else is going to have to decide what the proper behavior is here! Another idea would be to have separate quantile() and iquantile() Incidentally, this works nicely, preserving input type: julia> x=[1//2, 2//3, 6//11, 9//102] julia> quantile(x, .5) julia> typeof(ans) On Thu, Oct 4, 2012 at 12:42 PM, Mike Nolta [email protected]:
|
I'm reasonably sure that the definition of the median in most textbooks is consistent with Mike's assertion, which only guarantees closure for the rationals. -- John On Oct 4, 2012, at 12:56 PM, Harlan Harris wrote:
|
Do we have a consensus then that the proper course of action is to On Thu, Oct 4, 2012 at 1:22 PM, John Myles White
|
My initial reaction is that there shouldn't be special cases: everything that's a subtype of Real should return a floating point answer as the median. While the rationals may be closed under this operation, it seems like that's the special case. Maybe a good way to reason about this is to think carefully about how one wants a quantile() function to behave, since median is just a special case. My instinct is that you can only put in types that derive from Real and you always get a floating point back out. I believe the implementations in distributions.jl behave this way because Rmath does. Do other languages actually define medians over any totally ordered set that's not the reals? My assumption is no, but I don't really know. -- John On Oct 5, 2012, at 11:39 AM, Harlan Harris wrote:
|
Anyone want to argue the correct behavior? Return a float? Round to the nearest integer? Fail with a nicer error message?
The text was updated successfully, but these errors were encountered: