Just checking, is this intended?
https://github.com/TuringLang/Turing.jl/blob/cba33402b3d71e95aa5cee9c043db5698b9f3b8c/src/samplers/support/resample.jl#L86
Using rand() like this will add the same random variable to all entries. To broadcast rand as well, we need rand.().
Sharing rand is the correct behaviour here - this resembling function is specifically designed for minismising Monte Carlo variance by reducing total amount of randomness.
Link to the matlab version:
https://uk.mathworks.com/matlabcentral/fileexchange/24968-resampling-methods-for-particle-filtering
This rand() thing is a common mistake so I was double checking. Thanks.
You raised a good point - there might be other places in Turing where we should broadcast rand.
Most helpful comment
Sharing rand is the correct behaviour here - this resembling function is specifically designed for minismising Monte Carlo variance by reducing total amount of randomness.
Link to the matlab version:
https://uk.mathworks.com/matlabcentral/fileexchange/24968-resampling-methods-for-particle-filtering