Skip to content
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 output not sorted #164

Closed
cstjean opened this issue May 24, 2016 · 4 comments
Closed

Quantile output not sorted #164

cstjean opened this issue May 24, 2016 · 4 comments

Comments

@cstjean
Copy link

cstjean commented May 24, 2016

On Julia 0.4.5 and the latest release of StatsBase:

y = [0.40003674665581906,0.4085630862624367,0.41662034698690303,0.41662034698690303,0.42189053966652057,0.42189053966652057,0.42553514344518345,0.43985732442991354]
issorted(quantile(y, linspace(0.01, 0.99, 17)))   # false

The quantiles are:

[0.4006335904282823,0.4042892585346196,0.40794492664095694,
0.4114334853955278,0.41488803593114276,
0.41662034698690303,0.416620346986903, # these two not in order
0.4169958482153258,0.41925544332671183,0.4215150384380978,0.42189053966652057,
0.42189053966652057,0.4226741294789331,0.42423675334903477,0.42657350156657636,
0.4327141366637794,0.4388547717609824]

Is that a bug, or is it a conscious decision to define "empty quantiles"?

@andreasnoack
Copy link
Member

The difference is smaller than eps() and you are asking for more quantiles than you have data points. Is this a real problem for you?

@simonbyrne
Copy link
Member

This is actually a problem in Base, particularly this line.

I think we can fix this by changing

(1-h)*T(v[i]) + h*T(v[i+1])

to

T(v[i]) + h*(T(v[i+1])-T(v[i]))

@cstjean
Copy link
Author

cstjean commented May 24, 2016

It's not a problem for my algorithm, but FWIW it originally happened on a dataset with more unique values than quantiles. I just trimmed it to file the issue.

simonbyrne added a commit to JuliaLang/julia that referenced this issue May 25, 2016
@cstjean
Copy link
Author

cstjean commented May 26, 2016

Thank you for the quick fix @simonbyrne and @andreasnoack

@cstjean cstjean closed this as completed May 26, 2016
nalimilan pushed a commit to JuliaStats/Statistics.jl that referenced this issue Sep 18, 2019
nalimilan pushed a commit to JuliaStats/Statistics.jl that referenced this issue Sep 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants