How to deal with numerical error in tiedrank

Hi all,

I would like to account for numerical error in tiedrank from StatsBase. For example,

julia> tiedrank([1,1+eps(),3])
3-element Vector{Float64}:
 1.0
 2.0
 3.0

I would like the first two elements to be treated as equal. I saw that it has a keyword ls. I tried passing various functions to ls but nothing worked. Is there a way to account for the numerical error?

Rounding sounds like a good idea:

julia> tiedrank(round.([1,1+eps(),3]; digits=1))
3-element Vector{Float64}:
 1.5
 1.5
 3.0
1 Like

Yeah. I think that is the best approach when the size of the vector is small. I think round will be OK for my use case, but I think I need to use 15 instead of 1 for digits. I don’t know if there is a solution which avoids copying which might be a problem with large vectors. I don’t need that at the moment, but I want to acknowledge the potential performance impact scale.