You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If length of pool is much smaller than the number of entries we can run the following (working code):
function median_fast(x::PooledVector)
n = length(x)
p = sortperm(x.pool)
counts = zeros(Int, length(p))
for v in x.refs
counts[v] += 1
end
cum = 0
for (j,i) in enumerate(p)
cum += counts[i]
if isodd(n)
if cum >= div(n + 1, 2)
return middle(x.pool[i])
end
else
if cum >= div(n, 2)
if cum == div(n, 2)
return middle(x.pool[i], x.pool[p[j+1]])
else
return middle(x.pool[i])
end
end
end
end
error("unreachable reached")
end
If length of pool is much smaller than the number of entries we can run the following (working code):
Example timings:
The text was updated successfully, but these errors were encountered: