Skip to content

Commit

Permalink
RFC:add functionality for quantiles of vectors of infinity (#19574)
Browse files Browse the repository at this point in the history
* add functionality for quantiles of vectors of infinity

* fixed spacing
  • Loading branch information
alexhallam authored and tkelman committed Dec 19, 2016
1 parent 1a983b2 commit 071c60a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/statistics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ end
else
a = T(v[i])
b = T(v[i+1])
return a + h*(b-a)
return a + ifelse(a == b, zero(a), h*(b-a))
end
end

Expand Down
1 change: 1 addition & 0 deletions test/statistics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ end
@test quantile(100.0:-1.0:0.0, 0.0:0.1:1.0) == collect(0.0:10.0:100.0)
@test quantile(0.0:100.0, 0.0:0.1:1.0, sorted=true) == collect(0.0:10.0:100.0)
@test quantile(100f0:-1f0:0.0, 0.0:0.1:1.0) == collect(0f0:10f0:100f0)
@test quantile([Inf,Inf],0.5) == Inf

@test quantile([0,1],1e-18) == 1e-18

Expand Down

0 comments on commit 071c60a

Please sign in to comment.