Skip to content

Commit

Permalink
Avoid aliasing problems in sortedrandrange
Browse files Browse the repository at this point in the history
  • Loading branch information
Tortar committed Apr 27, 2024
1 parent c26a496 commit ea8aa16
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/SortedSamplingMulti.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ end

function sortedrandrange(rng, range, n)
exp_rands = randexp(rng, n)
sorted_rands = accumulate!(+, exp_rands, exp_rands)
sorted_rands = cumsum(exp_rands)
a, b = range.start, range.stop
range_size = b-a+1
cum_step = (sorted_rands[end] + randexp(rng)) / range_size
Expand Down

0 comments on commit ea8aa16

Please sign in to comment.