I now understand (from Multi-threading) that I need to generate random seeds for each thread to avoid race conditions if I wish to speed up the generation of independent random variables. One good and straightforward way of doing this is the following code snippet from Parallel Computing · The Julia Language
using Random
import Future
rseed = let m = MersenneTwister(1)
[m; accumulate(Future.randjump, fill(big(10)^20, Threads.nthreads()-1), init=m)]
end;
The problem is that I wish to generate Inverse Wishart random variables from the Distributions package but find that I’m unable to do so because of the way the related InverseWishart()
function and its extensions are defined. Executing
rand( rseed[1], InverseWishart( 5, [1.0 0; 0 1] ) )
will return
ERROR: ArgumentError: Sampler for this object is not defined
Wonder if anyone would be able to guide me to a workaround? I tried looking the base codes of the function InverseWishart
from Distributions.jl/inversewishart.jl at b05da33f63421994868b3ec57ff57fb6a7b36d7e · JuliaStats/Distributions.jl · GitHub
to try and work something out but struggled to understand and meaningfully manipulate their definitions to my favour.