Seems like one could add @inbounds to this line
|
x[i] = rand(rng) < ap[j] ? a[j] : a[alias[j]] |
In fact its here already when using alias table sampling for Categorical in Distributions:
https://github.com/JuliaStats/Distributions.jl/blob/d6de7214e6d84df77d1eb3ec7a98d23862d1232d/src/samplers/aliastable.jl#L19